Calling conventions
- From: "James Daughtry" <mordock32@xxxxxxxxxxx>
- Date: 31 Mar 2006 13:03:00 -0800
The Windows API uses the stdcall convention where the called procedure
is responsible for cleaning up the stack. In NASM I would use a macro
(one of the few places where I would) like so:
%macro scall 2-*
%define _func %1
%rep %0 - 1
%rotate -1
push %1
%endrep
call _func
%endmacro
In RosAsm, I would end up using this:
[push | push #1 | #+1]
[call | push #L>2 | call #1]
Now for the problem. I believe that the functions supported by
msvcrt.dll use the cdecl calling convention instead of the stdcall
calling convention where the caller is repsonsible for cleaning up the
stack. In RosAsm, I'm not entirely sure how much damage I'm doing
because this:
call 'msvcrt.printf',fmt
works just as well as this:
call 'msvcrt.printf',fmt | add esp,4
In NASM, I would use a different macro to handle the cdecl calling
convention such that it adds the right amount to esp to clean up the
stack after the call:
%macro scall 2-*
%define _func %1
%assign __params %0 - 1
%assign __params __params * 4
%rep %0 - 1
%rotate -1
push %1
%endrep
call _func
add esp,__params
%endmacro
In RosAsm, I haven't yet figured out how to get a macro to do that. My
question is this: Am I trashing the stack by using an stdcall calling
convention when a cdecl calling convention is expected by the functions
I'm calling?
.
- Prev by Date: Re: SpooK, its put up or shut up time.
- Previous by thread: The rats nets show
- Index(es):
Relevant Pages
|