;; Read in two integers a, b and print out their gcd, ;; like in the following python script: ;; ;; a = input() ;; b = input() ;; if a < 0: a = -a ;; if b < 0: b = -b ;; while b > 0: ;; a, b = b, a % b ;; print a allocate-registers a ; input/output allocate-registers b ; input allocate-registers bzero, gcd, testb ; labels allocate-registers zero ; constant allocate-registers newb, test ; temporary li zero 0 li testb Ltestb li gcd Lgcd li bzero Lbzero read a read b slt test a zero jeqz test testb sub a zero a Ltestb: slt test b zero jeqz test gcd sub b zero b Lgcd: jeqz b bzero rem newb a b add a b zero add b newb zero j gcd Lbzero: write a halt