completed rec and again fixed echo
This commit is contained in:
parent
8c8a68cb89
commit
b16c3e23d8
6 changed files with 371 additions and 14 deletions
66
ass1/fact.asm
Normal file
66
ass1/fact.asm
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
prog START 0
|
||||
JSUB sinit
|
||||
LDA #5
|
||||
JSUB fact
|
||||
|
||||
|
||||
|
||||
halt J halt
|
||||
|
||||
.fakulteta
|
||||
fact COMP #1
|
||||
JGT rec
|
||||
LDA #1 .base case
|
||||
RSUB
|
||||
|
||||
rec STL @stkp
|
||||
JSUB spush
|
||||
STA @stkp
|
||||
JSUB spush
|
||||
STB @stkp
|
||||
JSUB spush
|
||||
|
||||
RMO A, B .shrani n v B
|
||||
SUB #1 .n-1
|
||||
JSUB fact .fact(n-1)
|
||||
MULR B, A .n * fact(n-1)
|
||||
|
||||
JSUB spop
|
||||
LDB @stkp
|
||||
JSUB spop
|
||||
.LDA @stkp da ne povozimo odgovora?
|
||||
JSUB spop
|
||||
LDL @stkp
|
||||
|
||||
|
||||
|
||||
RSUB
|
||||
|
||||
|
||||
.rutine za sklad
|
||||
sinit STA stkA
|
||||
LDA #stkRESW .inicializiraj stkp
|
||||
STA stkp
|
||||
LDA stkA
|
||||
RSUB
|
||||
|
||||
spush STA stkA
|
||||
LDA stkp .poveca stkp za 3
|
||||
ADD #3
|
||||
STA stkp
|
||||
LDA stkA
|
||||
RSUB
|
||||
|
||||
spop STA stkA
|
||||
LDA stkp .zmanjsa stkp za 3
|
||||
SUB #3
|
||||
STA stkp
|
||||
LDA stkA
|
||||
RSUB
|
||||
|
||||
.podatki za sklad
|
||||
stkp WORD 0
|
||||
stkA WORD 0
|
||||
stkRESW RESW 1000
|
||||
|
||||
END prog
|
||||
Loading…
Add table
Add a link
Reference in a new issue