I have an issue with bochs reading my floppy drive. After reading a few sectors (1 - 10) bochs exits with the following error:
[BIOS ] int13_diskette: ctrl not ready.
The error occurs while executing interrupt 13h, but the parameters given to the interrupt seem to be fine:
AX: 0x0201 
BX: 0x0900
CX: 0x0004
DX: 0x0100
ES: 0x0000
Here is the floppy disk reading part:
; input: 
;   dl -> device
;   es:bx -> Buffer to read to
;   ax -> Start sector
;   cx -> Number of sectors
;
; output:
;   carry -> On error
fat_read_device:
    mov di, FAT_READ_RETRIES ; retries for error -> 5
    .try_load:
        push ax
        push bx
        push cx
        push bx
        mov bl, dl ; remember device
        mov dx, ax
        int 0xe2 ; Convert lba to chs -> Writing to cl, ch and dh
        mov dl, bl
        pop bx
        mov ah, 0x02 ; Read device es:bx
        mov al, 0x01 ; Number of sectors to read
        ;xchg bx, bx
        int 0x13
        jnc .done ; test if succeeded
        xor ax, ax ; Reset disk
        int 0x13
        dec di ; decrement error counter
        pop cx
        pop bx
        pop ax
        jnz .try_load ; attempt to read again
        stc
        ret
    .done:
        int 0xcf ; Feedback disk operation -> Print a "."
        pop cx
        pop bx
        pop ax
        add bx, word [bpbBytesPerSector] ; next sector
        inc ax ; read next sector
        loop fat_read_device ; repeat until cx sectors are read
        ret
I'm also reprogramming PIT 0 (programmable interval timer) to be 1000hz rather than 18.2hz using this code:
TIMER_DIVISOR EQU 1193
timer_init:
    cli
    mov al, 36h ; PIT channel 0
    out 43h, al ; select channel
    mov ax, TIMER_DIVISOR
    out 40h, al ;send low byte
    mov al, ah
    out 40h, al ;send high byte
    sti
    mov word [cs:timer_tick_count], 0
    ret
I do only get this error with bochs in debug mode. If I start the system in non debug mode, it works fine.
Has anyone had the same issue or does anyone have an idea what I am doing wrong?