Intel 80286, 80287 manual PLlM-286 Built-In Procedures

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 431
Image 431

PROGRAMMING NUMERIC APPLICATIONS

PL/M-286

ProgrammersinPLfM-286 can access a very useful subset of the 80287's numeric capabilities. The PLfM-286 REAL data type corresponds to the NPX's short real (32-bit) format. This data type provides

arange of about 8.43*10-37~ ABS(X) :$ 3.38*1038, with about seven significant decimal digits. This representation is adequate for the data manipulated by many microcomputer applications.

The utility of the REAL data type is extended by the PLfM-286 compiler's practice of holding inter- mediate results in the 80287's temporary real format. This means that the-'full range and precision of the processor are utilized for intermediate results. Underflow, overflow, and rounding errors are most likely to occur during intermediate computations rather than during calculation of an expression's final result. Holding intermediate results in temporary real format greatly reduces the likelihood of overflow and underflow and eliminates roundoff as a serious source of error until the final assignment of the result is performed.

The compiler generates 80287 code to evaluate expressions that contain REAL data types, whether variables or constants or both. This means that addition, subtraction, multiplication, division, compar- ison, and assignment of REALs will be performed by the NPX. INTEGER expressions, on the other hand, are evaluated on the CPU.

Five built-in procedures (table 2-15) give the PLfM-286 programmer access to 80287 functions manip- ulated by the processor control instructions. Prior to any arithmetic operations, a typical PLfM-286 program will set up the NPX after power up using the INIT$REAL$MATH$UNIT procedure and then issue SET$REAL$MODE to configure the NPX. SET$REAL$MODE loads the 80287 control word, and its 16-bit parameter has the format shown in figure 1-5. The recommended value of this parameter is 033EH (projective closure, round to nearest, 64-bit precision, all exceptions masked except invalid operation). Other settings may be used at the programmer's discretion.

If any exceptions are unmasked, an exception handler must be provided in the form of an interrupt procedure that is designated to be invoked by CPU interrupt pointer (vector) number 16. The excep- tion handler can use the GET$REAL$ERROR procedure to obtain the low-order byte of the 80287 status word and to then clear the exception flags. The byte returned by GET$REAL$ERROR contains the exception flags; these can be examined to determine the source of the exception.

TheSAVE$REAL$STATUS and RESTORE$REAL$STATUS procedures are provided for multi- tasking environments where a running task that uses the 80287 may be preempted by another task that also uses the 80287. It is the responsibility of the preempting task to issue SAVE$REAUSTATUS before it executes any statements that affect the 80287; these include the INIT$REAL$MATH$UNIT

Table 2-15. PLlM-286 Built-In Procedures

Procedure

80287 Instruction

Description

INIT$REAL$MATH$UNIT(1)

FINIT

Initialize processor.

SET$REAL$MODE

FLDCW

Set exception masks, rounding

 

 

preCision, and infinity controls.

GET$REAL$ERROR(2)

FNSTSW & FNCLEX

Store, then clear, exception flags.

SAVE$REAL$STATUS

FNSAVE

Save processor state.

RESTORE$REAL$STATUS

FRSTOR

Restore processor state.

(1)Also initializes interrupt pOinters for emulation. (')Returnslow-order byte of status word.

2-39

Page 431
Image 431
Intel 80286, 80287 manual PLlM-286 Built-In Procedures