moving 8bit integers array to 32bit array assembly

I'm stuck on how you're supposed to take the decimal integers from an 8-bit BYTE array and somehow manage to move them into a 32-bit DWORD array within a loop. I know it has to do something with OFFSET and Movezx, but it's a little confusing to understand. Are there any helpful tips for a newbie to understand it? EDIT: For example:

    Array1 Byte 2, 4, 6, 8, 10
    mov esi, OFFSET Array1
    mov ecx, 5
    mov al, [esi]
    movzx eax, al
    inc esi
    Loop L1

Is this the right approach? Or am I doing it entirely wrong? It's Assembly x86. (Using Visual Studios)


Your code is almost right. You managed to get the values from the byte array and to convert them to dword. Now you only have to put them in the dword array (which is even not defined in your program).

Anyway, here it is (FASM syntax):

; data definitions
Array1 db 2, 4, 6, 8, 10
Array2 rd 5              ; reserve 5 dwords for the second array.

; the code
    mov esi, Array1
    mov edi, Array2
    mov ecx, 5

    movzx eax, byte [esi]  ; this instruction assumes the numbers are unsigned.
                           ; if the byte array contains signed numbers use 
                           ; "movsx"

    mov   [edi], eax       ; store to the dword array

    inc   esi
    add   edi, 4     ; <-- notice, the next cell is 4 bytes ahead!

    loop  copy_loop  ; the human-friendly labels will not affect the
                     ; speed of the program.

Need Your Help

what will happen if service already fetch the job from the queue and then blow up

c# .net rabbitmq nservicebus

I'm new to this, please help me. I want to design a system with a web site and a service. The website accept user's request and put job into a queue. The service get job from queue and process it. ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.