outputing numbers from an array
outputing numbers from an array
(OP)
i have the numbers in the array now, both in single and double digits now what i am trying to do is display them back out to the screen.
this is what i have and i dont know why it aint working
mov bx,offset numarray
mov cx,count
outtake:mov al,[bx]
cmp al,9 ;to check if it is double digit
ja divnum
add al,48 ;if single digit then display
mov ah,2
mov dl,al
mov 21h
jmp next
divnum: mov fnum,al ;stores whole num in fnum
mov al,10 ;divide by 10 to place first number in al and remainder in ah
div fnum
add al,48
mov snum,ah ;stores second digit
mov ah,2
mov dl,al ;display first digit
int 21h
mov al,snum
add al,48
mov dl,al ;display second digit
int 21h
next: inc bx
loop outtake
this makes sense to me so i dont see why it aint working. please help
RE: outputing numbers from an array
DIV divides the number in DX:AX or AX by the data you specify.
For example:
mov cl,10
mov ax,50
div cl
ret
will return with al=5, ah=0.
What you tried to do was divide 10 by the number, not divide the number by 10 to get the tens digit.
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
RE: outputing numbers from an array
DIV divides the number in DX:AX or AX by the data you specify.
For example:
mov cl,10
mov ax,50
div cl
ret
will return with al=5, ah=0.
What you tried to do was divide 10 by the number, not divide the number by 10 to get the tens digit.
And here's some research work for you:
There is already an instruction which does the work your divnum routine is doing. Find it. Hint: it is one of the 'Ascii Adjust' instructions.
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
RE: outputing numbers from an array
DIV divides the number in DX:AX or AX by the data you specify.
For example:
mov cl,10
mov ax,50
div cl
ret
will return with al=5, ah=0.
What you tried to do was divide 10 by the number, not divide the number by 10 to get the tens digit.
And here's some research work for you:
There is already an instruction which does the work your divnum routine is doing (or, rather, is trying to do). Find it. Hint: it is one of the 'Ascii Adjust' instructions.
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."