In: Computer Science
Given an array labeled as array1 with the values: 11111h,
22222h, 33333h, 44444h
And another array labeled as array2 with the values: 0AEFFh, 23CAH,
1156H
Sum up BOTH arrays through direct addressing and place the sum into the EAX register.
array1 is a DWORD and array2 is a WORD
1. Code:
.data
array1: dw 1111h,2222h,3333h,4444h
array2: dw 0AEFFH,23CAH,1156H
.code
lea esi,array1 ;load the address of array1 to esi
lea edi,array2 ;load the address of array2 to edi
mov eax,[esi] ;load the first number from array1 to eax
add esi,2 ;increment the address to point to the next number in array1
add eax,[esi] ;adding the second number with first number
add esi,2 ;increment the address
add eax,[esi] ;adding third number
add esi,2 ;increment the address
add eax,[esi] ;adding fourth number
add eax,[edi] ;adding first number of array2 with the sum of array1
add esi,2 ;increment the address of array2
add eax,[edi] ;adding the second number
add edi,2 ;increment the address
add eax,[edi] ;adding the third number and store the answer in register eax
hlt
thank u , give thumbs up plz!