I am not sure if anyone here knows PC Assembly, but I have a project due tomorrow for my Assembly langue class. I just need to know how do I find out if some pressed up or down arrow keys on the keyboard. I am able to detect the key being pressed but I dont know what key is being pressed when it is not a character. Can anyone help me with this?
Announcement
Collapse
No announcement yet.
Quick PC Assembly langue question
Collapse
X
-
Quick PC Assembly langue question
Tags: None
-
I ran the program in debug. The value I got was zero for both up and down keys. I have an ASCII table of values and it did not work when I use it in the program
Comment
-
Originally posted by Dr. A. Cula
I ran into the same problem years ago, but I was using C. IIRC, the solution was to test the keyboard again when I got a 0.
Comment
-
Right now since I cant figure this out, I am using the w key for up and the s key for down.
Comment
-
Maybe you are checking the wrong register? You need to post some code. For example:
Code:mov ax, 0 ; parameter 1 mov bx, 2 ; parameter 2 int 21h ; interrupt mov dx, ax ; put result into dx
Comment
-
Here is a short sample of the code I am using:
Code:mov ah,01h ;using 1h so that the program does not wait for key to be pressed, it is only checking to see if it is int 16h ;do the interrupt jz mainloop ;Zero flag is set if no key is pressed ;go on to check what key was pressed and process input
Comment
-
I found some (rather sketchy) doc that seems to confirm that int 0x16, function 0x01 returns 0 in AL for function keys (http://www.htl-steyr.ac.at/~morg/pci...s/inte1at0.htm).
But it also says that AH contains that key's scan code and I think you should use that if AL is 0. Here is a list of keyboard scan codes: http://www.cs.cmu.edu/afs/cs/user/ra...WWW/files.html (I found it in the part A archive, in the INTERRUP.A file). Also see the INTERRUP.D file for some more info on int 0x16.The monkeys are listening.
Comment
-
Originally posted by Dr. A. Cula
I found some (rather sketchy) doc that seems to confirm that int 0x16, function 0x01 returns 0 in AL for function keys (http://www.htl-steyr.ac.at/~morg/pci...s/inte1at0.htm).
But it also says that AH contains that key's scan code and I think you should use that if AL is 0. Here is a list of keyboard scan codes: http://www.cs.cmu.edu/afs/cs/user/ra...WWW/files.html (I found it in the part A archive, in the INTERRUP.A file). Also see the INTERRUP.D file for some more info on int 0x16.
Comment
-
I'm quite sure you need to check a second value for function keys like the arrow keys. I don't know assembly at all, but I know that in BASIC and other languages that pick up ASCII for arrow keys, you get a 0 and then another value for keyboards (appears visually with a ^, like ^M for enter).<Reverend> IRC is just multiplayer notepad.
I like your SNOOPY POSTER! - While you Wait quote.
Comment
-
I ran it in debug and the value was stored in AH, thanks Dr. A. Cula that was a real big help.
Comment
-
I just put it into my program and it works perfect.
Comment
Comment