Basic Floppy Disk loader help.
- From: "Jean-François Michaud" <spamtrap@xxxxxxxxxx>
- Date: 29 Dec 2005 19:59:23 -0800
Does anybody see why this bombs if i put 3Ch or above in
nbSectorsTotal? This is a really old bug I can't seem to pinpoint. 3Ch
would put us at 60 decimal which would be, if I calculated correctly,
Track 1, head 1, sector 6. The code works fine below 3Ch.
nbSectorsTotal: .word 0x003B
startAddress: .word 0x0500
trackToRead: .byte 0x00
headToUse: .byte 0x00
#______________________________________________________________________
#
# It is important to note the alternance of the tracks, head, sectors.
# A high density floppy has 80 tracks ( 0-79 ), 2 heads ( 0-1 ) and
# 18 sectors ( 1-18 )
#
# The value of these attributes alternates as if incrementing a 3 "bit"
# binary counter, each "bit" ranging from their respective minimum
# value to their maximum value:
#
# ( track, head, sector )
#
# sector 1 = ( 0, 0, 1 )
# sector 2 = ( 0, 0, 2 )
# ...
# sector 19 = ( 0, 1, 1 )
# sector 20 = ( 0, 1, 2 )
# ...
# sector 37 = ( 1, 0, 1 )
# and so forth...
#______________________________________________________________________
#
loadKernel:
resetFloppyDrive:
xor %ah, %ah # Zero to reset the floppy controler
xor %dl, %dl
int $0x13 # Controler reset
readASector:
mov $0x02, %ah # Function 0x02 of interrupt 0x13
mov $0x00, %dl # Drive number ( 0x00 = A: 0x01 = B: 0x80 = hda
0x81 = hdb )
mov $0x01, %al # Numbers of sectors to read
movw $trackToRead, %si
movb (%si), %ch # Track to read ( 0-79 tracks per floppy )
movw $headToUse, %si
mov (%si), %dh # Head to use ( 0-1 for a floppy )
movw $sectorToStartFrom, %si
mov (%si), %cl # Sector to start from ( 1-18 per head per track )
xor %bx, %bx # Indirect addressing for %es
mov %bx, %es # We change %es
movw $startAddress, %bx
movw (%bx), %bx # We finalize es:bx to situate ourselves at
0000:0500
int $0x13 # We read the sectors
sectorLogic:
movw $sectorToStartFrom, %si # We want the next sector, so we adjust
the
movb (%si), %bl # sector to start from ( can't go beyond
0x12 )
inc %bl
movb %bl, (%si)
cmp $0x13, %bl
je headLogic
jmp logicEnd
headLogic:
movb $0x01, %bl
movb %bl, (%si)
movw $headToUse, %si
movb (%si), %bl # Track to read ( 0-79 tracks per floppy )
inc %bl
movb %bl, (%si)
cmp $0x02, %bl
je trackLogic
jmp logicEnd
trackLogic:
xor %bx, %bx
movb %bl, (%si)
movw $trackToRead, %si
movb (%si), %bl # Track to read ( 0-79 tracks per floppy )
inc %bl
movb %bl, (%si)
cmp $0x50, %bl
je readOverflowLogic
jmp logicEnd
readOverflowLogic:
xor %bx, %bx
movb %bl, (%si)
jmp errorReadingFloppy
logicEnd:
movw $startAddress, %si # We just read one sector ( 512 bytes ) so we
adjust the
movw (%si), %bx # start address for the next sector to read
addw $0x0200, %bx
movw %bx, (%si)
movw $nbSectorsTotal, %si # We decrement the counter and check if we
have reached
movw (%si), %bx # 0
dec %bx
movw %bx, (%si)
cmp $0x0000, %bx
jne readASector
jc loadKernel # On error we try again
ret
Regards
Jean-Francois Michaud
.
- Follow-Ups:
- Re: Basic Floppy Disk loader help.
- From: David J. Craig
- Re: Basic Floppy Disk loader help.
- Prev by Date: Re: Question about the A20 line
- Next by Date: Re: Basic Floppy Disk loader help.
- Previous by thread: Question about the A20 line
- Next by thread: Re: Basic Floppy Disk loader help.
- Index(es):
Relevant Pages
|