SteveOS for 16 bit processors (286)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

46 lines
748 B

  1. ;; Load sector from floppy
  2. ;; cl - sector number
  3. ;; ch - cylinder number
  4. ;; dh - head number
  5. ;; es:bx - RAM location
  6. read_sector:
  7. push ax
  8. mov ah, 0x02
  9. call do_sector
  10. pop ax
  11. ret
  12. write_sector:
  13. push ax
  14. mov ah, 0x03
  15. call do_sector
  16. pop ax
  17. ret
  18. do_sector:
  19. pusha ;preserve registers
  20. mov [disk_errors], byte 0 ;Reset error count
  21. mov dl, 0x00 ;Floppy
  22. do_sector_int:
  23. pusha ;registers get changed by int
  24. int 0x13
  25. jc do_sector_err ;CF set
  26. popa
  27. popa
  28. ret
  29. do_sector_err:
  30. ;; should count # of times errored
  31. popa
  32. add [disk_errors], byte 1 ;Increment err count
  33. cmp [disk_errors], byte 5
  34. jle do_sector_int
  35. ;; Handle error
  36. shr ax, 8 ;right binary shift
  37. mov ah, 0
  38. call print_hex
  39. popa
  40. ret
  41. disk_errors: db 0