NMI Support Patch 8:

[NTOS]: Implement a GNU Assembler version of the Windows SDK ASM calling convention macros. Only stdCall and its helpers have been written -- feel free to write the rest. Based on callconv.inc from Microsoft). SUGGESTION: Slowly start rewriting current code to use calling convention macros as it is much cleaner.


svn path=/trunk/; revision=44868
This commit is contained in:
ReactOS Portable Systems Group 2010-01-02 01:28:36 +00:00
parent e40621ab44
commit 0396096bd1

View file

@ -0,0 +1,100 @@
/*
* PROJECT: ReactOS Source Development Kit (SDK)
* LICENSE: BSD - See COPYING.ARM in the top level directory
* FILE: include/ddk/api/callconv.s
* PURPOSE: x86 Calling Convention Helpers
* PROGRAMMERS: ReactOS Portable Systems Group
*/
/* INCLUDES *******************************************************************/
//
// @name CountArg
//
// This macro counts the number of arguments in the ArgList and returns
// the value in cCount.
//
// @param cCount - Count of arguments
// @param ArgList - Argument list
//
// @remark None.
//
.macro CountArg cCount:req,ArgList:vararg
cCount = 0
.irp arg, \ArgList
cCount = cCount+1
.endr
.endm
//
// @name RevPush
//
// This macro pushes the arguments in ArgList in the reverse order
// and returns the number of arguments in cCount
//
// @param cCount - Count of arguments
// @param ArgList - Argument list
//
// @remark None.
//
.macro RevPush cCount:req,ArgList:vararg
LOCAL index, x
CountArg cCount, ArgList
index = cCount
.rept cCount
x = 0
.irp arg,ArgList
x=x+1
.ifeq index-x
push arg
.exitm
.endif
.endr
index = index-1
.endr
.endm
//
// @name stdCallCall
//
// This macro performs a function call using the STDCALL convention and applies
// the correct name decoration required based on the stack bytes
//
// @param Func - Function name
// @param N - Number of stack bytes for arguments
//
// @remark None.
//
.macro stdCallCall Func:req,N:req
.ifdef __imp_&Func&@&N
call dword ptr [__imp_&Func&@&N]
.else
call Func&@&N
.endif
.endm
//
// @name stdCall
//
// This macro pushes the arguments required for a function call using the
// STDCALL convention and then issues the call
//
// @param Func - Function name
// @param ArgList - Argument list
//
// @remark None.
//
.macro stdCall Func:req,ArgList:vararg
LOCAL Bytes
RevPush Bytes,ArgList
Bytes = Bytes*4
stdCallCall Func, %(Bytes)
.endm