i add two numbers but wen it cums to displaying the res by using service 2 of int21,,,,i get the res in hes,,i want same in dec,,,i meam like add 02,01 dispalys a res which stands for heart symbol so that i get a heratsymbol as a res instead of getting 3,,plz help..its got over my nerves now

MOV AL, 2 ; AL = 2
ADD AL, 1 ; AL = 3
RET

What is your problem with that?

movi a ,#2 ; immediately move 2 to accumulator
mov b,a ; move accumulator to b Reg
mvi a, #4 :immediately move 4 to accumulator
add b ; add a & b

This is because when you output the value 03 to the screen using
AH=02h of INT 21h it will write it to text mode memory,
when this is done it will display the associated ASCII character,
which for 03 is the Heart symbol.
It seems you would like to display the decimal representation of a binary
value in memory.
The ASCII values 48 to 57 represent the printable '0' ,'1','2'...'9'
so that when you output them to the screen or write them to video memory
there associated printable character is displayed.
You have to do some math and arithmetic comparisons to figure out what
digits make up the number and print it to the screen.

There is a way to do this
when ever you find a digit keep a count to track its decimal
place.
So that it can be multiplied by 10, so 781 = (7*100) + (8*10) + (1*1)
You can find the value of the fist digit by decrementing the value by one,
until a certain condition is reached.

For the value 128, when the value has became 120 it will have been
decremented 8 times. To confirm that this is the value of the first digit,
Take 128 - 8 = 120 - 120 = 0, thus a result of zero would confirm this (Zero Flag).
To get the next digit take 120, and subtract it by ten, until a certain condition
is reached.
When it equals 100 it will have been subtracted 2 times by 10.
To confirms that this is the value of the second digit,
take 2*10=20, that is, multiply the count by ten.
Then 120 - 20 = 100 - 100 = 0, this would confirm that the next
digits value is 2, and would set the ZF (zero flag).
This is the process,
to continually to get the decimal positions value,
as you are going through the digits take the value which
you will be using to subtract from the number which at first
will be 1, and multiply it by 10 storing it in the location
you will be using to subtract your sums.
A=1
So for the first digit keep A and do not multiply (A=1).
Then for the second digit A=A*10 (A=10).
Then for the third digit A=A*10 (A=100).

To then get the printble characters:

str db "0123456789"
mov bx, offset str
mov ax,02      ; Value of digit
add bx,ax       ; Add the value to the offset of your array 
                     ; of bytes, getting ASCII '2'
mov bl,byte ptr [bx]  ; This will place the ASCII value 50 into bl, to print '2'

This isn't the only way, at least I'm pretty sure.
But many of the processes it uses will be present in nearly any algorithm
which performs the same action.

A simple integer to ascii conversion can be done for each decimal
place. Thus 23 / 10 = 2.3, to get the ascii charcter
add 48 to 2 (the quotient) to get the ascii value of the character '2'.
Merely change the division, for each digit, after
decrementing the value by the value of the decimal place
times the quotient.
Thus, for the above:
23 / 10 = 2.3
2 + 48 = 50 ; '2'
2 * 10 = 20
23 - 20 = 3
3 / 1 = 3
3 + 48 = 51 ; '3'

This code will print "23" to the screen.

jmp start
decval db 23

start:
mov bh,00h
mov bl,0Ah   ; 0Ah = 10d, the value of the 10's place
mov ah,0
mov al,[decval]
div bl
mov cl,al
xchg dl,cl
add dl,30h
mov ah,02h
int 21h

sub [decval],20  ; Subtract the value by the value of digit in the tens place
                          ;  To get the next digit
mov bh,00h
mov bl,01h     ; 1, the value of the 1's place
mov ah,0
mov al,[decval]
div bl
mov dl,al
add dl,30h
mov ah,02h
int 21h

mov ax,4c00h
int 21h

So I can't add decimal values?
Nice joke :)
"here take took scoop fulls of meds"

Who could not understand the student's plea:
"so that i get a heratsymbol as a res instead of getting 3"
He wanted to print out the character 3,
so he could see the result of adding 2 + 1,
to the screen, but when he output value 3 to the console,
he got the heart symbol.
This is because the printable character '3' has the ascii
value 51, and the ascii value 3 is the heart symbol.
What's your problem with that?
PRINTING TO THE SCREEN?
For one,
the result of arithmetic operations are
not directly printable to the screen.
So why was the student printing to the
screen? It is obvious...

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.