.model small
disp macro a
mov ah,09h
lea dx,a
int 21h
endm
.data
count db 00h
msg1 db 10,13,"Enter the no of elements:$"
arr db 10 dup(0)
msg2 db 10,13,"Enter the no:$"
sum dw 0000h
count1 db 00h
msg3 db 10,13,"Addition:$"
.code
main:
mov ax,@data
mov ds,ax
disp msg1
call accept
mov count,bl
mov count1,bl
mov SI,00h
lea SI,arr
up:
disp msg2
call accept
mov [SI],bl
inc SI
dec count
cmp count,00h
jg up
mov SI,00h
lea SI,arr
up1:
mov bx,[SI]
mov bh,00h
add sum,bx
inc SI
dec count1
cmp count1,00h
jg up1
disp msg3
call print
mov ah,4ch
int 21h
accept proc near
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down
sub al,07h
down:
shl al,04h
mov bl,al
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down1
sub al,07h
down1:
add bl,al
ret
accept endp
print proc near
mov bx,sum
shr bx,0Ch
cmp bl,09h
jle down2
add bl,07h
down2:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,sum
shr bx,08h
and bl,0Fh
cmp bl,09h
jle down3
add bl,07
down3:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,sum
shr bx,04h
and bl,0Fh
cmp bl,09h
jle down4
add bl,07h
down4:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,sum
and bl,0Fh
cmp bl,09h
jle down5
add bl,07h
down5:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
ret
print endp
end main
end
disp macro a
mov ah,09h
lea dx,a
int 21h
endm
.data
count db 00h
msg1 db 10,13,"Enter the no of elements:$"
arr db 10 dup(0)
msg2 db 10,13,"Enter the no:$"
sum dw 0000h
count1 db 00h
msg3 db 10,13,"Addition:$"
.code
main:
mov ax,@data
mov ds,ax
disp msg1
call accept
mov count,bl
mov count1,bl
mov SI,00h
lea SI,arr
up:
disp msg2
call accept
mov [SI],bl
inc SI
dec count
cmp count,00h
jg up
mov SI,00h
lea SI,arr
up1:
mov bx,[SI]
mov bh,00h
add sum,bx
inc SI
dec count1
cmp count1,00h
jg up1
disp msg3
call print
mov ah,4ch
int 21h
accept proc near
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down
sub al,07h
down:
shl al,04h
mov bl,al
mov ah,01h
int 21h
sub al,30h
cmp al,09h
jle down1
sub al,07h
down1:
add bl,al
ret
accept endp
print proc near
mov bx,sum
shr bx,0Ch
cmp bl,09h
jle down2
add bl,07h
down2:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,sum
shr bx,08h
and bl,0Fh
cmp bl,09h
jle down3
add bl,07
down3:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,sum
shr bx,04h
and bl,0Fh
cmp bl,09h
jle down4
add bl,07h
down4:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
mov bx,sum
and bl,0Fh
cmp bl,09h
jle down5
add bl,07h
down5:
add bl,30h
mov dl,bl
mov ah,02h
int 21h
ret
print endp
end main
end
--------------------------------------------------OUTPUT------------------------------------------------
D:\tasm\BIN>edit
addition.asm
D:\tasm\BIN>tasm
addition.asm
Turbo Assembler Version 4.1
Copyright (c) 1988, 1996 Borland International
Assembling file: addition.asm
Error messages: None
Warning
messages: None
Passes: 1
Remaining
memory: 451k
D:\tasm\BIN>tlink
addition.obj
Turbo Link Version 7.1.30.1. Copyright (c) 1987, 1996
Borland International
Warning: No stack
D:\TASM\BIN>addition
Enter the no of
elements:04
Enter the no:04
Enter the no:04
Enter the no:04
Enter the no:03
Addition:000F
D:\TASM\BIN>
------------------------------------------------------------------------------------------------------------------------------------------------------------