×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

keyboard input

keyboard input

keyboard input

(OP)
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

RE: keyboard input

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."

RE: keyboard input

(OP)
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?

RE: keyboard input

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
    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
http://www.geocities.com/thevhbcompany/
Don't worry what people think about you. They're too busy wondering what you think about them.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close