⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 linux 内核源代码
💻
📖 第 1 页 / 共 2 页
字号:
 +---------------------------------------------------------------------------+ |  wm-FPU-emu   an FPU emulator for 80386 and 80486SX microprocessors.      | |                                                                           | | Copyright (C) 1992,1993,1994,1995,1996,1997,1999                          | |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      | |                       Australia.  E-mail billm@melbpc.org.au              | |                                                                           | |    This program is free software; you can redistribute it and/or modify   | |    it under the terms of the GNU General Public License version 2 as      | |    published by the Free Software Foundation.                             | |                                                                           | |    This program is distributed in the hope that it will be useful,        | |    but WITHOUT ANY WARRANTY; without even the implied warranty of         | |    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          | |    GNU General Public License for more details.                           | |                                                                           | |    You should have received a copy of the GNU General Public License      | |    along with this program; if not, write to the Free Software            | |    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              | |                                                                           | +---------------------------------------------------------------------------+wm-FPU-emu is an FPU emulator for Linux. It is derived from wm-emu387which was my 80387 emulator for early versions of djgpp (gcc undermsdos); wm-emu387 was in turn based upon emu387 which was written byDJ Delorie for djgpp.  The interface to the Linux kernel is based uponthe original Linux math emulator by Linus Torvalds.My target FPU for wm-FPU-emu is that described in the Intel486Programmer's Reference Manual (1992 edition). Unfortunately, numerousfacets of the functioning of the FPU are not well covered in theReference Manual. The information in the manual has been supplementedwith measurements on real 80486's. Unfortunately, it is simply notpossible to be sure that all of the peculiarities of the 80486 havebeen discovered, so there is always likely to be obscure differencesin the detailed behaviour of the emulator and a real 80486.wm-FPU-emu does not implement all of the behaviour of the 80486 FPU,but is very close.  See "Limitations" later in this file for a list ofsome differences.Please report bugs, etc to me at:       billm@melbpc.org.auor     b.metzenthen@medoto.unimelb.edu.auFor more information on the emulator and on floating point topics, seemy web pages, currently at  http://www.suburbia.net/~billm/--Bill Metzenthen  December 1999----------------------- Internals of wm-FPU-emu -----------------------Numeric algorithms:(1) Add, subtract, and multiply. Nothing remarkable in these.(2) Divide has been tuned to get reasonable performance. The algorithm    is not the obvious one which most people seem to use, but is designed    to take advantage of the characteristics of the 80386. I expect that    it has been invented many times before I discovered it, but I have not    seen it. It is based upon one of those ideas which one carries around    for years without ever bothering to check it out.(3) The sqrt function has been tuned to get good performance. It is based    upon Newton's classic method. Performance was improved by capitalizing    upon the properties of Newton's method, and the code is once again    structured taking account of the 80386 characteristics.(4) The trig, log, and exp functions are based in each case upon quasi-    "optimal" polynomial approximations. My definition of "optimal" was    based upon getting good accuracy with reasonable speed.(5) The argument reducing code for the trig function effectively uses    a value of pi which is accurate to more than 128 bits. As a consequence,    the reduced argument is accurate to more than 64 bits for arguments up    to a few pi, and accurate to more than 64 bits for most arguments,    even for arguments approaching 2^63. This is far superior to an    80486, which uses a value of pi which is accurate to 66 bits.The code of the emulator is complicated slightly by the need toaccount for a limited form of re-entrancy. Normally, the emulator willemulate each FPU instruction to completion without interruption.However, it may happen that when the emulator is accessing the usermemory space, swapping may be needed. In this case the emulator may betemporarily suspended while disk i/o takes place. During this timeanother process may use the emulator, thereby perhaps changing staticvariables. The code which accesses user memory is confined to fivefiles:    fpu_entry.c    reg_ld_str.c    load_store.c    get_address.c    errors.cAs from version 1.12 of the emulator, no static variables are used(apart from those in the kernel's per-process tables). The emulator istherefore now fully re-entrant, rather than having just the restrictedform of re-entrancy which is required by the Linux kernel.----------------------- Limitations of wm-FPU-emu -----------------------There are a number of differences between the current wm-FPU-emu(version 2.01) and the 80486 FPU (apart from bugs).  The differencesare fewer than those which applied to the 1.xx series of the emulator.Some of the more important differences are listed below:The Roundup flag does not have much meaning for the transcendentalfunctions and its 80486 value with these functions is likely to differfrom its emulator value.In a few rare cases the Underflow flag obtained with the emulator willbe different from that obtained with an 80486. This occurs when thefollowing conditions apply simultaneously:(a) the operands have a higher precision than the current setting of the    precision control (PC) flags.(b) the underflow exception is masked.(c) the magnitude of the exact result (before rounding) is less than 2^-16382.(d) the magnitude of the final result (after rounding) is exactly 2^-16382.(e) the magnitude of the exact result would be exactly 2^-16382 if the    operands were rounded to the current precision before the arithmetic    operation was performed.If all of these apply, the emulator will set the Underflow flag but a real80486 will not.NOTE: Certain formats of Extended Real are UNSUPPORTED. They areunsupported by the 80486. They are the Pseudo-NaNs, Pseudoinfinities,and Unnormals. None of these will be generated by an 80486 or by theemulator. Do not use them. The emulator treats them differently indetail from the way an 80486 does.Self modifying code can cause the emulator to fail. An example of suchcode is:          movl %esp,[%ebx]	  fld1The FPU instruction may be (usually will be) loaded into the pre-fetchqueue of the CPU before the mov instruction is executed. If thedestination of the 'movl' overlaps the FPU instruction then the bytesin the prefetch queue and memory will be inconsistent when the FPUinstruction is executed. The emulator will be invoked but will not beable to find the instruction which caused the device-not-presentexception. For this case, the emulator cannot emulate the behaviour ofan 80486DX.Handling of the address size override prefix byte (0x67) has not beenextensively tested yet. A major problem exists because using it invm86 mode can cause a general protection fault. Address offsetsgreater than 0xffff appear to be illegal in vm86 mode but are quiteacceptable (and work) in real mode. A small test program developed tocheck the addressing, and which runs successfully in real mode,crashes dosemu under Linux and also brings Windows down with a generalprotection fault message when run under the MS-DOS prompt of Windows3.1. (The program simply reads data from a valid address).The emulator supports 16-bit protected mode, with one difference froman 80486DX.  A 80486DX will allow some floating point instructions towrite a few bytes below the lowest address of the stack.  The emulatorwill not allow this in 16-bit protected mode: no instructions areallowed to write outside the bounds set by the protection.----------------------- Performance of wm-FPU-emu -----------------------Speed.-----The speed of floating point computation with the emulator will dependupon instruction mix. Relative performance is best for the instructionswhich require most computation. The simple instructions are adverselyaffected by the FPU instruction trap overhead.Timing: Some simple timing tests have been made on the emulator functions.The times include load/store instructions. All times are in microsecondsmeasured on a 33MHz 386 with 64k cache. The Turbo C tests were underms-dos, the next two columns are for emulators running with the djgppms-dos extender. The final column is for wm-FPU-emu in Linux 0.97,using libm4.0 (hard).function      Turbo C        djgpp 1.06        WM-emu387     wm-FPU-emu   +          60.5           154.8              76.5          139.4   -          61.1-65.5      157.3-160.8        76.2-79.5     142.9-144.7   *          71.0           190.8              79.6          146.6   /          61.2-75.0      261.4-266.9        75.3-91.6     142.2-158.1 sin()        310.8          4692.0            319.0          398.5 cos()        284.4          4855.2            308.0          388.7 tan()        495.0          8807.1            394.9          504.7 atan()       328.9          4866.4            601.1          419.5-491.9 sqrt()       128.7          crashed           145.2          227.0 log()        413.1-419.1    5103.4-5354.21    254.7-282.2    409.4-437.1 exp()        479.1          6619.2            469.1          850.8The performance under Linux is improved by the use of look-ahead code.The following results show the improvement which is obtained underLinux due to the look-ahead code. Also given are the times for theoriginal Linux emulator with the 4.1 'soft' lib. [ Linus' note: I changed look-ahead to be the default under linux, as   there was no reason not to use it after I had edited it to be   disabled during tracing ]            wm-FPU-emu w     original w            look-ahead       'soft' lib   +         106.4             190.2   -         108.6-111.6      192.4-216.2   *         113.4             193.1   /         108.8-124.4      700.1-706.2 sin()       390.5            2642.0 cos()       381.5            2767.4 tan()       496.5            3153.3 atan()      367.2-435.5     2439.4-3396.8

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -