	PAGE	,132			;
	TITLE	FLINS - SAMPLE FLOATING POINT INSTRUCTIONS
.8087
CSEG	SEGMENT PARA PUBLIC 'CODE'
	ASSUME	CS:CSEG,DS:CSEG

SHORT_REAL	   DD	3.14159 	;32 BIT, DOUBLE WORD, SHORT REAL NUMBER
LONG_REAL	   DQ	3.14159 	;64 BIT, QUAD WORD LONG REAL NUMBER
TEMP_REAL	   DT	3.14159 	;80 BIT, TEN BYTES, TEMP REAL NUMBER
PACKED_DECIMAL	   DT	314159		;10 BYTES, 18 DIGIT PACKED DECIMAL INTEGER
WORD_INTEGER	   DW	31415		;16 BIT, SINGLE WORD, BINARY INTEGER
SHORT_INTEGER	   DD	314159		;32 BIT, DOUBLE WORD, SHORT BINARY INTEGER
LONG_INTEGER	   DQ	314159		;64 BIT, QUAD WORD, LONG BINARY INTEGER
NINETY_FOUR_BYTES  DB	94 DUP(0)	;SAVE AREA REQUIRED BY FSAVE/FRSTOR
FOURTEEN_BYTES	   DB	14 DUP(0)	;ENVIRONMENT SAVE AREA
TWO_BYTES	   DW	0		;2 BYTE AREA (CONTROL OR STATUS WORD)

; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

SAMPLES PROC	NEAR
;			DATA TRANSFER INSTRUCTIONS
;REAL TRANSFERS
	FLD	ST(0)			;LOAD REAL (DUPS TOP OF STACK)
	FLD	ST(7)
	FLD	SHORT_REAL		;LOAD REAL
	FLD	LONG_REAL
	FLD	TEMP_REAL

	FST	ST(7)			;STORE REAL
	FST	ST(0)
	FST	SHORT_REAL
	FST	LONG_REAL

	FSTP	ST(7)			;STORE REAL AND POP
	FSTP	ST(0)			;JUST POP STACK, NO DATA TRANSFER
	FSTP	SHORT_REAL
	FSTP	LONG_REAL
	FSTP	TEMP_REAL

	FXCH	ST(7)			;EXCHANGE REGISTERS (TOP OF STACK AND OPERAND)
	FXCH				;OPERAND IS ASSUMED TO BE ST(1)
	FXCH	ST(1)			;EXPLICITLY STATE THE DEFAULT REG

;INTEGER TRANSFERS
	FILD	WORD_INTEGER		;INTEGER LOAD
	FILD	SHORT_INTEGER
	FILD	LONG_INTEGER

	FIST	WORD_INTEGER		;INTEGER STORE
	FIST	SHORT_INTEGER

	FISTP	WORD_INTEGER		;INTEGER STORE AND POP
	FISTP	SHORT_INTEGER
	FISTP	LONG_INTEGER

;PACKED DECIMAL TRANSFERS
	FBLD	PACKED_DECIMAL		;PACKED DECIMAL (BCD) LOAD

	FBSTP	PACKED_DECIMAL		;PACKED DECIMAL (BCD) STORE AND POP

;			ARITHMETIC INSTRUCTIONS
;ADDITION
	FADD	ST,ST(1)		;ADD REAL
	FADD	ST(1),ST
	FADD	ST(7),ST
	FADD	ST,ST(0)		;DOUBLE TOP OF STACK
	FADD	ST,ST(7)
	FADD	SHORT_REAL
	FADD	LONG_REAL
	FADD				;ADD REAL

	FADDP	ST(1),ST		;SAME AS ABOVE, BUT USING THE POP OP CODE
	FADDP	ST(7),ST		;ADD REAL AND POP

	FIADD	WORD_INTEGER		;INTEGER ADD
	FIADD	SHORT_INTEGER

;SUBTRACTION
	FSUB				;SUBTRACT REAL
					; (LIKE FSUBP ST(1),ST BELOW)
	FSUB	ST,ST(1)
	FSUB	ST(1),ST
	FSUB	ST(7),ST
	FSUB	ST,ST(7)
	FSUB	SHORT_REAL
	FSUB	LONG_REAL

	FSUBP	ST(7),ST		;SUBTRACT REAL AND POP
	FSUBP	ST(1),ST		;(LIKE FSUB ABOVE)

	FISUB	WORD_INTEGER		;INTEGER SUBTRACT
	FISUB	SHORT_INTEGER

	FSUBR				;SUBTRACT REAL REVERSED
					; (LIKE FSUBRP ST(1),ST BELOW)
	FSUBR	ST,ST(1)
	FSUBR	ST(1),ST
	FSUBR	ST(7),ST
	FSUBR	ST,ST(7)
	FSUBR	SHORT_REAL
	FSUBR	LONG_REAL

	FSUBRP	ST(7),ST		;SUBTRACT REAL REVERSED AND POP
	FSUBRP	ST(1),ST		;(LIKE FSUBR ABOVE)

	FISUBR	WORD_INTEGER		;INTEGER SUBTRACT REVERSED
	FISUBR	SHORT_INTEGER

;MULTIPLICATION
	FMUL	ST,ST(1)		;MULTIPLY REAL
	FMUL	ST(1),ST
	FMUL	ST(7),ST
	FMUL	ST,ST(7)
	FMUL	SHORT_REAL
	FMUL	LONG_REAL
	FMUL				;MULTIPLY REAL

	FMULP	ST(1),ST		;SAME AS ABOVE, BUT WITH POP OP CODE
	FMULP	ST(7),ST		;MULTIPLY REAL AND POP

	FIMUL	WORD_INTEGER		;INTEGER MULTIPLY
	FIMUL	SHORT_INTEGER

;DIVISION
	FDIV				;DIVIDE REAL
					; (LIKE FDIVP ST(1),ST BELOW)
	FDIV	ST,ST(1)
	FDIV	ST(1),ST
	FDIV	SHORT_REAL
	FDIV	LONG_REAL

	FDIVP	ST(1),ST		;DIVIDE REAL AND POP
					; (LIKE FDIV ABOVE)
	FDIVP	ST(7),ST

	FIDIV	WORD_INTEGER		;INTEGER DIVIDE
	FIDIV	SHORT_INTEGER

	FDIVR				;DIVIDE REAL REVERSED
					; (LIKE FDIVRP ST(1),ST BELOW)
	FDIVR	ST,ST(1)
	FDIVR	ST(1),ST
	FDIVR	ST,ST(7)
	FDIVR	SHORT_REAL
	FDIVR	LONG_REAL

	FDIVRP	ST(1),ST		;DIVIDE REAL REVERSED AND POP
					; (LIKE FDIVR ABOVE)
	FDIVRP	ST(7),ST

	FIDIVR	WORD_INTEGER		;INTEGER DIVIDE REVERSED
	FIDIVR	SHORT_INTEGER

;OTHER ARITHMETICAL OPERATIONS
	FSQRT				;SQUARE ROOT

	FSCALE				;SCALE

	FPREM				;PARTIAL REMAINDER

	FRNDINT 			;ROUND TO INTEGER

	FXTRACT 			;EXTRACT EXPONENT AND SIGNIFICAND

	FABS				;ABSOLUTE VALUE

	FCHS				;CHANGE SIGN

;			COMPARISON
	FCOM				;COMPARE REAL
	FCOM	ST(1)			;SAME AS ABOVE
	FCOM	ST(7)
	FCOM	SHORT_REAL
	FCOM	LONG_REAL

	FCOMP				;COMPARE REAL AND POP
	FCOMP	ST(1)			;SAME AS ABOVE
	FCOMP	ST(7)
	FCOMP	SHORT_REAL
	FCOMP	LONG_REAL

	FCOMPP				;COMPARE REAL AND POP TWICE
					; THIS IS SHOWN BY DEBUG AS BEING FCOMPP ST(1)
					; BUT IT CANNOT BE CODED WITH THE OPERAND.
	FCOMPP	ST(1)			;AS I SAID, CANNOT BE CODED THIS WAY

	FICOM	WORD_INTEGER		;INTEGER COMPARE
	FICOM	SHORT_INTEGER

	FICOMP	WORD_INTEGER		;INTEGER COMPARE AND POP
	FICOMP	SHORT_INTEGER

	FTST				;TEST

	FXAM				;EXAMINE

;			TRANSCENDENTAL INSTRUCTIONS
	FPTAN				;PARTIAL TANGENT

	FPATAN				;PARTIAL ARCTANGENT

	F2XM1				;2 TO THE X POWER, MINUS ONE

	FYL2X				;Y TIMES LOG2 X

	FYL2XP1 			;Y TIMES LOG2 (X+1)

;			CONSTANT GENERATING INSTRUCTIONS
	FLDZ				;LOAD +0.0

	FLD1				;LOAD +1.0

	FLDPI				;LOAD PI

	FLDL2T				;LOAD LOG2 10

	FLDL2E				;LOAD LOG2 e

	FLDLG2				;LOAD LOG10 2

	FLDLN2				;LOAD LOGe 2

;			PROCESSOR CONTROL INSTRUCTIONS
	FINIT				;INITIALIZE PROCESSOR

	FNINIT

	FDISI				;DISABLE INTERRUPTS

	FNDISI

	FENI				;ENABLE INTERRUPTS
	FNENI				;ENABLE INTERRUPTS

	FLDCW	TWO_BYTES		;LOAD CONTROL WORD

	FSTCW	TWO_BYTES		;STORE CONTROL WORD
	FNSTCW	TWO_BYTES		;(OPCODE CANNOT BE EMULATED "/E")

	FSTSW	TWO_BYTES		;STORE STATUS WORD
	FNSTSW	TWO_BYTES		;(OPCODE CANNOT BE EMULATED "/E")

	FCLEX				;CLEAR EXCEPTIONS
	FNCLEX

	FSTENV	FOURTEEN_BYTES		;STORE ENVIRONMENT
	FNSTENV FOURTEEN_BYTES		;(OPCODE CANNOT BE EMULATED "/E")

	FLDENV	FOURTEEN_BYTES		;LOAD ENVIRONMENT

	FSAVE	NINETY_FOUR_BYTES	;SAVE STATE
	FNSAVE	NINETY_FOUR_BYTES	;(OPCODE CANNOT BE EMULATED "/E")

	FRSTOR	NINETY_FOUR_BYTES	;RESTORE STATE

	FINCSTP 			;INCREMENT STACK POINTER

	FDECSTP 			;DECREMENT STACK POINTER

	FFREE	ST(7)			;FREE REGISTER
	FFREE	ST(1)

	FNOP				;NO OPERATION, BUT DOES GENERATE A WAIT FIRST

	FWAIT				;CPU WAIT

;		MEMORY REFERENCES MAY BE BASE/INDEX WITH OFFSET INDIRECT,
;		 BUT THE TYPE ATTRIBUTE MUST BE EXPLICITLY STATED.

	FSTP	DWORD PTR [BX]		;STORE REAL AND POP
	FSTP	QWORD PTR [BX]
	FSTP	TBYTE PTR [BX]
	FSTP	DWORD PTR [BP]
	FSTP	QWORD PTR [SI]
	FSTP	TBYTE PTR [DI]
	FSTP	DWORD PTR [BX][DI]
	FSTP	QWORD PTR [BX+DI]
	FSTP	TBYTE PTR 2[BP][SI]
	FSTP	DWORD PTR [BP+SI+2]
	FSTP	QWORD PTR [BP+SI]+2

	FILD	DWORD PTR [BX]		;INTEGER LOAD
	FILD	QWORD PTR [BX][SI]+2
	FILD	WORD PTR [BX+2]

	FBLD	TBYTE PTR [SI+BP]	;PACKED DECIMAL (BCD) LOAD
SAMPLES ENDP
CSEG	ENDS
	END	samples
