Frustration over gcc/as combination
Posted: Sun Dec 02, 2007 1:57 pm
I'm attempting to remove all inline assembly from my C code so that I can port it to another compiler easily. The goal is to have a couple assembly files that perform all the compiler/hardware specific work there, so that I can port over to another arch easily.
In setting up my IDT, I'm trying to export a symbol from assembly, and use it in C. So, I define the IDT:
and then use it in C:
To my complete annoyance, this does not work. The assembly code generated is something to the affect of
versus
Now, this cost me a whole afternoon of debugging time in bochs, trying to figure out why my interrupt table was not setup. The fix was to do this in C:
I've been trying to find some documentation on how to get around this. I guess I could define the idt in the C code, but I was rather hoping to keep it in the assembly for fine grained and compiler independent control.
Am I doing something wrong in the assembly section? I'm used to inline assembly in C, but not so much dealing with mixed C and .S files... Might be on the wiki, but I failed to get the right keyword magic to pull it up.
In setting up my IDT, I'm trying to export a symbol from assembly, and use it in C. So, I define the IDT:
Code: Select all
.global idt
idt:
.fill 512, 4, 0x0000
Code: Select all
extern unsigned int* idt;
...
idt[(vec * 2) + 0] = word1;
idt[(vec * 2) + 1] = word2;
Code: Select all
mov idt, %edx
Code: Select all
mov $idt, %edx
Code: Select all
extern unsigned int idt;
unsigned int* idt_ptr = &idt;
....
Am I doing something wrong in the assembly section? I'm used to inline assembly in C, but not so much dealing with mixed C and .S files... Might be on the wiki, but I failed to get the right keyword magic to pull it up.