Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [org 0x7c00]
- KERNEL_LOCATION equ 0x1000
- xor ax, ax
- mov ds, ax
- mov es, ax
- mov ss, ax
- mov sp, 0x8000
- mov [BOOT_DISK], dl
- ;Get video mode info
- mov ax, 4f01h
- mov cx, 105h
- mov di, modeInfo
- int 10h
- mov eax, modeInfo
- mov bx, KERNEL_LOCATION
- mov dh, 32
- mov ah, 0x02
- mov al, dh
- mov ch, 0x00
- mov dh, 0x00
- mov cl, 0x02
- mov dl, [BOOT_DISK]
- int 0x13
- mov ax, 0x4F02 ; set VBE mode
- mov bx, 0x4118 ; VBE mode number
- int 0x10 ; call VBE BIOS
- cmp ax, 0x004F ; test for error
- jne error
- CODE_SEG equ GDT_code - GDT_start
- DATA_SEG equ GDT_data - GDT_start
- cli
- lgdt [GDT_descriptor]
- mov eax, cr0
- or eax, 1
- mov cr0, eax
- jmp CODE_SEG:start_protected_mode
- jmp $
- modeInfo TIMES 256 db 0
- error:
- stc
- ret
- BOOT_DISK: db 0
- GDT_start:
- GDT_null:
- dd 0x0
- dd 0x0
- GDT_code:
- dw 0xffff
- dw 0x0
- db 0x0
- db 0b10011010
- db 0b11001111
- db 0x0
- GDT_data:
- dw 0xffff
- dw 0x0
- db 0x0
- db 0b10010010
- db 0b11001111
- db 0x0
- GDT_end:
- GDT_descriptor:
- dw GDT_end - GDT_start - 1
- dd GDT_start
- [bits 32]
- start_protected_mode:
- mov ax, DATA_SEG
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax
- mov ss, ax
- mov esp, 0x00090000 ; 32 bit stack base pointer
- mov ebp, esp ; Only if you need this!
- jmp KERNEL_LOCATION
- times 510-($-$$) db 0
- dw 0xaa55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement