delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/18/08:56:50

Date: Sun, 18 Jun 2000 15:56:14 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alvin Lau <alvin_lau AT yahoo DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Inline assembly code problem
In-Reply-To: <394cb48b$1@newsgate.hknet.com>
Message-ID: <Pine.SUN.3.91.1000618155059.16892C-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 18 Jun 2000, Alvin Lau wrote:

> When I run this program, I got a message "General Protection Fault".
> I tried to run this program step by step in RHIDE, it returns a message
> "Program has received signal: SIGABRT, Aborted" while running the statement
> asm("iret\n");

This program has at least two grave bugs:

  1) You don't lock all the code and data touched by the interrupt handler;

  2) You register your function as an interrupt handler directly, without 
     going through an iret wrapper first.

The second problem is probably the most serious one: it is not enough to 
put asm("iret") into a normal C function to make it a valid interrupt 
handler.  You need to create a run-time environment expected by the code 
produced by GCC; without that, the segment registers will not be set up 
correctly, and the code will surely GP Fault.

I suggest to take a look at section 18.9 of the DJGPP FAQ, it explains 
the necessary steps for hooking a hardware interrupt at some length.  If 
something there is unclear, please ask specific questions.

- Raw text -


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