flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > An executable with mixed calling convention |
Author |
|
JohnFound 01 Mar 2012, 21:11
Hm, what is the problem with the mixed calling convention? I use it all the time, because of different reasons.
|
|||
01 Mar 2012, 21:11 |
|
Pinczakko 01 Mar 2012, 21:49
Actually, not a problem. But, I want to know whether 16-bit compiler(s) could emit code with different calling conventions? I have very little exposure to 16 compilers like Watcom C/C++ or Open Watcom.
_________________ Human knowledge belongs to the world |
|||
01 Mar 2012, 21:49 |
|
JohnFound 01 Mar 2012, 22:01
I don't know about C/C++. The code written by me on 16 bit computers was in Turbo Pascal and TASM assembler.
IIRC, both supports different calling conventions. |
|||
01 Mar 2012, 22:01 |
|
LocoDelAssembly 01 Mar 2012, 22:41
Pinczakko wrote: Actually, not a problem. But, I want to know whether 16-bit compiler(s) could emit code with different calling conventions? I have very little exposure to 16 compilers like Watcom C/C++ or Open Watcom. 1. The programmer(s) explicitly specified the calling convention for each function (or some of them and the rest established by the compiler by default) 2. The stdcall (not cdelc??) functions are not marked static and therefore the compiler's optimization engine felt free to change the calling convention to an optimal one for the functions that could result beneficial (sure it was exactly fascall and not really a free register-based convention?) 3. Besides using the same logic as in to 2., also some non-static functions were internally duplicated by the compiler to be able to change the convention (this is an available option in cases where the callee and caller are in the same source file) If the compiler was capable of doing 3 or 2, then in the disassembly you may be missing some functions because they end up inlined even if the programmer(s) didn't specify inline explicitly. |
|||
01 Mar 2012, 22:41 |
|
Pinczakko 03 Mar 2012, 18:06
hi,
about 1: Perhaps some of the code I observed are mixed assembly+C. The thing is bx register is sometimes used to pass parameters while in most cases, the parameters are passed via stack. Or is it possible that these "outlier" functions are coded to use __fastcall?? about 2: I can say I'm 90% sure it's stdcall calling convention because mostly the callee cleans-up the stack. about 3: I see. I have never used such feature so I didn't know it previously. Well, thanks for pointing out . _________________ Human knowledge belongs to the world |
|||
03 Mar 2012, 18:06 |
|
Enko 05 Mar 2012, 13:35
Borland C++ Compiler used __fastcall for the VCL(visual component library). Because of the VCL was writen in Delphi Pascal.
So this way, VCL function like TButton1::Clik was __fastcall while the procedure you writen where cdecl. And then, if you called some winapi function, it would be defined as extern stdcall. |
|||
05 Mar 2012, 13:35 |
|
Pinczakko 05 Mar 2012, 15:07
Thanks Enko. That's insightful
_________________ Human knowledge belongs to the world |
|||
05 Mar 2012, 15:07 |
|
MarcoV 01 May 2022, 13:27
(I'm necroing here, but I came here by chance via google).
Some 16-bit compilers like Topspeed's 3.x line (having a C/C++, Pascal and Modula2 compiler) could handle custom calling conventions. So you could specify per function if first parameter should go into ax, second into bx, third on the stack and fourth in dx etc. That is mainly made to optimize (e.g. with an interface to the out port instruction as prime example) or 3rd party libraries with atypical calling conventions. |
|||
01 May 2022, 13:27 |
|
Furs 01 May 2022, 16:58
Sounds cool, I wish GCC had something like that builtin without requiring some plugin extension.
|
|||
01 May 2022, 16:58 |
|
revolution 01 May 2022, 22:25
Furs wrote: Sounds cool, I wish GCC had something like that builtin without requiring some plugin extension. What is AX on ARM/MIPS? |
|||
01 May 2022, 22:25 |
|
Furs 02 May 2022, 12:29
They could just ignore it on another platform; it already has inline asm and that won't even compile in such case. I know what you mean but yeah they're just dumb.
|
|||
02 May 2022, 12:29 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.