Instruction manual

02cb db 0f in a,(0fh) ;check status
02cd e6 08 and 08h ;DRQ bit
02cf c2 c7 02 jp nz,read_loop ;loop until cleared
02d2 c9 ret
02d3 ;
02d3 ;Subroutine to write one disk sector (256 bytes)
02d3 ;Address of data to write to disk passed in HL
02d3 ;LBA bits 0 to 7 passed in C, bits 8 to 15 passed in B
02d3 ;LBA bits 16 to 23 passed in E
02d3 disk_write:
02d3 db 0f wr_status_loop_1: in a,(0fh) ;check status
02d5 e6 80 and 80h ;check BSY bit
02d7 c2 d3 02 jp nz,wr_status_loop_1 ;loop until not busy
02da db 0f wr_status_loop_2: in a,(0fh) ;check status
02dc e6 40 and 40h ;check DRDY bit
02de ca da 02 jp z,wr_status_loop_2 ;loop until ready
02e1 3e 01 ld a,01h ;number of sectors = 1
02e3 d3 0a out (0ah),a ;sector count register
02e5 79 ld a,c
02e6 d3 0b out (0bh),a ;lba bits 0 - 7
02e8 78 ld a,b
02e9 d3 0c out (0ch),a ;lba bits 8 - 15
02eb 7b ld a,e
02ec d3 0d out (0dh),a ;lba bits 16 - 23
02ee 3e e0 ld a,11100000b ;LBA mode, select drive 0
02f0 d3 0e out (0eh),a ;drive/head register
02f2 3e 30 ld a,30h ;Write sector command
02f4 d3 0f out (0fh),a
02f6 db 0f wr_wait_for_DRQ_set: in a,(0fh) ;read status
02f8 e6 08 and 08h ;DRQ bit
02fa ca f6 02 jp z,wr_wait_for_DRQ_set ;loop until bit set
02fd 7e write_loop: ld a,(hl)
02fe d3 08 out (08h),a ;write data
0300 23 inc hl
0301 db 0f in a,(0fh) ;read status
0303 e6 08 and 08h ;check DRQ bit
0305 c2 fd 02 jp nz,write_loop ;write until bit cleared
0308 db 0f wr_wait_for_BSY_clear: in a,(0fh)
030a e6 80 and 80h
030c c2 08 03 jp nz,wr_wait_for_BSY_clear
56