gcc optimization
Posted: Thu Jul 30, 2009 9:21 pm
void setGDTR(char *gdt, unsigned short numberOfGDTDescriptor) {
char gdtr[6];
memset(gdtr, 0, 6);
if (numberOfGDTDescriptor < 8192) {
if (numberOfGDTDescriptor == 0) {
*(unsigned short *)gdtr = (unsigned short) 0; //gdtr's limit is 8N-1
} else {
*(unsigned short *)gdtr = (unsigned short) (8 * numberOfGDTDescriptor)
- 1; //gdtr's limit is 8N-1
}
*(unsigned int *) (gdtr + 2) = gdt;
__asm__ __volatile__("lgdt (%%eax)"::"a"(gdtr));
}
}
GCC thinks I haven't used the gdtr variable, so all the line with gdtr will be be compiled into instruction code. May I know how to fix it?
thanks
from Peter ([email protected])
char gdtr[6];
memset(gdtr, 0, 6);
if (numberOfGDTDescriptor < 8192) {
if (numberOfGDTDescriptor == 0) {
*(unsigned short *)gdtr = (unsigned short) 0; //gdtr's limit is 8N-1
} else {
*(unsigned short *)gdtr = (unsigned short) (8 * numberOfGDTDescriptor)
- 1; //gdtr's limit is 8N-1
}
*(unsigned int *) (gdtr + 2) = gdt;
__asm__ __volatile__("lgdt (%%eax)"::"a"(gdtr));
}
}
GCC thinks I haven't used the gdtr variable, so all the line with gdtr will be be compiled into instruction code. May I know how to fix it?
thanks
from Peter ([email protected])