30 lines
No EOL
727 B
NASM
30 lines
No EOL
727 B
NASM
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 |