%include 'Functions.asm'
section .data
wordArray dw 0, 1, 2, 3, 4, 5
length equ $-wordArray
ddArray dd 0, 1, 2, 3, 4, 5
section .text
global main
main:
mov ebp, esp; for correct debugging
mov esi, wordArray
mov edi, ddArray
mov ecx, 0
convert:
mov bx, [esi + ecx * 2]
movzx edi, bx
inc ecx
cmp ecx, length
jne convert
mov eax, ddArray
call intLineFeed
call exit
I am trying to uss a loop to copy all the elements from an unsigned Word (16-bit) array into an unsigned doubleword (32-bit) array. However, I don't think I am doing it correctly.
Output I am receiving 134520880
You are overwriting the output pointer edi
instead of writing to the output array. Instead of:
mov bx, [esi + ecx * 2]
movzx edi, bx
You could try:
movzx ebx, word [esi + ecx * 2]
mov [edi + ecx * 4], ebx
Also note that you need to divide the length
by two, since you have it declared as a byte count, so you need cmp ecx, length / 2
PS: Your output array already contains the proper data.
PPS: Not sure what mov eax, ddArray; call intLineFeed
mov eax, ddArray; call intLineFeed
is supposed to do, I guess that's printing the address of your array so that's why you get 134520880
as output.
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.