×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# 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
mov    snum,ah  ;stores second digit
mov    ah,2
mov    dl,al  ;display first digit
int    21h
mov    al,snum
mov    dl,al   ;display second digit
int    21h

next:   inc    bx
loop   outtake

### RE: outputing numbers from an array

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."

### RE: outputing numbers from an array

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."

### RE: outputing numbers from an array

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."

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!