SteveOS for 16 bit processors (286)

disk.asm 748B

    ;; Load sector from floppy ;; cl - sector number ;; ch - cylinder number ;; dh - head number ;; es:bx - RAM location read_sector: push ax mov ah, 0x02 call do_sector pop ax ret write_sector: push ax mov ah, 0x03 call do_sector pop ax ret do_sector: pusha ;preserve registers mov [disk_errors], byte 0 ;Reset error count mov dl, 0x00 ;Floppy do_sector_int: pusha ;registers get changed by int int 0x13 jc do_sector_err ;CF set popa popa ret do_sector_err: ;; should count # of times errored popa add [disk_errors], byte 1 ;Increment err count cmp [disk_errors], byte 5 jle do_sector_int ;; Handle error shr ax, 8 ;right binary shift mov ah, 0 call print_hex popa ret disk_errors: db 0