spo/ass1/Rekurzija/stack.asm
2025-11-06 13:02:39 +01:00

37 lines
No EOL
683 B
NASM

prog START 0
JSUB sinit
LDX #5
STX @stkp
JSUB spush
JSUB spop
CLEAR X
LDX @stkp
halt J halt
stkp WORD 0
stk RESW 1000
stkA WORD 0 . Zacasni prostor za shranjevanje registra A
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
END prog