no_bios_hello_world.S 733 B

12345678910111213141516171819202122232425262728293031323334
  1. /* https://github.com/cirosantilli/x86-bare-metal-examples#no-bios-hello-world */
  2. #include "common.h"
  3. BEGIN
  4. mov $0xB800, %di
  5. mov %di, %es
  6. xor %di, %di
  7. lea msg, %si
  8. /* clear screen from SeaBIOS messages */
  9. xor %ax, %ax
  10. movw $2000, %cx
  11. repz stosw
  12. xor %di, %di
  13. /* write a string on the screen */
  14. .loop:
  15. lodsb
  16. test %al, %al
  17. jz .halt
  18. /* write the character */
  19. movb %al, %es:(%di)
  20. /* write color attribute of this character
  21. * 20d = 0x14 = 10100b = color attributes (red on blue)
  22. * background color = 1b = blue
  23. * foreground color = 100b = red
  24. */
  25. movb $20, %es:1(%di)
  26. add $0x2, %di
  27. jmp .loop
  28. .halt:
  29. hlt
  30. msg:
  31. .asciz "hello world"