23 lines
563 B
NASM
23 lines
563 B
NASM
|
.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
|