[英]Copying a Word Array to a DoubleWord array NASM assembly
%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. 我正在尝试使用一个循环,将所有元素从一个无符号的Word(16位)数组复制到一个无符号的双字(32位)数组中。 However, I don't think I am doing it correctly. 但是,我认为我做的不正确。
Output I am receiving 134520880 输出我正在接收134520880
You are overwriting the output pointer edi
instead of writing to the output array. 您将覆盖输出指针edi
而不是写入输出数组。 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
另请注意,您需要将length
除以二,因为您已将其声明为字节数,因此需要cmp ecx, length / 2
PS: Your output array already contains the proper data. PS:您的输出数组已经包含正确的数据。
PPS: Not sure what mov eax, ddArray; call intLineFeed
PPS:不确定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. mov eax, ddArray; call intLineFeed
应该可以完成,我想这是在打印数组的地址,所以这就是为什么要获得134520880
作为输出的原因。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.