Forum > FPC development
[SOLVED]Do we will have a general calling convention for pascal?
TYDQ:
These times I am trying to booting my kernel with my UEFI boot loader.
However,I was upset about free pascal don't have cross-platform(not cross-processor,due to processors have different assembly calling convention) calling conventions.I was testing MWPascal,MS_abi_default,MS_abi_cdecl and read the compiled assembly code.As a result,I don't get the same calling convention which can be processor-specific and operating system independent.If there are general calling convention for pascal which is system-independent,It will be more convenient for pascal programmer to not to consider what the system abi will effect the program.
Laksen:
No. Because making more calling conventions is just going to create more problems
This was a thing popular in the past, but luckily long done. Even if some of the new calling convention standards are pretty terrible (looking at you riscv...)
Thaddy:
There is a work-around and, wait for it, it is cross-platform despite its name:
Use winapi as calling convention.
You can examine the compiler code on how this is achieved.
Using winapi as calling convention solves 90% of the problems.
And is cross-platform.
PascalDragon:
--- Quote from: TYDQ on August 11, 2024, 05:42:15 pm ---However,I was upset about free pascal don't have cross-platform(not cross-processor,due to processors have different assembly calling convention) calling conventions.I was testing MWPascal,MS_abi_default,MS_abi_cdecl and read the compiled assembly code.As a result,I don't get the same calling convention which can be processor-specific and operating system independent.If there are general calling convention for pascal which is system-independent,It will be more convenient for pascal programmer to not to consider what the system abi will effect the program.
--- End quote ---
Calling conventions are only really relevant on x86 (both i8086 and i386 and to a lesser extend x86_64). On all other architectures(*) there is only a single calling convention. If you don't need to interact with third party systems on i386 or i8086then simply stay with the default register calling convention, otherwise use the corresponding third party calling convention. For x86_64 the default depends on whether the system in question uses the Win64 calling convention (Windows itself and UEFI) or the Sys-V one (all Unix-like systems). And the differences here in assembly code can easily be accounted for with some compiler defines as does FPC's RTL.
(*) m68k also has a custom calling convention for FPC as that makes use of more registers than the default calling convention
TYDQ:
--- Quote from: PascalDragon on August 11, 2024, 08:19:50 pm ---
--- Quote from: TYDQ on August 11, 2024, 05:42:15 pm ---However,I was upset about free pascal don't have cross-platform(not cross-processor,due to processors have different assembly calling convention) calling conventions.I was testing MWPascal,MS_abi_default,MS_abi_cdecl and read the compiled assembly code.As a result,I don't get the same calling convention which can be processor-specific and operating system independent.If there are general calling convention for pascal which is system-independent,It will be more convenient for pascal programmer to not to consider what the system abi will effect the program.
--- End quote ---
Calling conventions are only really relevant on x86 (both i8086 and i386 and to a lesser extend x86_64). On all other architectures(*) there is only a single calling convention. If you don't need to interact with third party systems on i386 or i8086then simply stay with the default register calling convention, otherwise use the corresponding third party calling convention. For x86_64 the default depends on whether the system in question uses the Win64 calling convention (Windows itself and UEFI) or the Sys-V one (all Unix-like systems). And the differences here in assembly code can easily be accounted for with some compiler defines as does FPC's RTL.
(*) m68k also has a custom calling convention for FPC as that makes use of more registers than the default calling convention
--- End quote ---
So does calling convention winapi in x86_64 will be ignored if I try to force the code to winapi calling convention in x86_64?
Navigation
[0] Message Index
[#] Next page