[SOLVED]int 13h ah=42h error code 4
Posted: Sun Feb 13, 2011 5:09 pm
Hello, I'm new to OS development, and semi-new to assembly, but not to programming in general.
I'm trying to write a basic bootloader (no filesystem yet, just trying to read from the drive). I'm using Notepad++,nasm,dd(both from cygwin), and virtualbox.
Every time I run it, I get error code 4, which according to http://www.ctyme.com/intr/rb-0606.htm#Table234, means that the sector is wrong or there was a generic read error. Not much info there.
Here is the source to my ReadDrive subroutine:
Here is the DiskAddrPack structure:
and the code i'm using to call it (should just load the next sector into an address)
Does anyone have an Idea? I've been googling all day, and can figure out anything.
That's all the code that partains to the reading of the sector. If you need anything else let me know.
Oh yeah, also I'm doing this from a floppy image.
I'm trying to write a basic bootloader (no filesystem yet, just trying to read from the drive). I'm using Notepad++,nasm,dd(both from cygwin), and virtualbox.
Every time I run it, I get error code 4, which according to http://www.ctyme.com/intr/rb-0606.htm#Table234, means that the sector is wrong or there was a generic read error. Not much info there.
Here is the source to my ReadDrive subroutine:
Code: Select all
; Read the root directory into 'disk_buffer'
; The DiskAddrPack is expected to be completely filled
; with all relevent data
; Also dl holds the device to read from
ReadDrive:
mov si,DiskAddrPack ; Tell int 13h where to find the settings
mov ah,42h ; Extended Read Sectors from drive function
int 13h ; Read!
ret
Code: Select all
;This is a packet of information about how, and what to read from a drive (used with the ReadDrive function)
DiskAddrPack:
.Size: db 10h ; Size of the Disk Address Packet
.Reserved1: db 0 ; Unused, always zero
.NSector: db 0 ; Number of sectors to read
.Reserved2: db 0 ; Unused, always zero
.Buffer: ; Pointer to the buffer to store the data (DS:DiskAddrPack.Buffer, segment:offset)
.BufferOffset: dw 0
.BufferSegment: dw 07C0h
.SectorIndex: ; The entire 8 bytes
.SectorIndexL: dd 0 ; Low 4 bytes
.SectorIndexH: dd 0 ; High 4 bytes
Code: Select all
mov byte[DiskAddrPack.NSector],1 ; Read one sector
mov word[DiskAddrPack.BufferOffset],2000h
mov dword[DiskAddrPack.SectorIndexL],1 ; Read sector one
mov dword[DiskAddrPack.SectorIndexH],0
mov dl,00h ; Set the read device
call ReadDrive ; Read from the drive
That's all the code that partains to the reading of the sector. If you need anything else let me know.
Oh yeah, also I'm doing this from a floppy image.