gcc, code16 and variadic functions
Andy Pont
andy.pont@sdcsystems.com
Thu Oct 8 14:43:00 GMT 2015
Hello,
I am currently working on some x86 code that starts in the murky arena of
16bit real mode code.
Using gcc v5.1.0 and as v2.24 I have managed to craft the start of the code
and it is executing as expected and I can jump from the initial assembler
code into C, call C functions, and get back again without any problems.
I am having one issue though, in that I can't get variadic functions to
work. I have implemented some custom functions to provide a custom printf
function: rmprintf(char *fmt, ...); which calls some inline assembler to
output the characters to the screen via a video BIOS interrupt.
All works well when just outputting strings: rmprintf("Hello World!\n"); but
it all goes awol when trying to use multiple parameters: rmprintf("Hello
%x\n", 0x1234);
The rmputhex(uint32_t val); function works correctly if I call it directly
so it appears that the rmprintf() function isn't able to process the
variadic arguments correctly.
Is this actually possible when writing 16bit code (-m16 -march=i386 command
line switches to gcc) and if so how do I make it work?
Thanks,
Andy.
More information about the Gcc-help
mailing list