.model small
.stack 100h
.data
msg db 'enter first numbers ','$'
msg1 db 'sum of two numbers is: ','$'
msg2 db 'enter 2nd number ','$'
chars1 db 10 dup(0),'$'
chars2 db 10 dup(0),'$'
chars3 db 10 dup(0),'$'
m dw 0
n dw 0
cr db '0'
k db ?,'$'
.code
main proc far
mov ax,@data
mov ds,ax
mov ah,9h
lea dx,msg
int 21h
lea si,chars1
pawan: ;to take input 1st number
mov ah,1
int 21h
mov [si],al
inc si
inc m
cmp al,'$'
jne pawan
dec m
dec m ;to find lenght of 1st number
mov ah,9
lea dx,chars1
int 21h
lea di,chars2
mov ah,9h
lea dx,msg2
int 21h
pawan1: ;to take input of 2nd number
mov ah,1h
int 21h
mov [di],al
inc di
inc n
cmp al,'$'
jne pawan1
dec n
dec n
clc
lea si,chars1
add si,m
lea di,chars2
add di,n
lea bx,chars3
inc m
add bx,m
mov cx,m
a20:
mov ax,[si]
adc al,[di]
aaa
mov [bx],al
dec si
dec di
dec bx
loop a20
mov [bx],ah
lea bx,chars3
add bx,m
inc m
mov cx,m
a30:
or byte ptr[bx],30h
dec bx
loop a30
mov ah,9
lea dx,chars3
int 21h
mov ah,4ch
int 21h
main endp
end main
.stack 100h
.data
msg db 'enter first numbers ','$'
msg1 db 'sum of two numbers is: ','$'
msg2 db 'enter 2nd number ','$'
chars1 db 10 dup(0),'$'
chars2 db 10 dup(0),'$'
chars3 db 10 dup(0),'$'
m dw 0
n dw 0
cr db '0'
k db ?,'$'
.code
main proc far
mov ax,@data
mov ds,ax
mov ah,9h
lea dx,msg
int 21h
lea si,chars1
pawan: ;to take input 1st number
mov ah,1
int 21h
mov [si],al
inc si
inc m
cmp al,'$'
jne pawan
dec m
dec m ;to find lenght of 1st number
mov ah,9
lea dx,chars1
int 21h
lea di,chars2
mov ah,9h
lea dx,msg2
int 21h
pawan1: ;to take input of 2nd number
mov ah,1h
int 21h
mov [di],al
inc di
inc n
cmp al,'$'
jne pawan1
dec n
dec n
clc
lea si,chars1
add si,m
lea di,chars2
add di,n
lea bx,chars3
inc m
add bx,m
mov cx,m
a20:
mov ax,[si]
adc al,[di]
aaa
mov [bx],al
dec si
dec di
dec bx
loop a20
mov [bx],ah
lea bx,chars3
add bx,m
inc m
mov cx,m
a30:
or byte ptr[bx],30h
dec bx
loop a30
mov ah,9
lea dx,chars3
int 21h
mov ah,4ch
int 21h
main endp
end main
No comments:
Post a Comment