Posted: Tue Feb 26, 2008 12:40 pm
here is the EXACT code, compiler under GCC in a windows environment and executed on an actual computer.
Code: Select all
asm("cli; jmp _main; hlt;"); // pseudo hop from bootloader
#include "../Libraries/system.h"
struct gdt_ptr
{
unsigned short limit;
unsigned int base;
} __attribute__((packed));
struct gdt_ptr *pGDT;
int main()
{
init_video(); // add basic video output suppor (printf)
pGDT = 0x500; // move entire struct to 0x500
pGDT->limit = 0x1234; // add dummy val to 0x500
pGDT->base = 0x5678; // add dummy val to 0x502
printf("%x | %x | %x \n", pGDT, &pGDT->limit, &pGDT->base); // produces 0x500,0x500,0x502
printf("%x | %x \n", pGDT->limit, pGDT->base); // produces 0x1234, 0x5678
for (;;); // neverending loop
return 0; // if something fails in the loop for some strange reason, return nil.
}