The addition and subtraction of Arrays by using Assembly Language

Bismillahir Rahmanir Rahim
Here the first array is ar=[1,2,3,4,5]
2nd is br=[6,7,8,9,10]
3rd is cr=[11,12,13,14,15]
4th is dr=[16,17,18,19,20]
the equation is sr=ar+br+cr-dr.
I added a extra function to print string.
mov ah,09
mov dx,offset msg ;msg='The result are= '
int 21h

 
mov ah,09
mov dx,offset coma ;coma=' , '
int 21h
 I think, you understand it why i use this string. I am not use this two string the output will be show as
2d4d6d8d10d
instead of this The result is = 2d, 4d, 6d, 8d, 10d

solution:

if 1
include mylib1.lib
endif

mydata segment
aR db 1,2,3,4,5 
bR db 6,7,8,9,10 
cR db 11,12,13,14,15
dr db 16,17,18,19,20
sR db 0,0,0,0,0
msg db "The result are= $"
coma db " , $"
COUNT EQU 05
mydata ends

mystack segment
db 100 dup(0)
mystack ends

mycode segment
assume cs:mycode, ds:mydata, ss:mystack
start:
 mov ax, seg mydata
 mov ds, ax
 mov ax, seg mystack
 mov ss, ax

 MOV CX,COUNT
 MOV SI,0000

 mov ah,09
 mov dx,offset msg ;solved by adhoa
 int 21h
BACK: 
 mov al,[si+ar]
 add al,[si+br]
 add al,[si+cr]
 sub al,[si+dr]
 mov [si+sr], al
 inc si
 push cx
 mov bh,0
 mov bl,al

 printd
 pop cx 

 mov ah,09
 mov dx,offset coma ;solved by adhoa
 int 21h

 loop back

mov ax, 4c00h
int 21h

printfd

mycode ends
end start
if you have to face any problem to solve or understand it ,comment below or contact admain  in facebook  .
Best of luck.

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →