I ran into the issue I'm not able to find out the root cause of. I'd appreciate if somebody can help.
I'm reading the disk partition using the int 0x13 service 02 sector by sector.
Virtual disk parameters: 20MB, MBR layout with one FAT16 partition, start: 0/1/1, end: 318/01/63 , sectors per track: 63, heads per cylinder: 2, sector size: 512, cluster size: 4.
I noticed that if I specify to read only one sector (AX: 0x0201) and go beyond the disk offset 0xfe00 (first fail at CHS 1/0/1) I start seeing weird behavior. No error is indicated (AH = 0 after int 0x13) but I start reading back 0s. ES:BX is set to write to the same location all the time, buffer doesn't grow out of the segment, etc.
I'm attaching my code too:
Just before call AX = 0; CX = -1, ES:BX = 0x7c0:0200 (phys 0x7e00)
Code: Select all
; Reads sectors into the buffer. Requires following arguments: ; ; AX: starting sector for read ; CX: sectors to read ; ES:BX buffer to read to ; read_sectors: .freshread: mov di, HDD_RETRY_SECTOR_READ .retry: inc cx ; XXX: debug push cx push ax call lba2chs ; BIOS call 0x13, function: AH = 0x02 (read sectors from drive) mov ch, byte [chs_track] ; CH: cylinder mov cl, byte [chs_sector] ; CL: sector mov dh, byte [chs_head] ; DH: head mov dl, byte [bsDriveNumber] ; DL: drive mov ax, 0x0201 ; AL: sectors to read int 0x13 jnc .ok xor ax,ax ; BIOS call 0x13, function: AH: 0 = reset disk int 0x13 pop ax pop cx dec di ; retry till we don't reach the HDD_RETRY_SECTOR_READ jnz .retry .error: lea si, [rdf] call puts16 jmp fatal ; fatal error, reboot .ok: lea si, [msg_dot] call puts16 pop ax pop cx inc ax ; debug ; add bx, word [bpbBytesPerSector] times 4 nop loop .freshread ret