Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Running a Program on the Target Running with or without Paging Installing Hardware Interrupt Handlers Catching NULL Pointer Assignments Running without Run-Time System Configuration for Debug and Release Builds Loading DLLs through a File System Using the MetaWINDOW Graphics Library Using the 387 Emulator Custom MP Floating Pointer Structure Compiling and Linking with On Time RTOS-32 |
Using the 387 EmulatorRTTarget-32 contains the 387 Floating Point Emulator RTEmu. Although RTEmu is bundled with RTTarget-32, it is a separate product with different licensing terms. This emulator has been derived from the DJGPP emulator EMU387 version 1.12, Copyright (c) DJ Delorie. DJGPP is released under the GNU General Public Licensing terms, which also apply to this emulator. Please read the complete licensing terms given later in this section before considering the use of this emulator. Two versions of the emulator are supplied: a single-thread version and a multi-thread version. The single-thread version can be used in a multitasking system only if the emulator's context is swapped with FNSAVE/FRSTOR in every task switch. The multi-thread version is completely reentrant on the task level and requires no swapping. The reentrant emulator is compatible with RTKernel-32's floating point driver Fltemumt.lib. Both emulator versions are non-reentrant for interrupt handlers. If you intend to do floating point calculations in interrupt handlers, FNSAVE/FRSTOR are required to preserve the foreground thread's floating point context. The emulator never disables interrupts. Thus, it is well-suited for real-time systems requiring a low interrupt latency. Please note that the 387 emulator only supports 387 instructions. An application using the emulator may not use any MMX, SSE, SSE2, AVX, etc instructions. In addition to the emulator, source file Fpexh.c contains a sample exception handler for 387 exceptions. It can be used for the emulator as well as for actual floating point hardware. It traps int 16 and displays some information about the exception on the screen. Then it continues, allowing the FPU or emulator to take its default action. Fpexh.c is recommended only for debugging. Real applications should mask all floating point exceptions. Linking the Emulator in C/C++ ProgramsSince the run-time systems contain floating point instructions in their startup code, the emulator should be installed before the startup code executes. This can be accomplished using RTTarget-32's Init directive in the application's configuration file. Example:Init _RTEmuInit or, for Microsoft C: Init RTEmuInit Function RTEmuInit is exported by module Rtemu.obj, which must be linked to the program. It installs the emulator's exception 7 handler as a trap gate. If you must call several functions at init time, you must write your own exported Init function, which in turn calls all Init functions required by your program. Applications which can guarantee that no floating point operations are required by application code before main is called (e.g., in constructors of global objects, DLL initialization code, etc.), can alternatively call RTEmuInit explicitly in function main, followed by fpreset. Apart from module Rtemu.obj, you must also link Rtemu.lib (single-thread) or Rtemumt.lib (multithread). Please note that the multithread library requires TLS data. If you use RTKernel-32, you must select an appropriate floating point driver. For Rtemumt.lib, use driver FLTEMUMT; for Rtemu.lib, use driver FLT387. There are no source code modifications required to use the emulator. You only need to link it (Rtemu.obj + Rtemu.lib or Rtemumt.lib) and make sure it is initialized through the RTTarget-32 Init directive. If you use the multithread version, be sure to include all sections generated for TLS by the compiler and linker. If you want to use the floating point exception handler included with the emulator, install it using the following call: #include <rttarget.h> int main(void) { RTFPInstallExHandler(); ... To make sure you actually see all exceptions, unmask all FPU exceptions in the development phase of your project with: _control87(0, 0xFFFFFFFF); Demo program EmuDemo shows how to use the emulator. Linking the Emulator in Delphi ProgramsUsing the emulator in Pascal programs is much simpler. Just add unit RTEmu (or RTEmuMT for multithread support) to the main program's USES clause. The emulator will be installed automatically by the unit's initialization code. Only if floating point instructions are executed at an earlier stage (e.g., in the initialization code of a statically referenced DLL), you must call RTEmuInit as an Init function. To do this, add Init RTEmuInit to your program's configuration file. Demo program EmuDemo shows how to use the emulator. Emulator Licensing TermsAlthough you have obtained this floating point emulator bundled with RTTarget-32, it is a separate product with different licensing terms. On Time Informatik GmbH and the original author of the emulator, DJ Delorie, supply this software without any warranty. The emulator is made available to all RTTarget-32 users free of charge. It may be further distributed under the terms of the GNU General Public License, with the following exceptions:
Please refer to file Source\Emu\Copying for the GNU General Public License. Using the MetaWINDOW Graphics Library
|