Hello! Anyone could help me with this problem? I'm trying to pass an integer array to a stack, but i don't know how to. Thanks.
Posted on 2006-11-17 13:33:54 by ammfj
Well, usually you would obtain the address of the array through 'LEA' then pass that as a dword parameter on the stack.


start PROC
LOCAL iArray[256]:DWORD ; 256 integers

    ; fill the array
    mov ECX, 256
    lea EDI, iArray
@@:
    mov , ECX
    dec ECX
    test ECX, ECX
    jnz @B

    ; Call Proc1 with address of iArray as parameter
    lea EAX, iArray
    push EAX
    call Proc1

    ; Exit
    push 0
    call ExitProcess
ENDP

Proc1 PROC lpiArray:DWORD
    ; Lets do something with the array
    mov ECX, 256
    mov EDI, lpiArray
@@:
    mov EAX,
    add EAX, ECX
    mov , EAX
    dec ECX
    test ECX, ECX
    jnz @B
    ret
ENDP
Posted on 2006-11-17 14:02:34 by Synfire
Also be sure to remember, that the maximum addressable array index is always n-1. For "256 DWORDS", that would mean indexing 0 through 255.
Posted on 2006-11-17 17:05:10 by SpooK
This forum is really helping me to develop my knowledges in assembly language. Thanks to all forum creators  :D
Posted on 2006-11-18 04:36:11 by ammfj