1

我在读取我的软盘驱动器时遇到问题。读取几个扇区 (1 - 10) 后,bochs 退出并出现以下错误:

[BIOS] int13_diskette:ctrl 未准备好。

执行中断 13h 时出现错误,但给中断的参数似乎没问题:

AX: 0x0201 
BX: 0x0900
CX: 0x0004
DX: 0x0100
ES: 0x0000

下面是软盘读取部分:

; 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

我还使用以下代码将 PIT 0(可编程间隔计时器)重新编程为 1000hz 而不是 18.2hz:

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

我只在调试模式下遇到这个错误。如果我以非调试模式启动系统,它工作正常。

有没有人有同样的问题,或者有没有人知道我做错了什么?

4

0 回答 0