diff --git a/ass1/fac.asm b/ass1/fac.asm new file mode 100644 index 0000000..0e77c99 --- /dev/null +++ b/ass1/fac.asm @@ -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 \ No newline at end of file diff --git a/ass1/stack.asm b/ass1/stack.asm new file mode 100644 index 0000000..bd6940d --- /dev/null +++ b/ass1/stack.asm @@ -0,0 +1,33 @@ +prog START 0 + JSUB sinit + LDT #4 + STT @stkp + JSUB spush + JSUB spop + CLEAR T + LDT @stkp + +halt J halt + +.rutine za sklad +sinit LDA #stkRESW .inicializiraj stkp + STA stkp + RSUB + +spush LDA stkp .poveca stkp za 3 + ADD #3 + STA stkp + RSUB + +spop LDA stkp .zmanjsa stkp za 3 + SUB #3 + STA stkp + RSUB + +.podatki za sklad +stkp WORD 0 +stkRESW WORD 1000 + + END prog + +