Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keyboard input 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I'm working on a program that takes a keypress as input and outputs the scan code, ASCII code, and whether any control keys (like shift, ctrl, numlock, etc.) are pressed. I've got the scan code and ASCII code working I think, but I'm not sure how to check what control keys are pressed. I can get the "keyboard status byte" using:
mov ah,12
int 16h
it returns for some reason 13 bytes, I think I have to look at the lower 8 bytes regardless. my question is, how do I check which bytes are set, and do I have to run through the process once for each byte?

thanks for any help
 
Is that bytes or BITS?

"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
sorry, bits. I output the contents of the status byte (or what I thought was a byte), and 13 bits are printed. the lower 8 bits seem to correspond to the description in my textbook, but I'm not sure what the other 5 bits are for. in any case, I'm not sure how to actually read the bits. from other programming I've done (not in assembly) I'm thinking of using an AND operation on the bits, but I'm not sure what to AND with and if that is the correct way, wouldn't I have to do it 8 times, as well as testing if the byte is 0 or 1?
 
You can indeed use the AND operator and you can generalize the whole procedure if you use SHL (shift left) on the test register.
Example: test the byte 01010110
Code:
    01010110
AND 00000001   (test register)
------------
    00000000   --> bit 0 not set
    
    00000001   (test register)
SHL        1
------------
    00000010

and test again:
    01010110
AND 00000010   (test register)
------------
    00000010   --> bit 1 set

continue this until you've tested all the bits.
Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top