delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/14/18:16:00

Message-ID: <3464918A.34B9@compuserve.com>
Date: Sat, 08 Nov 1997 11:23:04 -0500
From: Laurent Turcotte <lturcott AT compuserve DOT com>
MIME-Version: 1.0
Subject: Re: int 16h/func 00h
References: <3463E3D8 DOT 968C53AE AT geocities DOT com>
Newsgroups: comp.os.msdos.djgpp
Lines: 40
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

ionicis AT geocities DOT com wrote:
> 
> 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 removed

Interesting  !
I believe that int 16h/00h does what you think it should
It wait for a key an then return with the ascii character in AL reg 
(and scan code in AH reg)

Your problem if with printf .. well .. it is not realy a problem !
printf is line buffered
You simply need to add a "\n" at the END of the string .. or ..
add a call to fflush(stdio); after printf to send the buffer to the
screen !

that is why the first printf is called but does not show until the
second printf

if you ask why does the second printf show, there is no "\n" at the end
...

The second printf show when the program terminate and close stdout !
if you want a proof of this call _exit instead of return at the end of
the prog 
and you will see !

note:  
_exit() does not clean up while
exit() does !

- Raw text -


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