number reading routine

This commit is contained in:
Jeremy Penner 2019-11-17 19:30:59 -05:00
parent c12c67b556
commit e639d1fd2a
4 changed files with 46 additions and 10 deletions

32
in.asm
View file

@ -1,7 +1,33 @@
:> end
cs push \ copy code segment to data segment
ds pop
ax 0 # mov
\ 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
@ -18,7 +44,7 @@
:> moredigits
dx pop
dl 48 # add
dl in@ 0 # add
ax &h0200 # mov
&h21 int
bx dec
@ -26,4 +52,4 @@
0 .EXIT
cx 11 # mov
end <: