delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/05/13:45:47

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: keyboard problem!
Date: Sat, 06 Dec 1997 08:10:08 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 53
Message-ID: <34890860.5561@cs.com>
References: <65iu4r$ca1$1 AT yeppa DOT connect DOT com DOT au> <6608mn$g5u AT mtinsc05 DOT worldnet DOT att DOT net> <3485301B DOT 3A13 AT trash DOT lip6 DOT fr> <34878CD0 DOT 3AB5 AT mailexcite DOT com>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp218.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Doug Gale wrote:
> 
> There is a big difference!
> 
> The BIOS call always reads the keyboard.
> 
> getch() reads from standard input, which may have been redirected at the
> command-line to read from a device or a file.

You might be right, if you were talking about getchar().  But getch() is
a conio function that reads a single
keystroke from the BIOS keyboard interrupt.  The relevant code is in
src/libc/pc_hw/co80/conio.c:

int
getch(void)
{
  __dpmi_regs regs;
  int c;
  if (char_avail)
  {
    c = ungot_char;
    char_avail = 0;
  }
  else
  {
    regs.x.ax = 0x0700;
    __dpmi_int(0x21, &regs);
    c = regs.h.al;
  }
  return(c);
}

I don't know if this is functionally equivalent to reading from 0x16.

To the original poster:  I suggest you look in the DJGPP sources to see
exactly how the conio functions handle all the various keyboard-related
issues.  Also, a big tip:  use __dpmi_int instead of int86 for most
interrupt-related functions.  Not only does it support more functions,
but it also handles things like zeroing the stack pointer and other
overhead work.

hth

-- 
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? C++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---)
O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++
e(*)>++++ h!() !r !y+()
------END GEEK CODE BLOCK------

- Raw text -


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