I have a problem when adding 2 numbers in assembly because we are using hex.
When add 4+5 (34h + 35h) the output is 9 but if I add 5+5 (35h + 35h) the output displays colon(:) or 3ah instead of 10.

Here's the sample image when i generate the code.
[IMG]http://i42.tinypic.com/35hpkhs.jpg[/IMG]

Here's my code.

Run>debug
5+4 = 9

a100 ;assemble
mov ah,02
mov ch,35 ;5
mov cl,35
add cl,ch ;5+5
sub cl,30 ;-30
mov dl,cl
int 21
int 20

g

Adding 5 + 5 = :

-a100
mov ah,02
mov ch,34 ;4
mov cl,35
add cl,ch
sub cl,30
mov dl,cl
int 21
int 20

-g

Thanks in advance for your reply.

Subtract the 30h before doing the math.
Keep in mind: what you are after is not a single character after you go above 9.
You are dealing with the difference between the ASCII chart, actual values and what a human expects to "see".

Once above 9, you will need to convert the hex to decimal (or value to string).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.