CLI和STI不工作 [英] CLI and STI are not working
问题描述
我在x86汇编的初学者。我编了一个小的操作系统(与NASM编译到软盘),和我遇到一些麻烦吧。这种操作sysem旨在打开瓶盖,滚动和Num Lock,然后等待半秒,然后将其关闭,然后等待半秒。然后重复。
I am an beginner in x86 assembly. I have compiled a small operating system (compiled with nasm onto a floppy disk), and I am having some trouble with it. This operating sysem is designed to turn on Caps, Scroll, and Num Lock, then wait for half of a second, then turn them off, then wait half a second. Then it repeats.
问题是在行 CLI
和 STI
。这应该被启用,以确保原子性,所以时机是 Wait_Clk_Ticks
正确的。当这些线投入该计划,指示灯亮起,但仅此而已。当他们不在程序,灯光闪烁和关闭,因为他们应该。有什么不对这个code?
The problem is at the lines cli
and sti
. This should be enabled to ensure atomicity, so the timing is correct for Wait_Clk_Ticks
. When these lines are put into the program, the lights turn on, but that is all. When they are not in the program, the lights blink on and off as they should. What is wrong with this code?
在 Wait_Clk_Ticks
$ C $的 JMP
功能C产生中断?有人告诉我, CLI
和 STI
用于禁用硬件中断。是否 JMP
产生一个硬件中断?
Are the jmp
functions in the Wait_Clk_Ticks
code causing an interrupt? I am told that cli
and sti
are used to disable hardware interrupts. Does jmp
cause a hardware interrupt?
code:
; blinklights.asm
[BITS 16]
[ORG 0x7C00]
jmp Code_Start
Switch_Kbd_Leds:
push dx ; Store current values.
push ax
mov dx, 60h ; '60h' is the 'kbd' port value.
mov al, 0EDh ; '0EDh' is 'set/reset leds' function.
out dx, al ; Then output to the port.
pop ax ; Get the setting from the stack.
out dx, al ; Output this data to the port.
pop dx ; Restore 'dx'.
ret ; Return.
Wait_Clk_Ticks:
cli
mov ax, 0
mov ds, ax
mov bx, [46Ch]
WaitForAnotherChange:
NoChange:
mov ax, [46Ch]
cmp ax, bx
je NoChange
mov bx, ax
loop WaitForAnotherChange
sti
ret ; Return.
Code_Start:
mov al, 00000111b
call Switch_Kbd_Leds
mov cx, 9
call Wait_Clk_Ticks
mov al, 00000000b
call Switch_Kbd_Leds
mov cx, 9
call Wait_Clk_Ticks
jmp Code_Start
End:
jmp $ ; Run this line over and over again- stops excecution.
times 510-($-$$) db 0 ; Fill the rest of the 512 byte sector with zeros
dw 0xAA55 ; Boot magic number
我在IBM 8307上运行该code使用USB键盘。
I am running this code with a USB keyboard on an IBM 8307.
感谢您的帮助:)
推荐答案
你不觉得CLI还禁止时钟中断和定时器停止?
Don't you think cli also disables the clock interrupt, and the timer stops?
这篇关于CLI和STI不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!