spo/ass1/Rekurzija/rek.asm
2025-11-10 13:41:50 +01:00

59 lines
No EOL
961 B
NASM

rek START 0
loop RD #0xFA
COMP #1
JLT halt
JSUB fa
WD #1
CLEAR A
J loop
halt J halt
fa STL @stkp
JSUB spush
STB @stkp
JSUB spush
. Base case
COMP #2
JLT faExit
RMO A, B
SUB #1
JSUB fa
MULR B, A
faExit JSUB spop
LDB @stkp
JSUB spop
LDL @stkp
RSUB
sinit STA stkA
LDA #stk
STA stkp
LDA stkA
RSUB
spush . stkp++
STA stkA
LDA stkp
ADD #3
STA stkp
LDA stkA
RSUB
spop . stkp--
STA stkA
LDA stkp
SUB #3
STA stkp
LDA stkA
RSUB
stkp WORD 0
stk RESW 1000
stkA WORD 0
END rek