In the first example you had misspelt point
as Point
, so it didn't assemble (unless you told the assembler to ignore case).
If we ignore that, what you're doing here:
main:
push ebp
mov ebp,esp
PP point 0, 0 ;Crashes here..
mov esp, ebp
pop ebp
mov eax, 0x0
is pretty much the same as if you had written:
main:
push ebp
mov ebp,esp
dw 0,0
mov esp, ebp
pop ebp
mov eax, 0x0
It just inserts those two 0-words into the instruction "stream" where you put them. If you assemble this and then disassemble the output you get:
00000000 6655 push ebp
00000002 6689E5 mov ebp,esp
00000005 0000 add [bx+si],al ; <- the first 0
00000007 0000 add [bx+si],al ; <- the second 0
00000009 6689EC mov esp,ebp
0000000C 665D pop ebp
0000000E 66B800000000 mov eax,0x0
00000014 C3 ret
Your pp
variable would have to be declared somewhere else so that it never ends up in the code path (i.e. eip / rip
shouldn't reach your variable).
If you really need a stack-allocated point
you could use virtual at
:
virtual at esp-0x10 ; use whatever address is appropriate in your case
pp point 1,2
end virtual
mov ax,[pp.X]
Note that this neither allocates space for nor initializes a point
; it just sets up the name-address mapping.