the code is simple i tried to read 1 sector at a time, but everytime i get to read sector # 54 it hangs up.
it doesnt fail in the error message control loop, but on the load loop when i load 57 secotors, 52 are ok tho
Code: Select all
[BITS 16] ; We need 16-bit intructions for Real mode
[ORG 0x7C00] ; The BIOS loads the boot sector into memory location 0x7C00
jmp 0x0000:start
start:
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, ax
mov [bootdrive], dl ; boot drive stored by BIOS in DL.
mov di, 0FFh ;tries before an error
reset_drive:
dec di
mov ax, di
cmp ax, 0
je errorMSG ;if all tries failed print error
mov ah, 0 ; RESET-command
int 13h ; Call interrupt 13h
or ah, ah
jnz reset_drive
mov ax, 0
mov es, ax
push di
mov di, 0x1000 ;where in memory to load
mov si, 0
loadLoop:
mov bx, di ; Destination address = 0000:1000, increments per sector
mov ah, 02h ; READ SECTOR-command
mov al, 1 ; Number of sectors to read = 1
mov ch, 0 ; Cylinder = 0
mov cl, 2 ; Sector = 2
add cx, si
mov dh, 0 ; Head = 0
mov dl, [bootdrive]
int 13h ; Call interrupt 13h
or ah, ah ; Check for error code
jnz reset_drive ; Try again if ah != 0
add di, 0x0200 ;next place in memory to load the next sector
inc si
cmp si, 57
jne loadLoop