2014-03-06 59 views
1

如何從獨立的NASM文件(無操作系統)打開和關閉鎖定鍵(大寫鎖定,數字鎖定和滾動鎖定)的狀態指示燈?更改鎖定鍵狀態指示燈

我知道xset可以在linux終端裏面使用,其他操作系統還有其他方法打開和關閉狀態燈。但是如何在沒有操作系統的情況下做到這一點?

回答

2

該獨立文件將打開Caps Lock,Scroll Lock和Num Lock鍵盤燈。

; 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 ; Output to the port. 

    pop ax  ; Get the setting from the stack. 
    out dx, al ; Output to the port. 

    pop dx  ; Restore 'dx'. 
    ret  ; Return. 

Code_Start: 
    mov al, 00000111b 
    call Switch_Kbd_Leds 


    jmp $  

times 510-($-$$) db 0 
dw 0xAA55  

它的工作方式是al包含位打開或關閉某些燈:

---- ---- ---- ---- ---- caps num scrl 
0 0 0 0 0 x x x 

這一行啓用的帽子,民,和Scroll Lock燈:

mov al, 00000111b 

最後,通過「Set/Reset LEDs」(0EDh)調用鍵盤端口60h更改值。