Code: Select all
;load kernel.bin from disk to 0x100000
read:
xor ax,ax ; Floppy Reset BIOS Function
mov dl,[drive] ; Select floppy that was booted from
int 0x13
jc read
mov ax,0xffff
mov es,ax ; Data buffer for file
mov bx,0x10 ; Start of segment
mov ah,2 ; Function to read disk
mov al,17 ; Total sectors to read
mov ch,0 ; Track
mov cl,2 ; Sector
mov dh,0 ; Head | Drive is already loaded
int 0x13 ; Call BIOS read disk function
jc read ; motor error, try again
mov bx, 0x2210
mov dh,1 ; Head | Drive is already loaded
mov cl,1 ; Sector
next_read:
mov ax,0xffff
mov es,ax
mov ah,2 ; Function to read disk
mov al,18 ; Total sectors to read
int 0x13 ; Call BIOS read disk function
jc end_read ; reached end of disk
add bx,0x2400 ; next buffer
xor dh,1 ; alternate head
jnz next_read ;
inc ch ; increment cylinder/track
jmp next_read
end_read:
mov dx,0x3F2 ; stop the motor
mov al,0x0C ; from spinning
out dx,al
00218236515d[FDD ] BEFORE
00218236515d[FDD ] drive = 0
00218236515d[FDD ] head = 0
00218236515d[FDD ] cylinder = 3
00218236515d[FDD ] sector = 1
00218236515d[FDD ] eot = 18
00218236515d[FDD ] floppy_xfer: drive=0, offset=55296, bytes=512, direction=from floppy
...
00218792576d[FDD ] floppy_xfer: drive=0, offset=55808, bytes=512, direction=from floppy
...
...
00226021369d[FDD ] floppy_xfer: drive=0, offset=62464, bytes=512, direction=from floppy
...
00226577430d[FDD ] floppy_xfer: drive=0, offset=62976, bytes=512, direction=from floppy
...
00227133491d[FDD ] floppy_xfer: drive=0, offset=63488, bytes=512, direction=from floppy
...
00227689552d[FDD ] floppy_xfer: drive=0, offset=64000, bytes=512, direction=from floppy
...
00228245613d[FDD ] <<READ DONE>>
00228245613d[FDD ] AFTER
00228245613d[FDD ] drive = 0
00228245613d[FDD ] head = 1
00228245613d[FDD ] cylinder = 3
00228245613d[FDD ] sector = 1
thanks
ivan