Problem with loading CS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
CETian

Problem with loading CS

Post 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??
CETian

RE:Problem with loading CS

Post by CETian »

    Sorry for all friends. The probelem is solved. It was my bad interpretation of the jmp instruction which causes the confusion.
Post Reply