PROGRAMMING NUMERIC APPLICATIONS

The assembler does not, however, check the types of operands used in processor control instructions. Coding FRSTOR [BP] implies that the programmer has set up register BP to point to the stack location where the processor's 94-byte state record has been previously saved.

The initial values for 80287 constants may be coded in several different ways. Binary integer constants may be specified as bit strings, decimal integers, octal integers, or hexadecimal strings. Packed decimal values are normally written as decimal integers, although the assembler will accept and convert other representations of integers. Real values may be written as ordinary decimal real numbers (decimal point required), as decimal numbers in scientific notation, or as hexadecimal strings. Using hexadeci- mal strings is primarily intended for defining special values such as infinities, NaNs, and nonnormal- ized numbers. Most programmers will find that ordinary decimal and scientific decimal provide the simplest way to initialize 80287 constants. Figure 2-3 compares several ways of setting the various 80287 data types to the same initial value.

Note that preceding 80287 variables and constants with the ASM286 EVEN directive ensures that the operands will be word-aligned in memory. This will produce the best system performance. All 80287 data types occupy integral numbers of words so that no storage is "wasted" if blocks of variables are defined together and preceded by a single EVEN declarative.

RECORDS AND STRUCTURES

The ASM286 RECORD and STRUC (structure) declaratives can be very useful in NPX program- ming. The record facility can be used to define the bit fields of the control, status, and tag words. Figure 2-4 shows one definition of the status word and how it might be used in a routine that polls the 80287 until it has completed an instruction.

Because STRUCtures allow different but related data types to be grouped together, they often provide a natural way to represent "real world" data organizations. The fact that the structure template may be "moved" about in memory adds to its flexibility. Figure 2-5 shows a simple structure that might be used to represent data consisting of a series of test score samples. A structure could also be used to define the organization of the information stored and loaded by the FSTENV and FLDENV instructions.

THE FOLLOWING ALL ALLOCATE THI CONSTANT: -126

NOTE TWO'S COMPLETE STORAGE OF NEGATIVE BINARY INTEGERS,

EVEN

 

 

FORCE WORD

ALIGNMENT

WORD_I NTEGER

DW

111111111000010B

BIT

STRING

 

 

SHORT_I NTEGER

DD

OFFFFFF82H

HEX

STRING

MUST

START

 

 

 

WITH

DIGIT

 

 

LONG_INTEGER

DQ

-126

ORDINARY DECIMAL

 

SHORT_REAL

DD

-126,0

NOTE PRESENCE OF ' ,

LONG_REAL

DD

-1,26E2

"SCIENTIFIC"

 

PACKED_DECIMAL

DT

-126

ORDINARY DECIMAL

INTEGER

IN THE FOLLOWING, SIGN AND EXPONENT IS 'COOS' SIGNIFICAND IS '7EOO" ,00', 'R' INFORMS ASSEMBLER THAT THE STRING REPRESENTS A REAL DATA TYPE,

DT OCOOS7EOOOOOOOOOOOOOOR HEX STRING

Figure 2-3.Sample 80287 Constants

2-41

Page 433
Image 433
Intel 80286, 80287 manual BIT String Shorti Nteger OFFFFFF82H HEX Must Start