;; file: gcd.s ;; author: SS ;; date: Sep 9, 2019 ;; ;; This program reads in two nonnegative integers a and b, ;; then prints their gcd. ;; ;; The SLIM code translates the following python code: ;; ;; a = int(input()) ;; b = int(input()) ;; while b > 0: ;; a, b = b, a%b ;; print(a) allocate-registers zero a b loop write r test li zero 0 li loop loopL li write writeL read a read b loopL: sgt test b zero jeqz test write rem r a b sub a a a add a a b sub b b b add b b r j loop writeL: write a halt