[cfe-users] Calling convention FAR PASCAL when using -m16

Fabian Maurer via cfe-users cfe-users at lists.llvm.org
Mon Apr 13 16:17:56 PDT 2020


Hello,

I'm currently hacking on a small linker for 16Bit NE executables.

My current main issue is that clang doesn't seem to support the 16Bit calling
convention 'pascal' properly.

Consider the following code sample:
########
static void __pascal test2(short s1, short s2, short s3, short s4)
{
}

test2(1, 2, 3, 4);
########

That compiles to
########
mov    DWORD PTR [esp],0x1
mov    DWORD PTR [esp+0x4],0x2
mov    DWORD PTR [esp+0x8],0x3
mov    DWORD PTR [esp+0xc],0x4
mov    DWORD PTR [esp+0x10],eax
call   120 <test2>
########

AFAIK __pascal should push the arguments in the other order, and not as 4
bytes each. OpenWatcom, that generates real 16Bit code, pushes only 2 byte
each.

Is there away to get fake 16Bit code generated that follows that calling
convention so interfacing with real 16Bit code is possible?

Regards,
Fabian Maurer




More information about the cfe-users mailing list