Код | .186 .model small .stack 100h
.data msgON db "ON",13,10,"$" msgOFF db "OFF",13,10,"$" msgCL db "CapsLock - ","$" msgNL db "NumLock - ","$" msgSL db "ScrollLock - ","$" .code IsCapsLockOn proc xor ax,ax ; Zero out the content of the AX register mov ah,02h ; Keyboard shift status function dw 16CDh ; Issue the interrupt shr al,06h ; Move the 7th bit to the rightmost position and al,01h ; Mask all other bits out ret ; Return to the calling procedure IsCapsLockOn endp IsNumLockOn proc xor ax,ax ; Zero out the content of the AX register mov ah,02h ; Keyboard shift status function dw 16CDh ; Issue the interrupt shr al,05h ; Move the 6th bit to the rightmost position and al,01h ; Mask all other bits out ret ; Return to the calling procedure IsNumLockOn endp IsScrollLockOn proc xor ax,ax ; Zero out the content of the AX register mov ah,02h ; Keyboard shift status function dw 16CDh ; Issue the interrupt shr al,04h ; Move the 5th bit to the rightmost position and al,01h ; Mask all other bits out ret ; Return to the calling procedure IsScrollLockOn endp
start: mov ax,@data mov ds,ax ;---------- Test CapsLock ---------- mov dx,offset msgCL mov ah,9 int 21h call IsCapsLockOn test al,al jne CLON_p
mov dx,offset msgOFF jmp PrintCL CLON_p: mov dx,offset msgON
PrintCL: mov ah,9 int 21h ;-----------------------------------
;---------- Test NumLock ----------- mov dx,offset msgNL mov ah,9 int 21h call IsNumLockOn test al,al jne NLON_p
mov dx,offset msgOFF jmp PrintNL NLON_p: mov dx,offset msgON
PrintNL: mov ah,9 int 21h ;-----------------------------------
;--------- Test ScrollLock --------- mov dx,offset msgSL mov ah,9 int 21h call IsScrollLockOn test al,al jne SLON_p
mov dx,offset msgOFF jmp PrintSL SLON_p: mov dx,offset msgON
PrintSL: mov ah,9 int 21h ;-----------------------------------
mov ax,0C07h int 21h mov ax, 4C00h int 21h end start
|
|