;; Greatest Common Divisor ;; Problem 8.3 ;; CS 312 ;; Adam Smyth INCLUDE PCMAC.INC .MODEL SMALL .CODE PUBLIC FindGCD FindGCD PROC ;; Find the GCD of bx and cx cmp cx, 0 jne out2 mov ax, bx ret Out2: cmp bx, 0 jne out3 mov ax, cx ret Out3: cmp bx, -32768 jne Out4 cmp cx, -32768 jne Out5 mov ax, -32768 ret Out5: push bx push cx mov bx, 16384 jmp while1 Out4: push bx push cx cmp bx, 0 jnl While1 neg bx while1: cmp bx, cx je out1 jnl else1 sub cx, bx jmp while1 else1: sub bx, cx jmp while1 out1: mov ax, cx ; Return GCD in Ax register pop cx pop bx ret FindGCD ENDP END