www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/09/15:53:54

Date: Wed, 9 Sep 1998 18:55:49 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Tal Lavi <ranla AT post DOT tau DOT ac DOT il>
cc: djgpp AT delorie DOT com
Subject: Re: Making a keyboard handler
In-Reply-To: <35F6CBD0.303A@post.tau.ac.il>
Message-ID: <Pine.SUN.3.91.980909184621.2901H-100000@is>
MIME-Version: 1.0

On Wed, 9 Sep 1998, Tal Lavi wrote:

> It is said to be due to the slowly implemented getch() routine.

The problem is not that `getch' is slow, the problem is that it waits for 
the user to hit a key, and all that time is recorded as if your program 
is parked inside `__dpmi_int'.

A modern CPU can run circles around even the fastest human typists, so it 
doesn't make sense (IMHO) to time a program that calls `getch' as part of 
its operation: your execution profile will not tell anything interesting.

> I'd like to know in which of the ways(RMode handler, PMode handler,
> ?both?, etc.) should I choose.

Always begin with the PM handler and only install a real-mode one if PM 
is not enough to catch up.  In general, you should never need a real-mode 
handler for the keyboard, since it is only required for interrupt rates 
in excess of several KHz, and no keyboard is that fast.

> I also read in the FAQ that the handler should be written in ASM, did
> they mean the inline ASM in DJGPP?

No, ``they'' (that's me, btw ;-) meant to write it in pure assembly, as 
a .S file.

> If so, how will I be able to find the address of the beginning of the 
> asm command?

The beginning is easy: it's the name of the function.  What's hard is the 
size of a C function (needed to lock its code).

> This is my first attempt of a very tiime-critical application, which
> means that it is also my first attempt of creating a keyboard handler.

I'm not sure you indeed need a hardware interrupt handler.  It might be a 
good idea to describe why do you think you need it, so people here could 
advise.

If you do need to install a handler, you might consider using the Allegro 
library which already has a handler ready for you.

- Raw text -


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