I am trying to iterate through a 10 element SDWORD array in a procedure. I believe the array has all the expected values, because when I display them in main, it is how it should be. When I pass the address of the array to a procedure, the first element works, but every subsequent element is 0. I've tried every variation I can think of, and the debugger shows the correct values. I just can't understand where the problem is.
When I iterate through the array in main, using the below, it displays correctly.
mov ecx, 10
_displayTemp:
mov ebx, ecx
sub ebx, 10
mov eax, numArray[ebx * TYPE finalNumber]
call WriteInt
call CrLf
loop _displayTemp
If I do this, I get all 0s:
push OFFSET numArray
call bobBilby
bobBilby PROC
push ebp
mov ebp, esp
mov esi, [ebp + 8]
mov eax, [esi + 4]
call WriteInt
call CrLf
mov eax, [esi + 8]
call WriteInt
call CrLf
mov eax, [esi + 12]
call WriteInt
call CrLf
ret 4
bobBilby ENDP
I've tested the same code with an array I manually input the data into, and it works.
If it matters, the code to call the filling procedure is this. I used the first code above to test it, and it appears to have all the values.
mov ecx, 10
_fillArray:
mov ebx, ecx
sub ebx, 10
<lots of push OFFSETs>
call ReadVal
mov eax, finalNumber
mov numArray[ebx * TYPE finalNumber], eax
loop _fillArray
I am losing it here, so any help would be awesome. Thank you.