Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch a tab press in x86 assembly?

I'm working on a project in x86 assembly on Windows (MASM), and I need to somehow catch tab presses, but I'm not sure how to do that in assembly (I'm new to it).

I can get get user input with int 21h, but as far as I can tell that only works if the users types the data, then presses enter.

What I need is a way so that if the user presses the tab key, it will run a proc, and then from that proc I can handle what needs to happen. Is there a way to do this?

like image 676
Tyler Smith Avatar asked Nov 23 '25 00:11

Tyler Smith


2 Answers

If I understand correctly you can use:

mov ah,1 ; get char from keyboard

int 21h

cmp al, 9 ; 9 is ascii of tab

jnz Dont_Call

Call Proc_Name

Dont_Call:

(REST OF CODE)

like image 58
Bob Avatar answered Nov 26 '25 01:11

Bob


http://spike.scu.edu.au/~barry/interrupts.html#ah01

DOS INT 21h - DOS Function Codes

AH = 01h - READ CHARACTER FROM STANDARD INPUT, WITH ECHO

Return: AL = character read

Notes:

^C/^Break are checked
^P toggles the DOS-internal echo-to-printer flag
^Z is not interpreted, thus not causing an EOF if input is redirected character is echoed to standard output

See Also: AH=06h, AH=07h, AH=08h, AH=0Ah

like image 40
Robert Harvey Avatar answered Nov 26 '25 00:11

Robert Harvey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!