fp.txt
来自「汇编编程艺术」· 文本 代码 · 共 745 行 · 第 1/2 页
TXT
745 行
Floating Point Routines
-----------------------
The floating point routines provide a basic floating point package for
80x86 assembly language users. The floating point package deals with
four different floating point formats: IEEE 32-bit, 64-bit, and 80-bit
formats, and an internal 81-bit format. The external formats mostly
support the IEEE standard except for certain esoteric values such as
denormalized numbers, NaNs, infinities, and other such cases.
The package provides two "pseudo-registers", a floating point accumulator
and a floating point operand. It provides routines to load and store these
pseudo-registers from memory operands (using the various formats) and then
all other operations apply to these two operands. All computations use the
internal 81-bit floating point format. The package automatically converts
between the internal format and the external format when loading and storing
values.
Do not write code which assumes the internal format is 81 bits. This format
will change in the near future when I get a chance to add guard bits to
all the computations. If your code assumes 81 bits, it will break at that
point. Besides, there is no reason your code should count on the size of
the internal operations anyway. Stick with the IEEE formats and you'll
be much better off (since your code can be easily upgraded to deal with
numeric coprocessors).
WARNING: These routines have not been sufficiently tested as of 10/10/91.
Use them with care. Report any problems with these routines to Randy Hyde
via the electronic addresses provided in this document or by sending a
written report to UC Riverside. As I get more time, I will further test
these routines and add additional functions to the package.
*** Randy Hyde
Routine: lsfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a single precision (32-bit) value to load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
lsfpa
Description: LSFPA loads a single precision floating point value into the
internal floating point accumulator. It also converts the
32-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: ssfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a single precision (32-bit) value where
this routine should store the floating point acc.
Registers on return: None
Flags affected: Carry set if conversion error.
Example of Usage:
les di, FPValue
ssfpa
Description: SSFPA stores the floating point accumulator into a single
precision variable in memory (pointed at by ES:DI). It
converts the value from the 81-bit format to the 32-bit
value before storing the result. The 64-bit mantissa used
by the FP package is rounded to 24 bits during the store.
The exponent could be out of range. If this occurs, SSFPA
returns with the carry flag set.
Include: stdlib.a or fp.a
Routine: ldfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a double precision (64-bit) value to load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
ldfpa
Description: LDFPA loads a double precision floating point value into the
internal floating point accumulator. It also converts the
64-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: sdfpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a double precision (64-bit) value where
this routine should store the floating point acc.
Registers on return: None
Flags affected: Carry set if conversion error.
Example of Usage:
les di, FPValue
sdfpa
Description: SDFPA stores the floating point accumulator into a double
precision variable in memory (pointed at by ES:DI). It
converts the value from the 81-bit format to the 64-bit
value before storing the result. The 64-bit mantissa used
by the FP package is rounded to 51 bits during the store.
The exponent could be out of range. If this occurs, SDFPA
returns with the carry flag set.
Include: stdlib.a or fp.a
Routine: lefpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at an extended precision (80-bit) value to
load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
lefpa
Description: LEFPA loads an extended precision floating point value into
the internal floating point accumulator. It also converts the
80-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: lefpal
----------------
Category: Floating point Routine
Registers on entry: CS:RET points at an extended precision (80-bit) value to
load
Registers on return: None
Flags affected: None
Example of Usage:
lefpal
dt 1.345e-3
Description: LEFPAL loads an extended precision floating point value into
the internal floating point accumulator. It also converts the
80-bit format to the internal 81-bit format used by the
floating point package.
Unlike LEFPA, LEFPAL gets its operand directly from the code
stream. You must follow the call to lefpal with a ten-byte
(80-bit) floating point constant.
Include: stdlib.a or fp.a
Routine: sefpa
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at an extended precision (80-bit) value
where this routine should store the floating point acc.
Registers on return: None
Flags affected: Carry set if conversion error.
Example of Usage:
les di, FPValue
sefpa
Description: SEFPA stores the floating point accumulator into an extended
precision variable in memory (pointed at by ES:DI). It
converts the value from the 81-bit format to the 80-bit
value before storing the result.
The exponent could be out of range. If this occurs, SEFPA
returns with the carry flag set.
Include: stdlib.a or fp.a
Routine: lsfpo
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a single precision (32-bit) value to load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
lsfpo
Description: LSFPA loads a single precision floating point value into the
internal floating point operand. It also converts the
32-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: ldfpo
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at a double precision (64-bit) value to load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
ldfpo
Description: LDFPO loads a double precision floating point value into the
internal floating point operand. It also converts the
64-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: lefpo
---------------
Category: Floating point Routine
Registers on entry: ES:DI points at an extended precision (80-bit) value to
load
Registers on return: None
Flags affected: None
Example of Usage:
les di, FPValue
lefpo
Description: LEFPO loads an extended precision floating point value into
the internal floating point operand. It also converts the
80-bit format to the internal 81-bit format used by the
floating point package.
Include: stdlib.a or fp.a
Routine: lefpol
----------------
Category: Floating point Routine
Registers on entry: CS:RET points at an extended precision (80-bit) value to
load
Registers on return: None
Flags affected: None
Example of Usage:
lefpal
dt 1.345e-3
Description: LEFPOL loads an extended precision floating point value into
the internal floating point operand. It also converts the
80-bit format to the internal 81-bit format used by the
floating point package.
Unlike LEFPO, LEFPOL gets its operand directly from the code
stream. You must follow the call to lefpal with a ten-byte
(80-bit) floating point constant.
Include: stdlib.a or fp.a
Routine: itof
--------------
Category: Floating point Routine
Registers on entry: AX contains a signed integer value
Registers on return: None
Flags affected: None
Example of Usage:
mov ax, -1234
itof
Description: ITOF converts the 16-bit signed integer in AX to a floating
point value, storing the result in the floating point
accumuator.
Include: stdlib.a or fp.a
Routine: utof
--------------
Category: Floating point Routine
Registers on entry: AX contains an unsigned integer value
Registers on return: None
Flags affected: None
Example of Usage:
mov ax, -1234
itof
Description: UTOF converts the 16-bit unsigned integer in AX to a floating
point value, storing the result in the floating point
accumuator.
Include: stdlib.a or fp.a
Routine: ultof
---------------
Category: Floating point Routine
Registers on entry: DX:AX contains an unsigned 32-bit integer value
Registers on return: None
Flags affected: None
Example of Usage:
mov dx, word ptr val32+2
mov ax, word ptr val32
ultof
Description: ULTOF converts the 32-bit unsigned integer in DX:AX to a
floating point value, storing the result in the floating
point accumuator.
Include: stdlib.a or fp.a
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?