;;; Read in three numbers and write out their gcd allocate-registers zero, old-x, x, y, end, gcd ; set up constants li zero, 0 read x read y li end, Lmiddle li gcd, Lgcd ; calculate the gcd of x, y into x and then jump to end Lgcd: jeqz y, end add old-x, x, zero add x, y, zero rem y, old-x, y j gcd Lmiddle: ; put third number into y and do a second gcd computation read y li end, Lend j gcd Lend: write x halt