Mail Archives: djgpp/1997/11/09/09:46:25
Ok, what EXACTLY does that interrupt function do? I need to know
EXACTLY what it does when called. I'm very new to keyboard interrupts,
so below is a little code snippet I wrote as a test program for the
keyboard interrupt functions. I want the program to prompt the user via
the first printf(), and then call get_key(), and when the user presses a
key (because I assume that int6h/00h waits for the user to hit a key,
then returns the data), and then it tells the user what key was hit.
For some reason, the first printf() dosen't execute until the user hits
a key. When a key is hit, both printf()s execute. Why is this? BTW,
I'm using DJGPP.
Code snippet:
#include <stdio.h>
#include <dos.h>
#define KEYBOARD 0x16
char get_key() //the get_key functions, calls int 16h func 00h, and
returns the ASCII value
{
union REGS regs;
regs.h.ah = 0x00;
int86(KEYBOARD, ®s, ®s);
return regs.h.al;
}
main()
{
char key;
printf("Press a key"); //this should execute first, but it
dosen't
key = get_key();
printf("\nThe key your pressed was '%c'!", key);
return 0;
}
- Raw text -