flat assembler
Message board for the users of flat assembler.
Index
> Main > Parameters passing, calling convention |
Author |
|
Matrix 12 Nov 2004, 19:00
i couldn't keep a standard, as some functions are faster if using other registers.
you can only make a standard if you're using stack procedures (stdcall) but it won't be fast, so decide what whould you like : fast, or uniform. |
|||
12 Nov 2004, 19:00 |
|
Juras 12 Nov 2004, 22:17
well, there are some register-based parameter-passing techniques:
- FREE PASCAL's 2.0 - Open Watcom's Probably, I'll choose one of them. |
|||
12 Nov 2004, 22:17 |
|
Frank 13 Nov 2004, 22:47
I am writing for Win32 where API calls may destroy the contents of EAX, ECX, EDX, and the flags, but will preserve the contents of EBX, EDI, ESI, EBP, and ESP. It appeared most useful (i.e., least prone to bugs) to have the same subsets of registers destroyed (EAX, EDX, ECX, flags) versus preserved (all others) when calling API-functions as when calling my own functions. So I use the following convention:
First function parameter in EAX, second parameter in EDX, third parameter in ECX, any remaining parameters on the stack (theoretically at least -- I don't recall having any function that requires more than three parameters). Return values: first value in EAX, second one in EDX, third value in ECX. That's probably similar to Delphi's FASTCALL convention, but I'm not sure about the details. As an important aid against bugs, there are two different keywords for API-calls versus calls of my own functions (INVOKE vs. FCALL), so that the macro system alerts me during compilation if I mix them up. Other stuff: Callee (not caller) clears the stack (again, just because API-functions do it so); no stack frame by default (to keep EBP free for the function); avoid RET after CALL (JMP instead -- when passing parameters in registers, that is possible much more often than when passing parameters on the stack). No rule yet for using the coprocessor across calls of my own functions. |
|||
13 Nov 2004, 22:47 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.