Compare commits

..

6 commits

Author SHA1 Message Date
zanostro
fc0c680930 added stack 2025-11-15 12:17:44 +01:00
zanostro
63d5b3448f added stack 2025-11-15 12:16:56 +01:00
zanostro
47f3dcfc12 added cat.asm 2025-11-15 12:02:22 +01:00
zanostro
fb9dd4d7ec added poly.asm 2025-11-15 11:45:14 +01:00
zanostro
39aed69969 added arithr 2025-11-15 11:36:32 +01:00
zanostro
312c953151 added arith 2025-11-15 11:32:52 +01:00
5 changed files with 222 additions and 0 deletions

49
ass1/arith.asm Normal file
View file

@ -0,0 +1,49 @@
arith START 0
. seštevek: sum = x + y
LDA x
ADD y
STA sum
. razlika: diff = x - y
LDA x
SUB y
STA diff
. produkt: prod = x * y
LDA x
MUL y
STA prod
. količnik: quot = x / y
LDA x
DIV y .
STA quot
. ostanek: mod = x - y * (x / y)
STA qtemp
LDA y
MUL qtemp
STA prodtmp
LDA x
SUB prodtmp
STA mod
HALT J HALT
.data
x WORD 5
y WORD 2
sum RESW 1
diff RESW 1
prod RESW 1
quot RESW 1
mod RESW 1
qtemp RESW 1
prodtmp RESW 1
END arith

59
ass1/arithr.asm Normal file
View file

@ -0,0 +1,59 @@
.code
arithr START 0
LDA x ; A = x
LDB y ; B = y
RMO A,S ; S = x
RMO B,T ; T = y
. sum = x + y
RMO S,A ; A = x
ADDR T,A ; A = x + y
STA sum
. diff = x - y
RMO S,A ; A = x
SUBR T,A ; A = x - y
STA diff
. prod = x * y
RMO S,A ; A = x
RMO T,B ; B = y
MULR B,A ; A = x * y
STA prod
. quot = x / y
RMO S,A ; A = x
RMO T,B ; B = y
DIVR B,A ; A = x / y
STA quot
. mod = x % y = x - (x / y)*y
RMO S,A
RMO T,B
DIVR B,A ; A = q = x/y
RMO A,L ; L = q (shrani)
RMO T,A ; A = y
RMO L,B ; B = q
MULR B,A ; A = y*q = produkt
RMO S,B ; B = x
SUBR A,B ; B = x - (y*q)
STB mod
HALT J HALT
.data
x WORD 5
y WORD 2
sum RESW 1
diff RESW 1
prod RESW 1
quot RESW 1
mod RESW 1
END arithr

View file

@ -3,6 +3,7 @@
cat START 0
CLEAR X
read RD #0
STCH BUFF, X

57
ass1/poly.asm Normal file
View file

@ -0,0 +1,57 @@
poly START 0
. potence x^1 .. x^4
LDA x
STA x1
MUL x
STA x2
MUL x
STA x3
MUL x
STA x4
. x3 = 2 * x^3
LDA x3
LDB #2
MULR A,B
STB x3
. x2 = 3 * x^2
LDA x2
LDB #3
MULR A,B
STB x2
. x1 = 4 * x
LDA x1
LDB #4
MULR A,B
STB x1
. vsota vseh
LDA x0
ADD x1
ADD x2
ADD x3
ADD x4
STA result
HALT J HALT
END poly
.data
x WORD 2 ; vrednost x
x4 RESW 1
x3 RESW 1
x2 RESW 1
x1 RESW 1
x0 WORD 5 ; konstanta
result RESW 1
END poly

56
ass1/stack.asm Normal file
View file

@ -0,0 +1,56 @@
.code
stack START 0
LDA #9
STA @stackptr
JSUB stackpush
JSUB stackpop
LDA @stackptr
halt J halt
stackinit
STA stacktmp
LDA #STACK
STA stackptr
LDA stacktmp
RSUB
stackpush
STA stacktmp
LDA stackptr
ADD #3
STA stackptr
LDA stacktmp
RSUB
stackpop
STA stacktmp
LDA stackptr
SUB #3
STA stackptr
LDA stacktmp
RSUB
.data
stackptr WORD 0
stacktmp WORD 0
STACKSIZE EQU 50
STACK RESW STACKSIZE
END stack