<<< M09_prototype.asm | Index | Portability Concerns >>> |
The EXTERN MASM directive,
EXTERN _Beep@8:NEAR
defines a program symbol _Beep@8 with a NEAR type, which is needed by the assembler to generate the appropriate CALL instruction.
The linker gets the kernel32.lib object library on command line from the list of Additional Dependencies provided by the project settings.
The library provides the actual binary definition of the Beep system function.
Almost all Windows system functions use __stdcall calling convention . The system function removes its own arguments from the stack.
The __stdcall convention also requires a
function name prefixed by _underscore, and
appended function name suffix @, followed by the decimal number of bytes in the argument list. For example,
EXTERN _Beep@8:NEAR ; Function uses two DWORD arguments EXTERN _GetLastError@0:NEAR ; Function has no arguments .. call _Beep@8 call _GetLastError@0
Under __stdcall convention, function arguments are passed on the stack in right to left order. Download cjumpcxx.exe program, and click
Functions -> Stack Frames
to view animation of the function call.
<<< M09_prototype.asm | Index | Portability Concerns >>> |