Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi! I need to add two numbers and return the result in number (decimal) not hex or binary or char. I am using emulator8086.
I've done something like this:

ASM
org 100h
mov al,6
mov bl,5
add al,bl
mov dl,al
mov ah,02h
int 21h
int 20h


The result is in a character. Then how do I get an answer 11?
Then to add a big number (I mean more than 9, e.g. 97 + 17), I guess I need to use 16 bit register (AX, BX, CX, DX), Correct me if I am wrong. Any response, thanks!

Thanks

-Rudy
Posted

1 solution

In order to output the number 11 to the display you have to call the interrupt 21h two times, providing the character '1' (that is the value 31h) as dl argument.

Generally speaking, in order to ouput (in decimal representation) the content of a 8bit register you have to:
  • divide (integer division) it by 100, take the quotient, add 30h, assign to dl and call int 21h.
  • divide the reminder by 10, take the quotient, add 30h, assign to dl and call int 21h.
  • Finally, add 30h to the reminder, assign to dl and call int 21h.


(you may also iteratively extract such characters, proceding backwards).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900