RosettaCodeData/Task/Least-common-multiple/360-Assembly/least-common-multiple.360
2023-07-01 13:44:08 -04:00

30 lines
1.2 KiB
Text

LCM CSECT
USING LCM,R15 use calling register
L R6,A a
L R7,B b
LR R8,R6 c=a
LOOPW LR R4,R8 c
SRDA R4,32 shift to next reg
DR R4,R7 c/b
LTR R4,R4 while c mod b<>0
BZ ELOOPW leave while
AR R8,R6 c+=a
B LOOPW end while
ELOOPW LPR R9,R6 c=abs(u)
L R1,A a
XDECO R1,XDEC edit a
MVC PG+4(5),XDEC+7 move a to buffer
L R1,B b
XDECO R1,XDEC edit b
MVC PG+10(5),XDEC+7 move b to buffer
XDECO R8,XDEC edit c
MVC PG+17(10),XDEC+2 move c to buffer
XPRNT PG,80 print buffer
XR R15,R15 return code =0
BR R14 return to caller
A DC F'1764' a
B DC F'3920' b
PG DC CL80'lcm(00000,00000)=0000000000' buffer
XDEC DS CL12 temp for edit
YREGS
END LCM