org 100h ; set location counter to 100h
.model small
.stack 200
.data
crlf db 0dh,0ah,'$'
prompt1 db 'enter the first positive integer: ','$'
prompt2 db 'enter the second positive integer: ','$'
prompt3 db 'The sum of two numbers is: ','$'
num1 db ?
num2 db ?
res1 db ?
res2 db ?
.code
.startup
lea dx, prompt1
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
mov cl, al
mov ah, 01h
int 21h
sub al, 30h
mov num1, al
lea dx, crlf
mov ah,09h
int 21h
lea dx, prompt2
mov ah, 09h
int 21h
mov ah, 01h
int 21h
sub al, 30h
add al,cl
mov res1, al
mov ah, 01h
int 21h
sub al, 30h
add al, num1
mov res2,al
lea dx, crlf
mov ah,09h
int 21h
lea dx,prompt3
mov ah,09h
int 21h
mov dl,res1
add dl,30h
mov ah, 02h
int 21h
mov dl,res2
add dl,30h
mov ah, 02h
int 21h
.exit
end
The code above is working only if the number you're adding don't have any carry on it. Like if I add 16+13 the answer would be correct but if i add 19+13, it would display just 2 and a ascii character..How would I solve this?