flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
caoyunbin001 27 Jan 2012, 07:38
I'm a Chinese so forgive me about my poor English.
I'm running fasmw16935 on Microsoft Windows [版本 6.1.7601]. Here, I'll make it simple: when assemble this: ;============================= include "win64ax.inc" .data szContent db "lalala",0 .code start: push 0 push 0 ; times 8 push 0 mov rcx,0 mov rdx,szContent mov r8,0 mov r9,0 call [MessageBox] invoke ExitProcess,0 .end start ;============================= runs correctly,and MessageBox is shown. but when assemble this: ;============================= include "win64ax.inc" .data szContent db "lalala",0 .code start: push 0 ; push 0 ; times 8 push 0 mov rcx,0 mov rdx,szContent mov r8,0 mov r9,0 call [MessageBox] invoke ExitProcess,0 .end start ;============================= I just removed one "push" at the beginning of my program, it crashed without even a ErrorReport ! Just vanished! Like you didn't ever run it , nothing happens, no error, no MessageBox, no nothing! I debugged it, using FDBG, the only runtime-debug tool I can found, but it's a little hard to use ...
|
|||||||||||||||||||||||||||||
![]() |
|
sinsi 27 Jan 2012, 09:03
Shouldn't one push align it? When Windows calls your entry is misaligns by 8 (return address). I think more likely you are not allocating stack space for 'spill', 4 slots on the stack for rcx/rdx/r8/r9 parameters
|
|||
![]() |
|
caoyunbin001 27 Jan 2012, 10:16
yeah, I figured it out later,
I know that it should be aligned, but a got mislead by the debugger: it tells me that it's a ACCESS_VIOLATION fault, somehow not DATA_ALIGNMENT fault, maybe windows was unable to tell the #AC fault? there is a solution I found later: at the beginning : invoke SetErrorMode,0x0004 (will ignore #AC fault) |
|||
![]() |
|
sinsi 27 Jan 2012, 10:48
Look at the macro .code in win64ax.inc, this aligns the stack for you.
So one push misaligns it again. I would suggest that if you use the include file you should fully use it - invoke instead of mov/mov/call. |
|||
![]() |
|
caoyunbin001 27 Jan 2012, 10:57
yeah, I just use:
.code proc start invoke MessageBox,0,"ccc","ttt",0 endp .end start it wont work ,but it will work on win32, so I simplified the problem to the push problems, i.e., when using push ebp, the stack misaligned. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.