2

This is a question identical to previous post. The objective is to take a BYTE array of 2, 4, 6, 8 ,10 and insert them into a DWORD array via a LOOP to display them. This is my latest attempt.

INCLUDE Irvine32.inc

.data

Array1 BYTE 2,4,6,8,10
Array2 DWORD 5 dup(0)

.code
main PROC


 mov esi, OFFSET Array1  ;esi = byteArray
 mov edi, OFFSET Array2  ;edi = dwordArray
 mov ecx, 5              ;counter of loop


 DAWG:
     mov eax, [esi]   ;attempting to use movzx causes errors
     mov [edi], eax
     inc esi
     add edi, 4
     loop DAWG

Any suggestions? Trying to figure it out with my bit (pun intended) of assembly knowledge. Thanks for reading.

rkhb
  • 14,159
  • 7
  • 32
  • 60
caboose103
  • 33
  • 5

1 Answers1

3

1st solution as suggested by @rkhb is

DAWG:
 movzx eax, byte ptr [esi]
 mov   [edi], eax
 inc   esi
 add   edi, 4
 loop  DAWG

I would like to add this slightly more elegant solution:

 cld
 xor   eax, eax
DAWG:
 lodsb
 stosd
 loop  DAWG
Sep Roland
  • 33,889
  • 7
  • 43
  • 76