This is the code that I have written in 8086 using MASM. The code is for simple addition of two 8-bit numbers (no need to worry about carry). I gave for input to the following program, two numbers: 31h and 16h . The output should have been 47h but it is giving me the output as 'w'. The code works fine if I take numbers whose some does not exceed 9, can someone please point out my mistake here?
CODE:
data segment
n1 db 31h
n2 db 16h
data ends
code segment
assume cs:code, ds:data
start:
mov ax,data
mov ds,ax
mov al,n1
mov bl,n2
add al,bl
add al,30h
mov dl,al
mov ah,02h
int 21h
mov ah,4ch
int 21h
code ends
end start
After you add the two constants you wanted, you add al,30h
, giving you a value of 77h
. This is the ASCII code for w
, which you then print as an ASCII character rather than a number.