In the same way asOwen wrote:OK, but how do you mangle a name provided without parameters?
Code: Select all
void foo(void);
I can. Name-mangling enforce that caller (in module A) and the callee (in module B) use the exactly identical function declaration. If it is not true than the linker can not link this modules together and the user see an error-message.Owen wrote:You can't even mangle at the call site because there may be subtle mismatches (Int vs short vs char, etc) which will make it mangle incorrectly.
I do not know this, i thing this details are below the C standard.Owen wrote:Does the C standard even permit name mangling?
I can not see any problem. Okay i am losing some rarely and old libraries (or i have the work for updating the header files) but the very most C code use correct function declarations.Owen wrote:And do you really want to implement some non-standard variant of C?
ACK!Combuster wrote:So the idiot who gets a linker error over a K&R function IMO deserves that title.
I will use the following function header and footer (attention: my stack grows upwards)Combuster wrote:I'm a bit late with explaining the register distribution argument of last week
Code: Select all
void foo(long a, long b, _____ , int u, int v); //assuming that u and v must be passed at the stack
{
//u is at [R62 - 4] and v at [R62 - 8]
PUSH.W R61 //save the link-register
PUSHM.W R48,8 //save the registers R48 ... R55 (callee-save area)
ADD.W R62,100 //allocate 100 Bytes stack-frame
//u is at [R62 - 140] and v at [R62 - 144] ; the stack-frame is at [R62 - 100] .... [R62 - 1]
/* function code */
SUB.W R62,100 //free 100 Bytes stack-frame
POPM.W R48,8 //restore the registers R48 ... R55 (callee-save area)
POP.W R63 //restore the link-register direct into the instruction-pointer and do the RET
}
I will create, extra for the function header and footer, 2 additional instructions ENTER and LEAVE that do this two jobs each in one instruction.
Greetings
Erik