私は x86 アセンブリの初心者です。小さなオペレーティング システム (nasm を使用してフロッピー ディスクにコンパイル) をコンパイルしましたが、問題が発生しています。このオペレーティング システムは、Caps、Scroll、および Num Lock をオンにしてから 0.5 秒待ってからオフにし、さらに 0.5 秒待つように設計されています。それが繰り返されます。
問題は と の行cli
にありsti
ます。これは原子性を確保するために有効にする必要があるため、タイミングはWait_Clk_Ticks
. これらの行をプログラムに入れると、ライトが点灯しますが、それだけです。それらがプログラムにないとき、ライトは必要に応じてオンとオフを点滅します。このコードの何が問題になっていますか?
コード内のjmp
関数がWait_Clk_Ticks
割り込みを引き起こしていますか? ハードウェア割り込みを無効にするために使用されているcli
と言われています。ハードウェア割り込みを発生させますかsti
?jmp
コード:
; 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 の USB キーボードでこのコードを実行しています。
ご協力いただきありがとうございます :)