Advertisement
Guest User

Updated boot.asm

a guest
Jul 24th, 2022
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [org 0x7c00]                        
  2. KERNEL_LOCATION equ 0x1000
  3.                                    
  4. xor ax, ax
  5. mov ds, ax
  6. mov es, ax
  7. mov ss, ax
  8. mov sp, 0x8000
  9. mov [BOOT_DISK], dl
  10.  
  11. ;Get video mode info
  12. mov ax, 4f01h
  13. mov cx, 105h
  14. mov di, modeInfo
  15. int 10h
  16.  
  17. mov eax, modeInfo
  18. mov bx, KERNEL_LOCATION
  19. mov dh, 32
  20.  
  21. mov ah, 0x02
  22. mov al, dh
  23. mov ch, 0x00
  24. mov dh, 0x00
  25. mov cl, 0x02
  26. mov dl, [BOOT_DISK]
  27. int 0x13
  28.  
  29.                                    
  30. mov ax, 0x4F02   ; set VBE mode
  31. mov bx, 0x4118   ; VBE mode number
  32. int 0x10         ; call VBE BIOS
  33. cmp ax, 0x004F   ; test for error
  34. jne error
  35.  
  36. CODE_SEG equ GDT_code - GDT_start
  37. DATA_SEG equ GDT_data - GDT_start
  38.  
  39. cli
  40. lgdt [GDT_descriptor]
  41. mov eax, cr0
  42. or eax, 1
  43. mov cr0, eax
  44. jmp CODE_SEG:start_protected_mode
  45.  
  46. jmp $
  47.  
  48. modeInfo    TIMES 256 db 0
  49.  
  50. error:
  51.    stc
  52.    ret
  53.  
  54. BOOT_DISK: db 0
  55.  
  56. GDT_start:
  57.     GDT_null:
  58.         dd 0x0
  59.         dd 0x0
  60.  
  61.     GDT_code:
  62.         dw 0xffff
  63.         dw 0x0
  64.         db 0x0
  65.         db 0b10011010
  66.         db 0b11001111
  67.         db 0x0
  68.  
  69.     GDT_data:
  70.         dw 0xffff
  71.         dw 0x0
  72.         db 0x0
  73.         db 0b10010010
  74.         db 0b11001111
  75.         db 0x0
  76.  
  77. GDT_end:
  78.  
  79. GDT_descriptor:
  80.     dw GDT_end - GDT_start - 1
  81.     dd GDT_start
  82.  
  83.  
  84. [bits 32]
  85. start_protected_mode:
  86.     mov ax, DATA_SEG
  87.     mov ds, ax
  88.     mov es, ax
  89.     mov fs, ax
  90.     mov gs, ax
  91.     mov ss, ax
  92.     mov esp, 0x00090000     ; 32 bit stack base pointer
  93.     mov ebp, esp            ; Only if you need this!
  94.  
  95.     jmp KERNEL_LOCATION
  96.  
  97.                                      
  98.  
  99. times 510-($-$$) db 0              
  100. dw 0xaa55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement