News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Prefixes for external procedures

Started by bf2, September 28, 2011, 04:50:22 PM

Previous topic - Next topic

bf2

Why does MASM have to add a suffix to external procedure name? Suppose I am using a plain CALL-RET mechanism instead of INVOKE and my procedure MyProc takes a single double word parameter. Why would MASM change the procedure name to MyProc@4 so my code becomes something like below?
EXTERN MyProc@4:NEAR
. . .
PUSH 45
CALL MyProc@4

I know that the suffix denotes the number of bytes on the stack for parameters, but why does MASM need to change the procedure name to store that information?

dedndave

i am guessing it is because the linker has no other mechanism for passing that info
it's an external definition of some sort - code, of course - but the OBJ file would not know about parameters

ToutEnMasm


It is a decorate name made by the linker
a stdcall  have  the @N at he end.
the C call had NOthing at the end.
?....    syscall
.....

bf2

But why would even the linker need to store the number of bytes in the procedure name? Any address calculation for local variables on the stack has already been done by the assembler. What does the linker gain by changing the procedure name?

Vortex

Hi bf2,

MS link is mainly designed to be used with the Visual C++ compiler. The name decoration or mangling ( for example _MessageBoxA@16 ) is addressing to some specific C++ features like function overloading.

baltoro

Baltoro

Vortex

Agner Fog's document explains name mangling :

Quote5. Calling conventions for different C++ compilers and operating systems
This document contains details about data representation, function calling conventions, register usage conventions, name mangling schemes, etc. for many different C++ compilers and operating systems.

http://agner.org/optimize/calling_conventions.pdf

http://agner.org/optimize

bf2