Nardil stack
This commit is contained in:
parent
522f886eea
commit
68480249b4
3 changed files with 80 additions and 0 deletions
27
ass1/Rekurzija/rek_sum.asm
Normal file
27
ass1/Rekurzija/rek_sum.asm
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue