|
-
Nov 22nd, 2004, 04:48 PM
#1
Thread Starter
Frenzied Member
Need some help with keyboard BIOS Services interrupts->
Whenever I use INT 16h, 1h (Keyboard BIOS Services - Get Keystroke Status) I only get the status for the first key pressed. When calling the function again I still get the status for the first key pressed while having pressed other keys. Here is the code I am using:
(I think only the part up to the ".ScanCode db "0000", 13, 10, "$"" line is important here)
Code:
ORG 256
Main:
; Get scan code and ASCII character of any key currently being pressed.
MOV ah, 1 ; Get keyboard status.
INT 22 ; Keyboard BIOS services.
; Convert scan code and ASCII character to user readable format.
PUSH ax
CALL cv256to16
POP DWORD [.ScanCode]
; Displays key scan code and ASCII character.
MOV ah, 9 ; Print string.
MOV dx, .ScanCode ;
INT 33 ; DOS functions interrupt.
JMP Main
.ScanCode db "0000", 13, 10, "$"
;+-------------------------------------------------------------------------------+
;| Convert Byte to Hexadecimal - Converts byte values to hexadecimal number. |
;| [Parameters in:] |
;| Name: Description: Type: |
;| Number Byte values to be converted. 2 Byte number (by value) |
;| Parameters out:] |
;| Name: Description: Type: |
;| Hexadecimal Converted hexadecimal number. 4 Byte string (by value) |
;+-------------------------------------------------------------------------------+
cv256to16:
POP WORD [.ReturnAddress]
POP WORD [.ByteVal]
MOV bx, 0 ; Digit = 0
MOV cl, 12 ; BitShift = 12
MOV dx, 64410 ; BitMask = 64410
.GetHexDigits:
MOV ax, [.ByteVal] ;
AND ax, dx ; Extract a 4 bit value from the byte values.
SHR ax, cl ;
MOV si, ax ;
MOV al, [.HexDigits + si] ; Get the hexadecimal digit for the 4 bit value.
MOV [.HexNumber + bx], al ;
SHR dx, 4 ; Adjust BitMask
SUB cl, 4 ; and BitShift.
INC bx ; Next digit.
CMP bx, 4 ; Check for last digit.
JNE .GetHexDigits
PUSH DWORD [.HexNumber]
PUSH WORD [.ReturnAddress]
RET
.ByteVal dw 0
.HexNumber db "0000"
.HexDigits db "0123456789ABCDEF"
.ReturnAddress dw 0
Do I need to reset something after having called int 16h, 1h before calling the interrupt again?
Notes:
1 I have tried using Extended Get Keystroke Status (INT 16h, 11h) supposedly the ZF flag will indicate whether the key is being or was being pressed.
2 In my code all numbers are written in decimal format which means that in the code int 16h is referred to as int 22.
3 I looked up all the information about int 22h, 1h using Helppc.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|