CS2253/Assigments/4/fraction (original).asm

23 lines
563 B
NASM
Raw Normal View History

2023-05-25 18:39:26 -03:00
.ORIG x3000
LD R0, NUM
LD R1, DEN
JSR GCD
ADD R4, R1, #0
ADD R1, R2, #0
JSR DIVIDE
ST R2, NUM
ADD R0, R4, #0
JSR DIVIDE
ST R2, DEN
HALT
; you can try other values for NUM and DEN by replacing these values in the simulator
NUM .FILL #10 ; you can try other values for NUM and DEN by replacing
DEN .FILL #3
; Divide R0 by R1, putting quotient in R2 and remainder in R3
DIVIDE
; Euclid's algorithm for GCD of R0 and R1, result in R2
GCD
.END