i dont know why this program cannot output
+1
+2
+3
+4
the output is
+4214784
+1967600538
+2130567168
+1638356
i guess it is address, but why? how to correct it?
here is my code:
include irvine32.inc
.data
matrix dword 1, 2, 3, 4
.code
print proto, m:ptr dword
main proc
invoke print, addr matrix
exit
main endp
print proc, m:ptr dword
mov eax, m[0 * type m]
call writeint
mov eax, m[1 * type m]
call writeint
mov eax, m[2 * type m]
call writeint
mov eax, m[3 * type m]
call writeint
ret
print endp
end main
thanks for your answer <(__)>
mis a pointer passed on the stack. The assembler will turnminto something like[ebp+8]. Indexing will access items on the stack, starting from that position and that’s not what you want. You need to dereference thempointer which you can only do if you load it into a register.I do not recommend beginners use fancy features of their assembler without understanding what code gets generated exactly.