Inline ASM problem
Posted: Thu Aug 26, 2004 11:39 pm
I've been converting most of my early (N)ASM code into C wherever possible and have a problem in the code reloading the IDTR, my knowledge of inline ASM is fairly limited (sucks actually ). Anyway heres the C code I wrote
I also tried replacing the asm statement with a pointer as in
which also gives an error. The code compiles fine, but LD says "undefined reference to $IDTR" in both cases.
An 'objdump' of the idt object file gives this
I dont really know why the "p" is used in the output constraint. I tried using "m" and got the code linked but it tripple faults the CPU when an INT is generated after reloading the IDTR.
Can anybody tell me what is wrong here? I've been sitting all night with this thing.
Code: Select all
IDTR_s IDTR;
void reloadIDTR()
{
IDTR.limit= 256*(sizeof(IDT_s))-1;
IDTR.base= IDT_entry; // array of IDT_s entries
__asm__ __volatile__ ("LIDT (%0)": :"p"(&IDTR));
}
Code: Select all
IDTR_s *idtrptr= &IDTR;
__asm__ __volatile__ ("LIDT (%0)": :"p"(idtrptr));
An 'objdump' of the idt object file gives this
Code: Select all
000000f0 <reloadIDTR>:
f0: 55 push %ebp
f1: 89 e5 mov %esp,%ebp
f3: 83 ec 0c sub $0xc,%esp
f6: 66 c7 05 10 00 00 00 movw $0x7ff,0x10
fd: ff 07
ff: c7 05 12 00 00 00 00 movl $0x800,0x12
106: 08 00 00
109: 0f 01 1d 00 00 00 00 lidtl 0x0
110: 68 00 08 00 00 push $0x800
115: 68 ff 07 00 00 push $0x7ff
11a: 68 40 00 00 00 push $0x40
11f: e8 dc fe ff ff call 0 <loadInt>
124: 89 ec mov %ebp,%esp
126: 5d pop %ebp
127: c3 ret
128: 90 nop
Can anybody tell me what is wrong here? I've been sitting all night with this thing.