尝试切换到 32 位模式时引导循环

Boot looping when trying to switch to 32 bit mode

当使用我的引导加载程序从 16 位模式切换到 32 位模式时,它会循环启动,我知道这是导致问题的原因,因为之前的所有代码都会导致预期的结果。关于可能出现的问题有什么建议吗?

我的代码:

[bits 16]
[org 0x7c00]

mov [bootDrive], dl

mov bp, 0x7c00
mov sp, bp

mov bx, welcomeMsg
call print

call inputStart

in al, 0x92
or al, 2
out 0x92, al

cli
lgdt [descriptorGDT]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp GDTCodeSeg:startProtectedMode

jmp $

%include "src/print.asm"
%include "src/BIOSKeyboardInput.asm"
%include "src/GDT.asm"

bootDrive: db 0

welcomeMsg: db "Hello there! Successfully entered bootloader.", 0

[bits 32]
startProtectedMode:
    mov ax, GDTDataSeg
    mov ds, ax
    mov ss, ax
    mov es, ax
    mov fs, ax
    mov gs, ax

    mov ax, 0x0F41
    mov [0xb8000], ax

    jmp $

times 510-($-$$) db 0
db 0x55, 0xaa

GDT.asm:

GDTNullSeg:  
    dd 0x0  
    dd 0x0  
  
GDTCodeSeg:  
    dw 0xFFFF  
    dw 0x0000  
    db 0x00  
    db 0b10011010  
    db 0b11001111  
    db 0x00  
  
GDTDataSeg:  
    dw 0xFFFF  
    dw 0x0000  
    db 0x00  
    db 0b10010010  
    db 0b11001111  
    db 0x00  
  
GDTEnd:  
  
descriptorGDT:  
    GDTSize:  
        dw GDTEnd - GDTNullSeg - 1  
        dd GDTNullSeg  
  
GDTCodeSegSize equ GDTCodeSeg - GDTNullSeg  
GDTDataSegSize equ GDTDataSeg - GDTNullSeg 

编辑: print.asm:

print:
    mov ah, 0x0e

    loop:
        mov al, [bx]
        cmp al, 0
        je exit
            int 0x10
            inc bx
            jmp loop

    exit:
        ret 

BIOSKeyboardInput.asm:

inputStart:
    mov bx, inputInfo
    call print

    call input
    ret

input:
    mov ah, 0x00
    int 0x16

    cmp al, 0x1B
    je exitInput

    cmp ah, 0x4B
    je leftArrowInput

    cmp ah, 0x4D
    je rightArrowInput

    cmp ah, 0x48
    je upArrowInput

    cmp ah, 0x50
    je downArrowInput

    cmp ah, 0x47
    je homeInput

    mov ah, 0x0e
    int 0x10

    cmp al, 0x8
    je backspaceInput

    jmp input

leftArrowInput:
    mov al, 0x8
    mov ah, 0x0e
    int 0x10
    jmp input

rightArrowInput:
    mov al, 0x20
    mov ah, 0x0e
    int 0x10
    jmp input

upArrowInput:
    jmp input

downArrowInput:
    jmp input

backspaceInput:
    mov al, 0x20
    int 0x10
    mov al, 0x8
    int 0x10
    jmp input

homeInput:
    mov al, 0x17
    mov ah, 0x0e
    int 0x10
    jmp input

exitInput:
    ret

inputInfo: db 0xA, 0xD, "To exit input mode click ESC.", 0

感谢 Jester 在评论中的回答:

问题是:

jmp GDTCodeSeg:startProtectedMode

mov ax, GDTDataSeg

您需要提供段选择器。
相反应该是:

jmp 8:startProtectedMode

mov ax, 16