GAS LISTING gcd.s page 1 1 # These are needed to link with glibc. 2 .option pic0 3 4 .text 5 .globl gcd # make gcd externally linkable 6 7 gcd: 8 0000 00804025 move $t0, $a0 9 0004 00A04825 move $t1, $a1 10 11 loop: 12 # This is Euclid's algorithm. 13 0008 15200002 divu $t0, $t1 # results are in `lo` and `hi` registers 13 0109001B 13 0007000D 13 00004012 14 0018 00005010 mfhi $t2 # copy `c`, the remainder, from the `hi` register to $t2 15 001c 11400004 beq $t2, $0, zeroRemainderFound 15 00000000 16 0024 01204025 move $t0, $t1 # a = b 17 move $t1, $t2 # b = c 18 0028 08000002 j loop 18 01404825 19 20 zeroRemainderFound: 21 move $v0, $t1 22 0030 03E00008 jr $ra 22 01201025 22 00000000 22 00000000 GAS LISTING gcd.s page 2 DEFINED SYMBOLS gcd.s:7 .text:0000000000000000 gcd gcd.s:11 .text:0000000000000008 loop gcd.s:20 .text:0000000000000030 zeroRemainderFound NO UNDEFINED SYMBOLS