Mail Archives: djgpp/1999/03/01/14:01:23

Date: Mon, 1 Mar 1999 17:22:35 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Wojciech Zabolotny <wzab AT ise DOT pw DOT edu DOT pl>
cc: djgpp AT delorie DOT com
Subject: Re: HELP! Assembly language dual mode interrupt handler for djgpp program
In-Reply-To: <>
Message-ID: <Pine.SUN.3.91.990301171051.24475E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Mon, 1 Mar 1999, Wojciech Zabolotny wrote:

> The interrupts rate is so high (up to 20 kHZ), that I have to 
> install both real mode and protected mode handlers.

Are you sure?  Did you try to get away with a protected-mode handler 
alone?  (See section 18.11 of the FAQ for some hints.)  The dual RM/PM 
setup is a lot of work (see below), so you want to be sure you actually 
need it before you embark on that journey...

> I couldn't find anything about using the assembly language interrupt
> handlers. How to write them, to interface them smoothly with the rest
> of C program?

What smooth interface did you have in mind, except accessing the 
data of the real-mode handler from protected mode?

> How to access handler's data from the C program.

Allocate a buffer in conventional memory and use methods from sections 
18.2 and 18.4 of the FAQ to access them.  Specifically, _farpeek/poke and 
dosmemget/put.  This is how the PM handler can access the data of the RM 
one.  The reverse is not possible: real-mode code cannot access memory 
above 1MB mark.  So you need to maintain all interface variables in 
conventional memory where both handlers can get at them; real-mode code 
will access them as far data, with segment:offset.

> How to write "dual mode handler" (code which may be executed both in
> real and in protected mode)?

No, you need to write write two handlers: one each for real and protected
mode.  The real-mode one needs to be written as real-mode machine code (it
will run completely in real mode), copied into a buffer in conventional
memory that you allocate, and set as the real-mode handler for the 
interrupt.  As for protected-mode handler, see the sources
of Allegro and the file src/libc/go32/exceptn.S from for

- Raw text -

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