www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/09/09:46:25

From: ionicis AT geocities DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: int 16h/func 00h
Date: Fri, 07 Nov 1997 20:00:25 -0800
Organization: An Family
Lines: 43
Message-ID: <3463E3D8.968C53AE@geocities.com>
Reply-To: "DON'T CHANGE" <ionicis AT geocities DOT com>
NNTP-Posting-Host: 168.191.200.39
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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, &regs, &regs);
        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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019