-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd_two_array.asm
More file actions
38 lines (30 loc) · 1007 Bytes
/
Add_two_array.asm
File metadata and controls
38 lines (30 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
; 2. Define three arrays as follows:
; Arr1 byte 11h, 22h, 33h, 44h, 55h
; Arr2 byte 66h, 77h, 88h, 99h, 0AAh
; Arr3 byte 5 DUP(?)
; Now, add corresponding elements of Arr1 and Arr2 and store the result of each addition at the respective indices ; in Arr3. First, find the size of one of these arrays by using the $ operator. Then, load the size in ecx register and ; use a loop to perform the element-wise addition. Paste your code and screenshot of Memory window showing ; Arr3 in the space below:
;------------------------------------
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
arr1 byte 11h, 22h, 33h, 44h, 55h
arr2 byte 66h, 77h, 88h, 99h, 0AAh
arr3 byte 5 DUP(?)
;size_arr1 = ($-arr1) ; f
.code
main PROC
; ecx ->> 5 4 3 2 1
; ebx ->> 0 1 2 3 4 5
mov ebx, 0
mov ecx, LENGTHOF arr1
loop1:
mov al, [arr1+ebx]
add al , [arr2+ebx]
mov [arr3+ebx] , al
inc ebx
loop loop1
INVOKE ExitProcess,0
main ENDP
END main