qf/in.asm

56 lines
773 B
NASM
Raw Normal View History

2019-11-18 00:30:59 +00:00
:> end
2019-10-26 18:12:25 +00:00
cs push \ copy code segment to data segment
ds pop
2019-11-18 00:30:59 +00:00
\ read number
\ clobbers: ax, bx, cx, dx
dx dx xor
cx cx xor
bx 10 # mov
dx push
:> readnext
ax &h0100 # mov
&h21 int
:> readover
al in@ 0 # cmp
readover jl
al in@ 9 # cmp
readover jg
cl al mov
cl in@ 0 # sub
ax pop
bx mul
ax cx add
ax push
readnext jmps
readover <:
ax pop
\ ax 0 # mov
\ print number
\ in: ax = number
\ clobbers: ax, bx, cx, dx
cx 10 # mov
bx bx xor
:> moredigits
bx inc
dx dx xor
cx div
dx push
ax 0 # cmp
moredigits jne
2019-10-20 18:53:53 +00:00
:> moredigits
dx pop
2019-11-18 00:30:59 +00:00
dl in@ 0 # add
ax &h0200 # mov
2019-10-22 03:38:30 +00:00
&h21 int
bx dec
moredigits jne
2019-10-22 03:38:30 +00:00
0 .EXIT
2019-11-18 00:30:59 +00:00
end <: