Factorial: Difference between revisions
Content added Content deleted
PatGarrett (talk | contribs) m (→{{header|360 Assembly}}: Better editing) |
|||
Line 86: | Line 86: | ||
L R15,=A(FACT) |
L R15,=A(FACT) |
||
BALR R14,R15 call fact(n) |
BALR R14,R15 call fact(n) |
||
ZAP F,0(L'R,R1) f=fact(n) |
|||
DUMP EQU * |
DUMP EQU * |
||
MVC S,MASK |
|||
ED S,N |
|||
MVC WTOBUF+5(2),S+30 |
MVC WTOBUF+5(2),S+30 |
||
MVC S,MASK |
|||
ED S,F |
|||
MVC WTOBUF+9(32),S |
MVC WTOBUF+9(32),S |
||
WTO MF=(E,WTOMSG) |
WTO MF=(E,WTOMSG) |
||
AP N,=P'1' n=n+1 |
|||
B LOOPN |
|||
ENDLOOPN EQU * |
ENDLOOPN EQU * |
||
RETURN EQU * |
RETURN EQU * |
||
Line 111: | Line 111: | ||
LOOP CP I,L if i>l |
LOOP CP I,L if i>l |
||
BH ENDLOOP then goto endloop |
BH ENDLOOP then goto endloop |
||
MP R,I r=r*i |
|||
AP I,=P'1' i=i+1 |
|||
B LOOP |
|||
ENDLOOP EQU * |
ENDLOOP EQU * |
||
LA R1,R return r |
LA R1,R return r |