(Assembly) Exception thrown error? (with STOSD instruction)

-1

I'm writing a procedure that fills an (2d) array with random integers. The array address is to be passed through a stack to the fillArray procedure.

For some reason, when I run the code, I get an exception thrown error: "Exception thrown at 0x00403687 in Project.exe: 0xC0000005: Access violation writing location 0x004036A7." I can't figure out exactly what's causing this. I'm guessing it has something to do with the way I'm passing the array address, since the error message disappears once I comment out "mov edi, [ebp+8]", but I can't figure out how it's wrong.

fillArray PROC arrAdd
    mov ebx, 0
    push ebp
    mov ebp, esp
    push eax
    mov ecx, (ROWS*COLS)
    mov edi, [ebp+8]
    cld
    fill:
        call Randomize
        mov eax, MAX + 1
        call RandomRange
        add eax, 10
        STOSD
        mov ax, numArray[ebx]
        inc ebx
        call writeInt
    loop fill
    pop eax
    pop ebp
    ret
fillArray endP

main PROC
push OFFSET numArray
call fillArray
assembly
x86
masm
irvine32
asked on Stack Overflow Dec 6, 2018 by newbieProgrammer • edited Dec 6, 2018 by Michael Petch

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0