delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/01/13/03:49:38

Date: Tue, 13 Jan 1998 10:49:08 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: DJ Delorie <dj AT delorie DOT com>
cc: Anthony DOT Appleyard AT umist DOT ac DOT uk, djgpp-workers AT delorie DOT com
Subject: Re: [MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk: Hooking interrupt 9 : a DIFF]
In-Reply-To: <199801122321.SAA13895@delorie.com>
Message-ID: <Pine.SUN.3.91.980113104759.5496F-100000@is>
MIME-Version: 1.0

On Mon, 12 Jan 1998, DJ Delorie wrote:

>   Herewith suggested alterations to make it easier for a user to hook
> interrupt 9 to get the keyboard events raw:-

Some comments:

> + extern void (*userskeyboardhandler)(int X);

Why is this added to go32cbrk.c?

It *should* be added to some header, however, so an application that
uses this feature will have a prototype.  I suggest <sys/exceptn.h>.

Also, the name of this user-defined callback should begin with an
underscore, since it (the name) gets linked into every application and
will pollute the ANSI/POSIX name space.  I suggest something like
`__djgpp_kbd_callback'.

> + 	sti				/* disable interrupts */

Charles, isn't this dangerous/slow/unnecessary in the keyboard
handler?

> + 	movw   __go32_info_block+26,%ax
> + 	movw   %ax,%fs			/* FS = _dos_ds */
> + 	.byte  0x64			/* use segment reg FS */
> + 	movw   0417,%ax			/* [0x417] [0x418] are shift status */

The current keyboard handler already sets its DS to point to
conventional memory, with this line:

	movw	%cs:___djgpp_dos_sel, %ds

Isn't it better to just move this line a couple of lines up, so it
takes effect before _calluserskeyboardhandler is called, instead of
doing it twice and bloating the code?

Also, how about some minimal documentation?

- Raw text -


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