delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/26/11:43:11

Date: Sun, 26 Sep 1999 15:08:38 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Ralph Reid <ralph AT fingers DOT shocking DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: 387 emulation problem
In-Reply-To: <7skr62$7ff@fingers.shocking.com>
Message-ID: <Pine.SUN.3.91.990926150202.2195A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 26 Sep 1999, Ralph Reid wrote:

> The 387 emulation library seems to have a problem.  I compiled the
> little program below with gcc2.95 and DJGPP, using the following
> command lines in an MSDOS 6.22 OS on a 486SX25:
> 
> gcc -s -O2 -Wall -c sqrt.c
> gcc -s -O2 -Wall -o sqrt.exe sqrt.o -lemu
> 
> No errors or warnings appear during compilation or linking.  Running
> the resulting program (SQRT.EXE) produces no output at all, and I was
> able to terminate the program with CTRL-C.

This is a known bug: any floating-point program that uses the emulator on 
Windows and issues WAIT or FWAIT instructions (most of the non-trivial FP 
programs use these instructions) will be trapped in an endless loop, 
because the emulation of WAIT/FWAIT doesn't increment the EIP.

On plain DOS, these problems don't happen, because WAIT/FWAIT don't 
trigger the no-fpu exception except on Windows.

The following source-level patch fixes this bug.  You will need to 
download the DJGPP sources (v2/djlsr202.zip) and rebuild the emulator 
(emu387.dxe) and/or the emulation library (libemu.a), after patching the 
sources with the Patch utility (v2gnu/pat25b.zip).

The bug is already solved in the DJGPP development tree, and v2.03 will 
be free from it.

*** src/libemu/src/emu387.c~0	Thu Jun 10 10:41:56 1999
--- src/libemu/src/emu387.cc	Wed Sep  1 21:04:58 1999
*************** int _emu_entry(jmp_buf _exception_state)
*** 3507,3513 ****
      eip++;
    if (*eip == 0x9b) // fwait
    {
! //    _exception_state->__eip++;
      return 0;
    }
    jmpval = setjmp(jumpbuf);
--- 3507,3514 ----
      eip++;
    if (*eip == 0x9b) // fwait
    {
!     eip++;
!     _exception_state->__eip = (unsigned long) eip;
      return 0;
    }
    jmpval = setjmp(jumpbuf);

- Raw text -


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