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])
gcc optimization
Re: gcc optimization
this may give GCC the hint:
Code: Select all
*(volatile unsigned short *)gdtr =
Website: https://joscor.com
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: gcc optimization
Yup. 01000101 beat me to it. Whenever GCC engages in folly, I just volatile that ho (Ohhhh).
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: gcc optimization
thanks gentlemen