force specific calling convention on C

Hi guys, I am developing bootloader and met with a need to force C compiler to output the calling function in a specific way.

Due to program requirement, I am passing function parameter to function called ProcName function from code segment like following:
I am also declaring all functions far.

jmp skipData
param1 db 00h, 001h

push cs
push offset word ptr cs:param1 ; pushed seg:ofs address of param1
push cs
push offset word ptr cs:retAddr ; pushed return address.
dw eah
dw ProcName
dw CS_SEG ; far jump to CS_SEG:ProcName



Now the problem is I declare ProcName in C file and calling ProcName function from C like following way:

extern void far ProcName(char far *);

Problem is it is not working because, C compiler compiles it as follows:
push ds
push offset word ptr ds:paramInC

because string '12345' is created in data segment. But upon program entry I am using ds for something else not for DATA segment.

Finally the question is is there way to force C compiler to create 12345 string in code segment and pass CS and OFFSET CS:12345 to ProcName. Thanks!


  • By default, unless you specify the convention, the compiler will probably default to __cdecl?

    [code]extern void far ProcName(char far *);
    is probably defaulting to

    [code]extern void __cdecl far ProcName(char far *);

    I think you might be wanting to do this if your compiler supports it.

    Naked function calls
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion