This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
gcc, code16 and variadic functions
- From: "Andy Pont" <andy dot pont at sdcsystems dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 8 Oct 2015 15:43:22 +0100
- Subject: gcc, code16 and variadic functions
- Authentication-results: sourceware.org; auth=none
- Reply-to: <andy dot pont at sdcsystems dot com>
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.