boot.S 791 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Boot sector stub: run at 0x7C00, set VGA mode 0x03, print message, call kernel_main. */
  2. .code16
  3. .section .text
  4. .globl _start
  5. _start:
  6. xorw %ax, %ax
  7. movw %ax, %ds
  8. movw %ax, %ss
  9. movw $0x7c00, %sp
  10. /* Set VGA mode 0x03 (80x25 color) via BIOS int 0x10 */
  11. movw $0x0003, %ax
  12. int $0x10
  13. /* Print "Welcome to nebos" in green by writing to VGA text buffer at 0xB8000 */
  14. movw $0xb800, %ax
  15. movw %ax, %es /* ES = VGA segment */
  16. xorw %di, %di /* start at offset 0 (top-left) */
  17. movw $msg, %si
  18. movb $0x02, %ah /* attribute: green on black */
  19. 1: lodsb
  20. cmpb $0, %al
  21. je 2f
  22. movw %ax, %es:(%di) /* write (attr<<8)|char to screen */
  23. addw $2, %di
  24. jmp 1b
  25. 2:
  26. call kernel_main
  27. cli
  28. 3: hlt
  29. jmp 3b
  30. msg:
  31. .asciz "Welcome to nebos"
  32. .section .bootsig
  33. .byte 0x55, 0xaa