Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outputing numbers from an array

Status
Not open for further replies.

glogic

Programmer
Nov 8, 2001
15
0
0
IE

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
 
Your interpretation of the div instruction is wrong.

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."
 
Your interpretation of the div instruction is wrong.

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."
 
Your interpretation of the div instruction is wrong.

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."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top