Right, its been a while, university work sort of piled up quickly. I've had a few moments to breathe so I thought id get back to this. I've re-written the code for the LBA to CHS conversion but its still not working. I've narrowed it down to two possible issues. The first being the code that converts the LBA and the second being an incorrect value from reading the RootDirectory or FAT. I'm hoping its the conversion that's wrong. This is the code I'm using right now:
Code: Select all
pusha ;0050)Preserve all the registers by moving them to the stack
mov si, NxtSect ;0051)Set the source index to the memory location of the next LBA
mov ax, FIHPT ;0052)
mov bx, FISPT ;0053)
mul bx ;0054)
mov bx, ax ;0055)
lodsw ;0056)
div bx ;0057)
mov di, CylinderTMP ;0058)
stosw ;0059) the lower ten bits of AX is the cylinder the data is stored on
mov ax, dx ;0060) take the remainder from the divide operation and store it in ax
mov bx, FISPT ;0061)
div bx ;0062)
mov di, Head ;0062)
stosb ;00064)AL should be the head of the disk.
inc dx
mov ax, dx
mov di, SectorTMP
mov si, CylinderTMP
xor ax, ax
xor bx, bx
lodsw
mov word ax, [si]
shr ax, 6
mov di, SectorTMP
mov bx, ax
lodsw
shr ax, 10
shl ax, 10
or ax, bx
mov si, CylinderSector
stosw
popa
ret
Yes I know its incredible in-efficient, but I wanna get the actual code working before I start optimising. The values being used, such as FISPT are:
Code: Select all
;1.44MB Floppy Information 3.5-=-=-=-=-=
FIBPS equ 0x0200 ;0000) The number of bytes in each sector
FISPC equ 0x01 ;0000) The number of sectors that exists with in a cluster
FIRE equ 0x00E0 ;0000) The total number of root director ientries
FIMT equ 0xF0 ;0000) The type of media being read
FISPF equ 0x0009 ;0000) The number of sectors that makes up the FAT
FISPT equ 0x0012 ;0000) The number of sectors on each track
FIHPT equ 0x0002 ;0000) The number of heads on the disk
Is there anything obliviously wrong that I'm missing. I've gone through ti several times even noting it down with pen and paper and yet it still doesn't work. After the conversion I. get the values:
AX = 0x0201
BX = 0xE000
CX = 0x0000
DX = 0x3900
ES = 0x0000
The disk I'm using is a 1.44mb floppy disk formatted with FAT12. Any help would be great because this is driving me crazy.