Suppose A={1,2,3,4} and B={2,3,4,5} be two arrays. How can we initialize them by using loops? And how can we add corresponding elements of these arrays and store them into 3rd array by using loops? My assembler is masm615.
include irvine32.inc
.data
word ayyay1 5 dup(?)
word ayyay2 5 dup(?)
.code
main proc
top:
----------
----------
loop top
call dumpregs
exit
main endp
end main
Untested but generally guiding:
include irvine32.inc
.data
word ayyay1 5 dup(?)
word ayyay2 5 dup(?)
.code
main proc
lea edi, [ayyay1]
lea esi, [ayyay2]
mov ax, 1
mov bx, 2
mov cx, 4
top:
mov word [edi],ax
mov word [esi],bx
inc ax
inc bx
add edi,2 ; add to point to next word location
add esi,2 ; add to point to next word location
loop top
call dumpregs
exit
main endp
end main
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.