Advertisement
MichaelPetch

SO 78375426

Apr 24th, 2024 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. org 0x7C00
  2. bits 16
  3.  
  4. %define ENDL 0x0D, 0x0A
  5.  
  6. jmp short start
  7. nop
  8.  
  9. bdn_oem: db "MSWIN4.1"
  10. bdb_bytes_per_sector: dw 512
  11. bdb_sectors_per_cluster: db 1
  12. bdb_reserved_sectors: dw 1
  13. bdb_fat_count: db 2
  14. bdb_num_rootdirs: dw 0E0h
  15. bdb_total_sectors: dw 2880
  16. bdb_media_descriptor_type: db 0F0h
  17. bdb_sectors_per_fat: dw 9
  18. bdb_sectors_per_track: dw 18
  19. bdb_heads: dw 2
  20. bdb_hidden_sectors: dd 0
  21. bdb_large_sector_count: dd 0
  22. ebr_drive_number: db 0
  23. db 0
  24. ebr_signature: db 29h
  25. ebr_volume_id: db 12h, 34h, 56h, 78h
  26. ebr_volume_label: db 'MudOS 1.0 '
  27. ebr_system_id: db 'FAT12 '
  28.  
  29. start:
  30. jmp main
  31.  
  32. puts:
  33. push si
  34. push ax
  35. mov ah, 0eh
  36.  
  37. .loop:
  38. lodsb
  39. or al, al
  40. jz .done
  41. mov bh, 0
  42. int 0x10
  43.  
  44. jmp .loop
  45.  
  46. .done:
  47. pop ax
  48. pop si
  49. ret
  50.  
  51. main:
  52. mov ax, 0
  53. mov ds, ax
  54. mov es, ax
  55. mov ss, ax
  56. mov sp, 0x7C00
  57. mov [ebr_drive_number], dl
  58.  
  59. mov ax, 1 ; LBA = AX = 1 (sector after bootloader)
  60. mov cl, 1 ; Number of sectors to read
  61. mov bx, 0x7E00
  62. call disk_read
  63.  
  64. mov si, msg_bootstring
  65. call puts
  66. cli
  67. hlt
  68.  
  69. floppy_error:
  70. mov si, msg_read_failed
  71. call puts
  72. jmp wait_key_and_reboot
  73.  
  74. wait_key_and_reboot:
  75. mov ah, 0
  76. int 16h
  77. jmp 0FFFFh:0
  78. .halt:
  79. cli
  80. hlt
  81.  
  82.  
  83. lba_to_chs:
  84. push ax
  85. push dx
  86.  
  87. xor dx, dx
  88. div word [bdb_sectors_per_track]
  89. inc dx
  90. mov cx, dx
  91. xor dx, dx
  92. div word [bdb_heads]
  93.  
  94. mov dh, dl
  95. mov ch, al
  96. shl ah, 6
  97. or cl, ah
  98.  
  99. pop ax
  100. mov dl, al
  101. pop ax
  102. ret
  103.  
  104.  
  105. disk_read:
  106. push ax
  107. push bx
  108. push cx
  109. push dx
  110. push di
  111.  
  112. mov si, cx ; Temp save sectors to read (CX) to SI
  113. call lba_to_chs
  114. mov ax, si ; Set AL to number to number of sectors to read (SI)
  115. mov ah, 02h
  116. mov di, 3
  117.  
  118. .retry:
  119. pusha
  120. stc
  121. int 13h
  122. jnc .done
  123. popa
  124. call disk_reset
  125. dec di
  126. test di, di
  127. jnz .retry
  128.  
  129. .fail:
  130. jmp floppy_error
  131.  
  132. .done:
  133. popa
  134.  
  135. pop di
  136. pop dx
  137. pop cx
  138. pop bx
  139. pop ax
  140. ret
  141.  
  142. disk_reset:
  143. pusha
  144. mov ah, 0
  145. stc
  146. int 13h
  147. jc floppy_error
  148. popa
  149. ret
  150.  
  151. msg_bootstring: db "MudOS 1.0 Beta Development Preview", ENDL, 0
  152. msg_bootstring1: db "Starting", ENDL, 0
  153. msg_read_failed: db "Floppy read failed", ENDL, 0
  154.  
  155. times 510-($-$$) db 0
  156. dw 0AA55h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement