How to switch from real mode to protected mode

265 Views Asked by At

I am going to write a simple operating system. An error have been occurred while switch from 16 bits' real mode to 32 bits' protected mode.

After loading the GDT register and setting the GDT, the protected mode has been turned on successfully. I'd like to jump to 0x0 address in memory but failed and the information of GDT shows that there are thousands of GDT describer.

'''

    lgdt    (gdt_48 - _start + 0x7c00)
    movw    $0x1, %ax
    lmsw    %ax         // switch protect mode on 

    jmp $0x8, $0x0      // jmp 0:0

gdt:
    .word   0, 0, 0, 0

    .word   0x07ff
    .word   0x0000
    .word   0x9a00
    .word   0x00c0

    .word   0x07ff
    .word   0x0000
    .word   0x9200
    .word   0x00c0

gdt_48:
    .word   0x7ff       // 2048/8=256
    .word   gdt, 0   

'''

Here is debug info: enter image description here

0

There are 0 best solutions below