Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

68 rader
2.0 KiB

  1. [BITS 16] ; We need 16-bit intructions for Real mode
  2. [ORG 0x7C00] ; The BIOS loads the boot sector into memory location 0x7C00
  3. cli ; Disable interrupts, we want to be alone
  4. xor ax, ax
  5. mov ds, ax ; Set DS-register to 0 - used by lgdt
  6. lgdt [gdt_desc] ; Load the GDT descriptor
  7. mov eax, cr0 ; Copy the contents of CR0 into EAX
  8. or eax, 1 ; Set bit 0
  9. mov cr0, eax ; Copy the contents of EAX into CR0
  10. jmp 08h:clear_pipe ; Jump to code segment, offset clear_pipe
  11. [BITS 32] ; We now need 32-bit instructions
  12. clear_pipe:
  13. mov ax, 10h ; Save data segment identifyer
  14. mov ds, ax ; Move a valid data segment into the data segment register
  15. mov ss, ax ; Move a valid data segment into the stack segment register
  16. mov esp, 090000h ; Move the stack pointer to 090000h
  17. mov byte [ds:0B8000h], 'P' ; Move the ASCII-code of 'P' into first video memory
  18. mov byte [ds:0B8001h], 1Bh ; Assign a color code
  19. hang:
  20. jmp hang ; Loop, self-jump
  21. gdt: ; Address for the GDT
  22. gdt_null: ; Null Segment
  23. dd 0
  24. dd 0
  25. gdt_code: ; Code segment, read/execute, nonconforming
  26. dw 0FFFFh
  27. dw 0
  28. db 0
  29. db 10011010b
  30. db 11001111b
  31. db 0
  32. gdt_data: ; Data segment, read/write, expand down
  33. dw 0FFFFh
  34. dw 0
  35. db 0
  36. db 10010010b
  37. db 11001111b
  38. db 0
  39. gdt_end: ; Used to calculate the size of the GDT
  40. gdt_desc: ; The GDT descriptor
  41. dw gdt_end - gdt - 1 ; Limit (size)
  42. dd gdt ; Address of the GDT
  43. times 510-($-$$) db 0 ; Fill up the file with zeros
  44. dw 0AA55h ; Boot sector identifyer