Closed ecm-pushbx closed 4 years ago
Hello @ecm-pushbx,
The default calling convention, if you do not specify any options, is cdecl
--- sorry I did not make that clear.
However, if you use a -mrtd
or -mregparmcall
option during both compilation and linking, you can effectively switch your whole program to a different calling convention. I have actually arranged to build different versions of the C library and libgcc
for the different calling conventions (cdecl
, stdcall
, and regparmcall
).
Thank you!
My question is which registers are call-preserved and which are call-clobbered. This does not seem to be documented anywhere.
Hello @ecm-pushbx,
OK... yes, unfortunately gcc-ia16
does not yet have a spiffy ABI document. But in brief:
%ax
, %cx
, %dx
, and %bx
are call-clobbered. Even for the regparmcall
calling convention.%ds
is a bit special --- it is assumed to be the same as %ss
, and must be restored on exit. A function can mess with %ds
without really saving it, but if so, it should do a pushw %ss; popw %ds
just before returning.%bp
, %si
, %di
, and (!) %es
.I will try to find a place in the info file to stash this information.
Thank you!
Ok, thanks! I suggest you should close this issue once you have things documented somewhere.
Thanks @ecm-pushbx!
I only found the "Submodel Options" → "IA-16 Options" in the gcc.info file and that links to "Function Attributes" → "IA-16 Function Attributes". This lists the
cdecl
,stdcall
, andregparmcall
attributes, but it does not fully describe the ABI.I want to convert some old programs to using NASM-assembled subfunctions instead of inline assembly. For that I want to know the exact ABI. Here's an example of what I am currently playing with: