NUMERIC PROGRAMMING EXAMPLES

iCALCULATE OFFSET INTO JUMP TABLE

MOV

BH,O

i

CLEAR

UPPER HALF OF

BX,

MOV

Bl,AH

i

lOAD CONDITION CODE

INTO BL

AND

BL,OOOOOIIIB

i CLE~R ALL BITS EXCEPT C2-CO

AND

AH,01000000B

i CLEAR ALL BITS EXCEPT C3

SHR

AH,2

 

SHIFT

C3 TWO PLACES

RIGHT

SAL

BX,1

 

SHIFT

C2-CO 1 PLACE LEFT (MULTIPLY

 

 

 

BY 2)

 

 

OR

Bl,AH

 

DROP

C3 BACK IN ADJACENT TO C2

(OOOXXXXO)

iJUMP TO THE ROUTINE 'ADDRESSED' BY CONDITION CODE

JMP FXAM_TBLIBXl

HERE ARE THE JUMP TARGETS, ONE TO HANDLE

iEACH POSSIBLE RESULT OF fXAM

PO LU NNOR M:

POS_NAN:

NELU NNOR M:

NELN AN:

PO LN 0 RM:

POLINFINITY:

NELH 0 RM:

NELINFINITY:

PO LZ E: R0:

EMPTY:

NELZERO:

PO LDE H0 RM:

HELDENORM:

Figure 4-2. Conditional Branching for FXAM (Cont'd.)

EXCEPTION HANDLING EXAMPLES

There are many approaches to writing exception handlers. One useful technique is to consider the exception handler procedure as consisting of "prologue," "body," and "epilogue" sections of code. (For compatibility with the 80287 emulators, this procedure should be invoked by interrupt pointer (vector) number 16.)

4-3

Page 459
Image 459
Intel 80286, 80287 manual Numeric Programming Examples, Conditional Branching for Fxam Contd