disk.asm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ;;;
  2. ; disk_load
  3. ; ---------
  4. ; Load disk sectors into memory.
  5. ;
  6. ; Parameters:
  7. ; - dh: number of sectors to read
  8. disk_load:
  9. pusha
  10. push dx ; store `dx' to check if the appropriate number of
  11. ; sectors were read later on.
  12. mov ah, 0x02 ; BIOS read routine
  13. mov al, dh ; read `dh' sectors
  14. mov ch, 0x00 ; select cylinder 0
  15. mov dh, 0x00 ; select head 0
  16. mov cl, 0x02 ; start reading from second sector (after the boot
  17. ; sector)
  18. int 0x13 ; BIOS interrupt
  19. jc disk_load_error ; if `cf' flag has gone off then a read error has
  20. ; occurred
  21. pop dx ; restore `dx'
  22. cmp dh, al ; were the appropriate amount of sectors read?
  23. jne disk_load_unexp ; if not then there was an error
  24. popa
  25. ret
  26. disk_load_error:
  27. mov bx, DISK_READ_ERROR ; print the error
  28. jmp disk_load_print_exit
  29. disk_load_unexp:
  30. mov bx, DISK_READ_UNEXP
  31. disk_load_print_exit:
  32. call print_string
  33. jmp $ ; lock due to failure
  34. DISK_READ_UNEXP:
  35. db "Unexpected amount of sectors read!",0
  36. DISK_READ_ERROR:
  37. db "Disk read error!",0