Page 1 of 1

Problem with loading CS

Posted: Sun Apr 06, 2003 11:00 pm
by CETian
    I've loaded my kernel from GRUB and loaded my own GDT with all segments with base 0x40100000 so that the kernel linked at 3 GB mark will be loaded correctly. After that i tried to load the GDT with base of all entries set to   0, the CS register doesn't seem to be loaded correctly.
     after the following instruction
       *   jmp 0x08:$+7-0xc0000000+0x100000   ;0x08 is the selector for a GDT entry with base 0...seccefssfully got into next instruction
       *   mov ax,0x10   ;0x10 is selector for GTD for data segment
       *   mov *,ax      ;load all segment registers

       the following codes did work
       1.   mov [ds:0xb8000],'A'    ;printed successfully
       2.   jmp $     ;got into infinite loop...I don't know how because kernel is linked to 0xc0000000 and loaded at 0x100000 hence $ is 0xc000??? and segment base is 0

      also
            jmp 0x08:$-0xc0000000+0x100000   ;works
            jmp $-0xc0000000+0x100000        ;didn't work..why??
the CS register is loaded with 0x08 itself, but the addressing doesn't seem to be as expected
        please help me??

RE:Problem with loading CS

Posted: Tue Apr 08, 2003 11:00 pm
by CETian
    Sorry for all friends. The probelem is solved. It was my bad interpretation of the jmp instruction which causes the confusion.