News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Question about calling conventions and parameters passing

Started by enzechen, November 16, 2016, 10:33:30 PM

Previous topic - Next topic

enzechen

Currently, I am confused of the calling convention and parameters passing in win64:

According to MSDN (https://msdn.microsoft.com/en-us/library/zthk2dkh.aspx), win64 calling convention is to pass first 4 integer parameters into RCX, RDX, R8, and R9, first 4 floating point into XMM0 ~ XMM3. Others are needed to pushed onto stack.

How does ML64 handle this calling convention by using INVOKE? Does INVOKE macro passes parameters using above conventions? or it's the same as win32 to push all parameters onto stack? How about shadow stack?

If I only use pure assembly without macro, how shall I handle this by using CALL?

Thanks a lot.

hutch--

ML64 does not have a native "invoke" directive. It has been implemented as a macro in conjunction with a prologue/epilogue pair of macros as ML64 comes unconfigured. Look in the subforum above for ML64 code that works with "invoke" in the normal MASM manner. Note that the project for 64 bit MASM is not complete and is still under development but you can get it going and produce 64 bit binaries with it.

LATER: Have a look at the two HTML files attached to this post. They explain how the win64 calling convention works in assembler code and how the invoke macro works. You can code this stuff manually but the stack addressing is very complex and unless you properly align the stack the app simply will not start. I would suggest that you use the supplied prologue / epilogue as it get all of this correct. You can manually write no stack frame procedures when the arg count to the procedure is 4 or less. Also note that you generally do not use PUSH / POP to preserve registers, you write them to local variables as the preferred way to write win64 procedures.