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!
retCode: 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 bytesCode: 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 driveThat'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.


