Hi AlexN,
There is a problem concerning the RET instruction. An other example :
.386
.model flat, stdcall
option casemap :none
.code
main PROC x:DWORD,y:DWORD
.if eax == 0
xor ecx,ecx
ret
.endif
ret
main ENDP
start:
invoke main,10,20
ret
END start
Output of Masm :
_text SEGMENT DWORD PUBLIC 'CODE'
_main@8 PROC NEAR
push ebp
mov ebp, esp
or eax, eax
jnz ?_001
xor ecx, ecx
leave
ret 8
?_001: leave
ret 8
_main@8 ENDP
_start PROC NEAR
push 20
push 10
call _main@8
ret
_start ENDP
_text ENDS
Output of Poasm :
_text SEGMENT PARA PUBLIC 'CODE'
_main@8 PROC NEAR
push ebp
mov ebp, esp
test eax, eax
jnz _start
xor ecx, ecx
leave
ret 8
_main@8 ENDP
_start PROC NEAR
push 20
push 10
call _main@8
ret
_start ENDP
_text ENDS
Poasm should not direct the code execution to the _start label. The stack remains unbalanced after this jump.
jnz _start