Naredil read.asm da testiram ce pravilno berem znake iz datoteke

This commit is contained in:
Timon 2025-11-12 18:12:43 +01:00
parent b35ff88e19
commit a118970d61

30
ass1/Rekurzija/read.asm Normal file
View file

@ -0,0 +1,30 @@
rd START 0
LDT #10 . Za mnozenje z 10
rloop JSUB read
COMP #0
JEQ halt
WD #1
J rloop
halt J halt
read RD #0xFA . V A se shrani naslednji prebrani znak
COMP #0xA
JEQ rExit . Če preberemo newline gremo na izhod
SUB #0x30 . Sicer iz ascii kode dobimo stevko
LDB tmp
MULR T, B . tmp *= 10
ADDR A, B . tmp += A
STB tmp
J read
rExit LDA tmp . Shranimo prebrano stevilko v A
LDB #0
STB tmp . Ponastavimo tmp
RSUB
END rd
tmp WORD 0