27 lines
No EOL
502 B
NASM
27 lines
No EOL
502 B
NASM
prog START 0
|
|
JSUB sinit
|
|
LDA #5
|
|
JSUB sum
|
|
|
|
halt J halt
|
|
|
|
stkp WORD 0
|
|
stk RESW 1000
|
|
|
|
sinit . nastavi stkp na zacetek sklada
|
|
|
|
|
|
rsum COMP #2
|
|
STL rsumL . Base case
|
|
JLT rsumExit
|
|
RMO A, B
|
|
SUB #1 . recursive case
|
|
JSUB rsum . rsum(n-1)
|
|
ADDR B, A
|
|
|
|
rsumExit LDL rsumL
|
|
RSUB
|
|
|
|
rsumL WORD 0
|
|
|
|
END prog |