Advertisement
AungKhantMin

boot_sec.asm

Jul 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;
  2. ;  boot_sec.s
  3. ;  HADES OS
  4. ;
  5. ;  Created by Aung Khant Min on 7/14/18.
  6. ;
  7. [bits 16]
  8. [org 0x7c00]
  9. KERNEL_OFFSET equ 0x1000
  10.  
  11.  
  12. xor ax, ax
  13. mov ds, ax
  14. mov es, ax
  15. mov [BOOT_DRIVE], dl
  16. mov ax,0x07E
  17. cli
  18. mov ss, ax
  19. mov sp, 0x1200
  20. sti
  21.  
  22.  
  23.  
  24. mov bx, MSG_REAL_MODE
  25. call print
  26.  
  27. call load_kernel
  28.  
  29. call switch_to_pm
  30.  
  31. jmp $
  32.  
  33. %include "./rm/print_func.asm"
  34. %include "./rm/disk_load.s"
  35. %include "./pm/global_descriptor_table.asm"
  36. %include "./pm/print_string_pm.asm"
  37. %include "./pm/swith_to_pm.asm"
  38.  
  39. [bits 16]
  40.  
  41. load_kernel:
  42.     mov bx, LOAD_KERNEL_MSG
  43.     call print
  44.  
  45.     mov bx, KERNEL_OFFSET
  46.     mov dh, 15
  47.     mov dl, [BOOT_DRIVE]
  48.     call disk_load
  49.     ret
  50.  
  51. [bits 32]
  52.  
  53. BEGIN_PM:
  54.     mov ebx, MSG_PROT_MODE
  55.     call print_string_pm
  56.  
  57.     call KERNEL_OFFSET
  58.     jmp $
  59.  
  60.  
  61. BOOT_DRIVE db 0
  62. SECTORS db 0
  63. MSG_REAL_MODE db "Started in 16-bit Real Mode.", 0
  64. LOAD_KERNEL_MSG db "Loading kernel into memory.", 0
  65. MSG_PROT_MODE db "Successfully landed in 32-bit Protected Mode", 0
  66.  
  67. times 510-($-$$) db 0
  68. dw 0xaa55
  69.  
  70. ;times 15*256 dw 0xDADA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement