我认为BIOS中断8(计时器)应该每秒出现18.2次,但在qemu上却不是这样。请参见以下示例:
$ cat c.asm
init:
.segments:
mov ax, 0x07C0
mov ds, ax
mov ax, 0
mov fs, ax
.interrupt:
mov [fs:0x08*4], word timer
mov [fs:0x08*4+2], ds
main:
hlt
jmp main
timer:
mov ah, 0x0e
mov al, 0x41
int 0x10
iret
times 510-($-$$) db 0
dw 0xaa55
$ nasm -f bin c.asm -o c.bin && qemu-system-x86_64 c.bin
出现Qemu窗口,只显示一个'A‘,而不是连续显示。
如果我希望一次又一次地中断8的到来,我的代码出了什么问题。
我使用的是nasm 1.14.02、qemu 4.2.1和ubuntu 20.04。
发布于 2021-01-06 22:19:06
使其重复显示'A‘的关键更改是向端口20h上的PIC发送中断结束信号。如果你使用中断1Ch或链到另一个中断08h处理程序,这在你的代码中是不需要的。但是,如果您完全替换了中断08h处理程序,那么它就是。PIC不会发送另一个IRQ #0,直到前一个得到EOI。正因为如此,我才能重现你的问题。
我所做的其他更改是确保在进入main
循环之前设置中断标志(使用sti
指令),并保留中断08h处理程序中的所有寄存器(如果您的代码是机器上唯一运行的,则这是可选的)。
init:
.segments:
mov ax, 0x07C0
mov ds, ax
mov ax, 0
mov fs, ax
.interrupt:
mov [fs:0x08*4], word timer
mov [fs:0x08*4+2], ds
sti
main:
hlt
jmp main
timer:
push ax
push bx
push bp
mov ah, 0x0e
mov al, 0x41
int 0x10
mov al, 20h
out 20h, al
pop bp
pop bx
pop ax
iret
times 510-($-$$) db 0
dw 0xaa55
像这样运行:
$ nasm test.asm
$ timeout 10 qemu-system-x86_64 test -curses
https://stackoverflow.com/questions/65592858
复制相似问题