Page 2 of 2

Posted: Tue Feb 26, 2008 12:40 pm
by 01000101
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. 
}

Posted: Wed Feb 27, 2008 1:32 am
by Solar
JamesM wrote:Solar:

The code is changing a GDT. What makes you think it is designed to be run in a hosted environment?
I admit confusing 01000101 with the OP. I guess Alzheimer is getting worse faster than I thought.