Create an assembly language program that will have two arrays, of five elements
ID: 3725431 • Letter: C
Question
Create an assembly language program that will have two arrays, of five elements each. Sum the corresponding elements in the two arrays together and store the result in one of the arrays. Do this for each element. In other words: a[0] = a[0] + b[0] a[1] = a[1] + b[1] etc. When this is complete, add all of the values in the array that contains the sums together, and store that value in memory. The values in each array should be: 1, 2, 3, 4, 5 . The code that adds the two arrays together and then sums the elements together is to be in a separate sub-routine.
Explanation / Answer
;arrays values declared
data segment
array1 db 1h,2h,3h,4h,5h,6h
array2 db 1h,2h,3h,4h,5h,6h
data ends
code segment
assume cs:code , ds:data
start:
mov ax,data
mov ds,ax
lea si,array1 ;loading array1 value
lea di,array2 ;loading array1 value
mov cl,6 ;loop counter value
l1:
mov al,[si] ;loading array1 value
add al,[di] ;adding array1 with array2
mov [si],al ;after adding array value storing back to array1
inc si ;incrementing two arrays pointers
inc di
dec cl ;decrementing counter
jnz l1
mov ah,4ch
int 21h
code ends
end start
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.