Well, taking out the xor dx,dx didnt make aany effect it keeps trying to read a track above 80... 99 to be especific...
ill put all the code involved in the reading part that gives the error, but the comments are in portuguese.
Code: Select all
LBAtoCHS:
;xor dx, dx ; Preapara dx:ax para operacao
div WORD [bpbSectorsPerTrack] ; calcula
inc dl ; ajusta para setor 0
mov BYTE [absoluteSector], dl
xor dx, dx ; Preapara dx:ax para operacao
div WORD [bpbHeadsPerCylinder] ; calcula
mov BYTE [absoluteHead], dl
mov BYTE [absoluteTrack], al
ret
The code below loads the root to memory.
Code: Select all
loadroot:
; Calcula o tamanho do diretorio root
xor cx, cx
xor dx, dx
mov ax, 0x0020 ; entrada de diretorio 32 bytes
mul WORD [bpbRootEntries] ; tamanho total do diretorio
div WORD [bpbBytesPerSector] ; setores usados pelo diretorio
xchg ax, cx
; Calcula a localização do diretorio root
mov al, BYTE [bpbNumberOfFATs] ; numero de FATs
mul WORD [bpbSectorsPerFAT] ; setores usados pelas FATs
add ax, WORD [bpbReservedSectors] ; soma os setores reservados
mov WORD [datasector], ax ; base do diretorio root
add WORD [datasector], cx
; grava-o na memoria depois do boot sector (7C00:0200)
mov bx, 0x0200
call readsectors
And here the readsectors function:
Code: Select all
readsectors:
.main:
mov di, 0x0005 ; 5 tentativas para erro
.sectorloop:
push ax
push bx
push cx
mov ax,msg1
call print
call LBAtoCHS ; converter setor primario para CHS
mov ah, 0x02 ; setor de leitura da BIOS
mov al, 0x01 ; ler 1 setor
mov ch, BYTE [absoluteTrack] ; track
mov cl, BYTE [absoluteSector] ; sector
mov dh, BYTE [absoluteHead] ; head
mov dl, BYTE [bsDriveNumber] ; drive
int 0x13
When it comes to this place it gives the track 63h
Well Ill keep trying to find the error, but if anyone can give me a light it would help
Thanks in advance
EDIT: I also tried a code from the tutorial i followed
Code: Select all
div word [bpbSectorsPerTrack]
; ax = LBA / SPT
; dx = LBA % SPT = sector - 1
mov cx, dx
inc cx
; cx = sector no.
xor dx, dx
div word [bpbHeadsPerCylinder]
; ax = (LBA / SPT) / HPC = cylinder
; dx = (LBA / SPT) % HPC = head
mov ch, al
; ch = LSB 0...7 of cylinder no.
shl ah, 6
or cl, ah
; cl = MSB 8...9 of cylinder no. + sector no.
mov dh, dl
; dh = head no.
mov dl, [bsDriveNumber]
; dl = drive no.
mov ax, 201h
But it gave the same 63h (99) for the track