RosettaCodeData/Task/Compile-time-calculation/360-Assembly/compile-time-calculation-2.360

23 lines
857 B
Plaintext

MACRO
&LAB FACT &REG,&N parameters
&F SETA 1 f=1
&I SETA 1 i=1
.EA AIF (&I GT &N).EB ea: if i>n then goto eb
&F SETA &F*&I f=f*i
&I SETA &I+1 i=i+1
AGO .EA goto ea
.EB ANOP eb:
MNOTE 0,'Load &REG with &N! = &F' macro note
&LAB L &REG,=A(&F) load reg with factorial
MEND macro end
COMPCALB CSECT
USING COMPCALB,R12 base register
LR R12,R15 set base register
FACT R1,10 macro call
XDECO R1,PG
XPRNT PG,L'PG print buffer
BR R14 exit
PG DS CL12
YREGS
END COMPCALB