September 2017
Beginner to intermediate
290 pages
6h 58m
English
The cdecl calling convention is the standard convention in C and C++ high-level languages. Parameters are stored on a stack with the rightmost parameter pushed onto stack first and the leftmost parameter pushed onto stack last. It is the caller's responsibility to restore the stack once it regains control.
The simplest macro that emulates the cdecl procedure invocation would be as follows:
macro ccall procName, [args]{ common a = 0 if ~args eq forward a = a + 4 reverse push args end if common call procName if a > 0 add esp, a end if}
The if clauses here are self-explanatory; however, you may simply ignore them for now as they will be covered a bit later in this chapter.
Read now
Unlock full access