; ; File: SANEMacs.a ; ; Contains: xxx put contents here xxx ; ; Written by: xxx put writers here xxx ; ; Copyright: © 1991 by Apple Computer, Inc., all rights reserved. ; ; Change History (most recent first): ; ; <6> 3/13/91 JL Checking in MPW version. Removed precision code masks ; <5> 1/30/91 gbm sab, #38: Change the ‘already including this file’ variable to ; all uppercase (for security reasons) ; ; To Do: ; ; Version: 1.02 ; Created: Tuesday, August 2, 1988 at 9:48:22 PM ; File: SANEMacs.a ; ; Copyright Apple Computer, Inc. 1984, 1985, 1986, 1987, 1989, 1990, 1991 ; All Rights Reserved ; ; SANE Numerics -- This file defines the assembly language ; access to the 68K floating-point arithmetic routines. It is ; documented in the Apple Numerics Manual. ; ;************************************************************ ; CHANGE LOG (relative to MPW 3.1 release) ; ; 16 Nov 89 JPO Added macros for operations involving ; 96-bit extended format (Ω SANE) ; 27 Mar 90 JPO Changed 96-bit extended opcodes for PACK 4 ; routines (bit 5 set instead of bit 7) ; 29 Mar 90 JPO Added macro FCLASSC (classify comp) ;************************************************************ ;——————————————————————————————————————————————————————————— ; Operation code masks. ;——————————————————————————————————————————————————————————— FOADD EQU $0000 ; add FOSUB EQU $0002 ; subtract FOMUL EQU $0004 ; multiply FODIV EQU $0006 ; divide FOCMP EQU $0008 ; compare, no exception from unordered FOCPX EQU $000A ; compare, signal invalid if unordered FOREM EQU $000C ; remainder FOZ2X EQU $000E ; convert to extended FOX2Z EQU $0010 ; convert from extended FOSQRT EQU $0012 ; square root FORTI EQU $0014 ; round to integral value FOTTI EQU $0016 ; truncate to integral value FOSCALB EQU $0018 ; binary scale FOLOGB EQU $001A ; binary log FOCLASS EQU $001C ; classify ; UNDEFINED EQU $001E FOSETENV EQU $0001 ; set environment FOGETENV EQU $0003 ; get environment FOSETHV EQU $0005 ; set halt vector FOGETHV EQU $0007 ; get halt vector FOD2B EQU $0009 ; convert decimal to binary FOB2D EQU $000B ; convert binary to decimal FONEG EQU $000D ; negate FOABS EQU $000F ; absolute FOCPYSGN EQU $0011 ; copy sign FONEXT EQU $0013 ; next-after FOSETXCP EQU $0015 ; set exception FOPROCENTRY EQU $0017 ; procedure entry FOPROCEXIT EQU $0019 ; procedure exit FOTESTXCP EQU $001B ; test exception ; UNDEFINED EQU $001D ; UNDEFINED EQU $001F ;——————————————————————————————————————————————————————————— ; Operand format masks. ;——————————————————————————————————————————————————————————— FFEXT EQU $0000 ; extended -- 80-bit float FFEXT96 EQU $0020 ; extended -- 96-bit float FFDBL EQU $0800 ; double -- 64-bit float FFSGL EQU $1000 ; single -- 32-bit float FFINT EQU $2000 ; integer -- 16-bit integer FFLNG EQU $2800 ; long int -- 32-bit integer FFCOMP EQU $3000 ; comp -- 64-bit integer ;——————————————————————————————————————————————————————————— ; Operations: operand addresses should already be on ; the stack, with the destination address on top. The ; suffix X, D, S, C, I, or L determines the format of the ; source operand -- extended, double, single, comp, ; integer, or long integer, respectively; the destination ; operand is always extended. ;——————————————————————————————————————————————————————————— ;——————————————————————————————————————————————————————————— ; Addition. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FADDX MOVE.W #FFEXT+FOADD,-(SP) _FP68K ENDM MACRO FADDD MOVE.W #FFDBL+FOADD,-(SP) _FP68K ENDM MACRO FADDS MOVE.W #FFSGL+FOADD,-(SP) _FP68K ENDM MACRO FADDC MOVE.W #FFCOMP+FOADD,-(SP) _FP68K ENDM MACRO FADDI MOVE.W #FFINT+FOADD,-(SP) _FP68K ENDM MACRO FADDL MOVE.W #FFLNG+FOADD,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FADDX96 MOVE.W #FFEXT96+FOADD,-(SP) _FP68K ENDM MACRO FADDD96 MOVE.W #FFDBL+FFEXT96+FOADD,-(SP) _FP68K ENDM MACRO FADDS96 MOVE.W #FFSGL+FFEXT96+FOADD,-(SP) _FP68K ENDM MACRO FADDC96 MOVE.W #FFCOMP+FFEXT96+FOADD,-(SP) _FP68K ENDM MACRO FADDI96 MOVE.W #FFINT+FFEXT96+FOADD,-(SP) _FP68K ENDM MACRO FADDL96 MOVE.W #FFLNG+FFEXT96+FOADD,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Subtraction. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FSUBX MOVE.W #FFEXT+FOSUB,-(SP) _FP68K ENDM MACRO FSUBD MOVE.W #FFDBL+FOSUB,-(SP) _FP68K ENDM MACRO FSUBS MOVE.W #FFSGL+FOSUB,-(SP) _FP68K ENDM MACRO FSUBC MOVE.W #FFCOMP+FOSUB,-(SP) _FP68K ENDM MACRO FSUBI MOVE.W #FFINT+FOSUB,-(SP) _FP68K ENDM MACRO FSUBL MOVE.W #FFLNG+FOSUB,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FSUBX96 MOVE.W #FFEXT96+FOSUB,-(SP) _FP68K ENDM MACRO FSUBD96 MOVE.W #FFDBL+FFEXT96+FOSUB,-(SP) _FP68K ENDM MACRO FSUBS96 MOVE.W #FFSGL+FFEXT96+FOSUB,-(SP) _FP68K ENDM MACRO FSUBC96 MOVE.W #FFCOMP+FFEXT96+FOSUB,-(SP) _FP68K ENDM MACRO FSUBI96 MOVE.W #FFINT+FFEXT96+FOSUB,-(SP) _FP68K ENDM MACRO FSUBL96 MOVE.W #FFLNG+FFEXT96+FOSUB,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Multiplication. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FMULX MOVE.W #FFEXT+FOMUL,-(SP) _FP68K ENDM MACRO FMULD MOVE.W #FFDBL+FOMUL,-(SP) _FP68K ENDM MACRO FMULS MOVE.W #FFSGL+FOMUL,-(SP) _FP68K ENDM MACRO FMULC MOVE.W #FFCOMP+FOMUL,-(SP) _FP68K ENDM MACRO FMULI MOVE.W #FFINT+FOMUL,-(SP) _FP68K ENDM MACRO FMULL MOVE.W #FFLNG+FOMUL,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FMULX96 MOVE.W #FFEXT96+FOMUL,-(SP) _FP68K ENDM MACRO FMULD96 MOVE.W #FFDBL+FFEXT96+FOMUL,-(SP) _FP68K ENDM MACRO FMULS96 MOVE.W #FFSGL+FFEXT96+FOMUL,-(SP) _FP68K ENDM MACRO FMULC96 MOVE.W #FFCOMP+FFEXT96+FOMUL,-(SP) _FP68K ENDM MACRO FMULI96 MOVE.W #FFINT+FFEXT96+FOMUL,-(SP) _FP68K ENDM MACRO FMULL96 MOVE.W #FFLNG+FFEXT96+FOMUL,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Division. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FDIVX MOVE.W #FFEXT+FODIV,-(SP) _FP68K ENDM MACRO FDIVD MOVE.W #FFDBL+FODIV,-(SP) _FP68K ENDM MACRO FDIVS MOVE.W #FFSGL+FODIV,-(SP) _FP68K ENDM MACRO FDIVC MOVE.W #FFCOMP+FODIV,-(SP) _FP68K ENDM MACRO FDIVI MOVE.W #FFINT+FODIV,-(SP) _FP68K ENDM MACRO FDIVL MOVE.W #FFLNG+FODIV,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FDIVX96 MOVE.W #FFEXT96+FODIV,-(SP) _FP68K ENDM MACRO FDIVD96 MOVE.W #FFDBL+FFEXT96+FODIV,-(SP) _FP68K ENDM MACRO FDIVS96 MOVE.W #FFSGL+FFEXT96+FODIV,-(SP) _FP68K ENDM MACRO FDIVC96 MOVE.W #FFCOMP+FFEXT96+FODIV,-(SP) _FP68K ENDM MACRO FDIVI96 MOVE.W #FFINT+FFEXT96+FODIV,-(SP) _FP68K ENDM MACRO FDIVL96 MOVE.W #FFLNG+FFEXT96+FODIV,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Square root. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FSQRTX MOVE.W #FOSQRT,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FSQRTX96 MOVE.W #FFEXT96+FOSQRT,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Round to integer, according to the current rounding mode. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FRINTX MOVE.W #FORTI,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FRINTX96 MOVE.W #FFEXT96+FORTI,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Truncate to integer, using round toward zero. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FTINTX MOVE.W #FOTTI,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FTINTX96 MOVE.W #FFEXT96+FOTTI,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Remainder. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FREMX MOVE.W #FFEXT+FOREM,-(SP) _FP68K ENDM MACRO FREMD MOVE.W #FFDBL+FOREM,-(SP) _FP68K ENDM MACRO FREMS MOVE.W #FFSGL+FOREM,-(SP) _FP68K ENDM MACRO FREMC MOVE.W #FFCOMP+FOREM,-(SP) _FP68K ENDM MACRO FREMI MOVE.W #FFINT+FOREM,-(SP) _FP68K ENDM MACRO FREML MOVE.W #FFLNG+FOREM,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FREMX96 MOVE.W #FFEXT96+FOREM,-(SP) _FP68K ENDM MACRO FREMD96 MOVE.W #FFDBL+FFEXT96+FOREM,-(SP) _FP68K ENDM MACRO FREMS96 MOVE.W #FFSGL+FFEXT96+FOREM,-(SP) _FP68K ENDM MACRO FREMC96 MOVE.W #FFCOMP+FFEXT96+FOREM,-(SP) _FP68K ENDM MACRO FREMI96 MOVE.W #FFINT+FFEXT96+FOREM,-(SP) _FP68K ENDM MACRO FREML96 MOVE.W #FFLNG+FFEXT96+FOREM,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Logb. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FLOGBX MOVE.W #FOLOGB,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FLOGBX96 MOVE.W #FFEXT96+FOLOGB,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Scalb. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FSCALBX MOVE.W #FFINT+FOSCALB,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FSCALBX96 MOVE.W #FFINT+FFEXT96+FOSCALB,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Copy-sign. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FCPYSGNX MOVE.W #FOCPYSGN,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FCPYSGNX96 MOVE.W #FFEXT96+FOCPYSGN,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Negate. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FNEGX MOVE.W #FONEG,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FNEGX96 MOVE.W #FFEXT96+FONEG,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Absolute value. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FABSX MOVE.W #FOABS,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FABSX96 MOVE.W #FFEXT96+FOABS,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Next-after. NOTE: both operands are of the same ; format, as specified by the usual suffix. ;——————————————————————————————————————————————————————————— MACRO FNEXTS MOVE.W #FFSGL+FONEXT,-(SP) _FP68K ENDM MACRO FNEXTD MOVE.W #FFDBL+FONEXT,-(SP) _FP68K ENDM ; 80-bit extended format MACRO FNEXTX MOVE.W #FFEXT+FONEXT,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FNEXTX96 MOVE.W #FFEXT96+FONEXT,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Conversion to 80-bit extended. ;——————————————————————————————————————————————————————————— MACRO FX2X MOVE.W #FFEXT+FOZ2X,-(SP) _FP68K ENDM MACRO FD2X MOVE.W #FFDBL+FOZ2X,-(SP) _FP68K ENDM MACRO FS2X MOVE.W #FFSGL+FOZ2X,-(SP) _FP68K ENDM MACRO FI2X MOVE.W #FFINT+FOZ2X,-(SP) _FP68K ENDM MACRO FL2X MOVE.W #FFLNG+FOZ2X,-(SP) _FP68K ENDM MACRO FC2X MOVE.W #FFCOMP+FOZ2X,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Conversion to 96-bit extended. ;——————————————————————————————————————————————————————————— MACRO FX2X96 MOVE.W #FFEXT96+FOZ2X,-(SP) _FP68K ENDM MACRO FD2X96 MOVE.W #FFDBL+FFEXT96+FOZ2X,-(SP) _FP68K ENDM MACRO FS2X96 MOVE.W #FFSGL+FFEXT96+FOZ2X,-(SP) _FP68K ENDM MACRO FI2X96 MOVE.W #FFINT+FFEXT96+FOZ2X,-(SP) _FP68K ENDM MACRO FL2X96 MOVE.W #FFLNG+FFEXT96+FOZ2X,-(SP) _FP68K ENDM MACRO FC2X96 MOVE.W #FFCOMP+FFEXT96+FOZ2X,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Conversion from 80-bit extended. ;——————————————————————————————————————————————————————————— MACRO FX2D MOVE.W #FFDBL+FOX2Z,-(SP) _FP68K ENDM MACRO FX2S MOVE.W #FFSGL+FOX2Z,-(SP) _FP68K ENDM MACRO FX2I MOVE.W #FFINT+FOX2Z,-(SP) _FP68K ENDM MACRO FX2L MOVE.W #FFLNG+FOX2Z,-(SP) _FP68K ENDM MACRO FX2C MOVE.W #FFCOMP+FOX2Z,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Conversion from 96-bit extended. ;——————————————————————————————————————————————————————————— MACRO FX2D96 MOVE.W #FFDBL+FFEXT96+FOX2Z,-(SP) _FP68K ENDM MACRO FX2S96 MOVE.W #FFSGL+FFEXT96+FOX2Z,-(SP) _FP68K ENDM MACRO FX2I96 MOVE.W #FFINT+FFEXT96+FOX2Z,-(SP) _FP68K ENDM MACRO FX2L96 MOVE.W #FFLNG+FFEXT96+FOX2Z,-(SP) _FP68K ENDM MACRO FX2C96 MOVE.W #FFCOMP+FFEXT96+FOX2Z,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Binary to decimal conversion. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FX2DEC MOVE.W #FFEXT+FOB2D,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FX2DEC96 MOVE.W #FFEXT96+FOB2D,-(SP) _FP68K ENDM MACRO FD2DEC MOVE.W #FFDBL+FOB2D,-(SP) _FP68K ENDM MACRO FS2DEC MOVE.W #FFSGL+FOB2D,-(SP) _FP68K ENDM MACRO FC2DEC MOVE.W #FFCOMP+FOB2D,-(SP) _FP68K ENDM MACRO FI2DEC MOVE.W #FFINT+FOB2D,-(SP) _FP68K ENDM MACRO FL2DEC MOVE.W #FFLNG+FOB2D,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Decimal to binary conversion. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FDEC2X MOVE.W #FFEXT+FOD2B,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FDEC2X96 MOVE.W #FFEXT96+FOD2B,-(SP) _FP68K ENDM MACRO FDEC2D MOVE.W #FFDBL+FOD2B,-(SP) _FP68K ENDM MACRO FDEC2S MOVE.W #FFSGL+FOD2B,-(SP) _FP68K ENDM MACRO FDEC2C MOVE.W #FFCOMP+FOD2B,-(SP) _FP68K ENDM MACRO FDEC2I MOVE.W #FFINT+FOD2B,-(SP) _FP68K ENDM MACRO FDEC2L MOVE.W #FFLNG+FOD2B,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Compare, not signaling invalid on unordered. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FCMPX MOVE.W #FFEXT+FOCMP,-(SP) _FP68K ENDM MACRO FCMPD MOVE.W #FFDBL+FOCMP,-(SP) _FP68K ENDM MACRO FCMPS MOVE.W #FFSGL+FOCMP,-(SP) _FP68K ENDM MACRO FCMPC MOVE.W #FFCOMP+FOCMP,-(SP) _FP68K ENDM MACRO FCMPI MOVE.W #FFINT+FOCMP,-(SP) _FP68K ENDM MACRO FCMPL MOVE.W #FFLNG+FOCMP,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FCMPX96 MOVE.W #FFEXT96+FOCMP,-(SP) _FP68K ENDM MACRO FCMPD96 MOVE.W #FFDBL+FFEXT96+FOCMP,-(SP) _FP68K ENDM MACRO FCMPS96 MOVE.W #FFSGL+FFEXT96+FOCMP,-(SP) _FP68K ENDM MACRO FCMPC96 MOVE.W #FFCOMP+FFEXT96+FOCMP,-(SP) _FP68K ENDM MACRO FCMPI96 MOVE.W #FFINT+FFEXT96+FOCMP,-(SP) _FP68K ENDM MACRO FCMPL96 MOVE.W #FFLNG+FFEXT96+FOCMP,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Compare, signaling invalid on unordered. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FCPXX MOVE.W #FFEXT+FOCPX,-(SP) _FP68K ENDM MACRO FCPXD MOVE.W #FFDBL+FOCPX,-(SP) _FP68K ENDM MACRO FCPXS MOVE.W #FFSGL+FOCPX,-(SP) _FP68K ENDM MACRO FCPXC MOVE.W #FFCOMP+FOCPX,-(SP) _FP68K ENDM MACRO FCPXI MOVE.W #FFINT+FOCPX,-(SP) _FP68K ENDM MACRO FCPXL MOVE.W #FFLNG+FOCPX,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FCPXX96 MOVE.W #FFEXT96+FOCPX,-(SP) _FP68K ENDM MACRO FCPXD96 MOVE.W #FFDBL+FFEXT96+FOCPX,-(SP) _FP68K ENDM MACRO FCPXS96 MOVE.W #FFSGL+FFEXT96+FOCPX,-(SP) _FP68K ENDM MACRO FCPXC96 MOVE.W #FFCOMP+FFEXT96+FOCPX,-(SP) _FP68K ENDM MACRO FCPXI96 MOVE.W #FFINT+FFEXT96+FOCPX,-(SP) _FP68K ENDM MACRO FCPXL96 MOVE.W #FFLNG+FFEXT96+FOCPX,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; The following defines a set of so-called floating ; branches. They presume that an appropriate compare ; operation, FCMPz, FCMPz96, FCPXz or FCPXz96, precedes. ;——————————————————————————————————————————————————————————— MACRO FBEQL BEQ &SYSLIST[1] ENDM MACRO FBLTL BCS &SYSLIST[1] ENDM MACRO FBLEL BLS &SYSLIST[1] ENDM MACRO FBGTL BGT &SYSLIST[1] ENDM MACRO FBGEL BGE &SYSLIST[1] ENDM MACRO FBULTL BLT &SYSLIST[1] ENDM MACRO FBULEL BLE &SYSLIST[1] ENDM MACRO FBUGTL BHI &SYSLIST[1] ENDM MACRO FBUGEL BCC &SYSLIST[1] ENDM MACRO FBUL BVS &SYSLIST[1] ENDM MACRO FBOL BVC &SYSLIST[1] ENDM MACRO FBNEL BNE &SYSLIST[1] ENDM MACRO FBUEL BEQ &SYSLIST[1] BVS &SYSLIST[1] ENDM MACRO FBLGL BCS &SYSLIST[1] BGT &SYSLIST[1] ENDM ;——————————————————————————————————————————————————————————— ; Short branch versions. ;——————————————————————————————————————————————————————————— MACRO FBEQS BEQ.S &SYSLIST[1] ENDM MACRO FBLTS BCS.S &SYSLIST[1] ENDM MACRO FBLES BLS.S &SYSLIST[1] ENDM MACRO FBGTS BGT.S &SYSLIST[1] ENDM MACRO FBGES BGE.S &SYSLIST[1] ENDM MACRO FBULTS BLT.S &SYSLIST[1] ENDM MACRO FBULES BLE.S &SYSLIST[1] ENDM MACRO FBUGTS BHI.S &SYSLIST[1] ENDM MACRO FBUGES BCC.S &SYSLIST[1] ENDM MACRO FBUS BVS.S &SYSLIST[1] ENDM MACRO FBOS BVC.S &SYSLIST[1] ENDM MACRO FBNES BNE.S &SYSLIST[1] ENDM MACRO FBUES BEQ.S &SYSLIST[1] BVS.S &SYSLIST[1] ENDM MACRO FBLGS BCS.S &SYSLIST[1] BGT.S &SYSLIST[1] ENDM ;——————————————————————————————————————————————————————————— ; Class and sign inquiries. ;——————————————————————————————————————————————————————————— FCSNAN EQU 1 ; signaling NAN FCQNAN EQU 2 ; quiet NAN FCINF EQU 3 ; infinity FCZERO EQU 4 ; zero FCNORM EQU 5 ; normal number FCDENORM EQU 6 ; denormal number MACRO FCLASSC MOVE.W #FFCOMP+FOCLASS,-(SP) _FP68K ENDM MACRO FCLASSS MOVE.W #FFSGL+FOCLASS,-(SP) _FP68K ENDM MACRO FCLASSD MOVE.W #FFDBL+FOCLASS,-(SP) _FP68K ENDM ; 80-bit extended format MACRO FCLASSX MOVE.W #FFEXT+FOCLASS,-(SP) _FP68K ENDM ; 96-bit extended format MACRO FCLASSX96 MOVE.W #FFEXT96+FOCLASS,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Bit indexes for bytes of floating point environment word. ;——————————————————————————————————————————————————————————— FBINVALID EQU 0 ; invalid operation FBUFLOW EQU 1 ; underflow FBOFLOW EQU 2 ; overflow FBDIVZER EQU 3 ; division by zero FBINEXACT EQU 4 ; inexact FBRNDLO EQU 5 ; low bit of rounding mode FBRNDHI EQU 6 ; high bit of rounding mode FBLSTRND EQU 7 ; last round result bit FBDBL EQU 5 ; double precision control FBSGL EQU 6 ; single precision control ;——————————————————————————————————————————————————————————— ; Get and set environment. ;——————————————————————————————————————————————————————————— MACRO FGETENV MOVE.W #FOGETENV,-(SP) _FP68K ENDM MACRO FSETENV MOVE.W #FOSETENV,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Test and set exception. ;——————————————————————————————————————————————————————————— MACRO FTESTXCP MOVE.W #FOTESTXCP,-(SP) _FP68K ENDM MACRO FSETXCP MOVE.W #FOSETXCP,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Procedure entry and exit. ;——————————————————————————————————————————————————————————— MACRO FPROCENTRY MOVE.W #FOPROCENTRY,-(SP) _FP68K ENDM MACRO FPROCEXIT MOVE.W #FOPROCEXIT,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Get and set halt vector. ;——————————————————————————————————————————————————————————— MACRO FGETHV MOVE.W #FOGETHV,-(SP) _FP68K ENDM MACRO FSETHV MOVE.W #FOSETHV,-(SP) _FP68K ENDM ;——————————————————————————————————————————————————————————— ; Elementary function operation code masks. ;——————————————————————————————————————————————————————————— ELEXT96 EQU $0080 ; 96-bit extended format FOLNX EQU $0000 ; base-e log FOLOG2X EQU $0002 ; base-2 log FOLN1X EQU $0004 ; ln (1 + x) FOLOG21X EQU $0006 ; log2 (1 + x) FOEXPX EQU $0008 ; base-e exponential FOEXP2X EQU $000A ; base-2 exponential FOEXP1X EQU $000C ; exp (x) - 1 FOEXP21X EQU $000E ; exp2 (x) - 1 FOXPWRI EQU $8010 ; integer exponentiation FOXPWRY EQU $8012 ; general exponentiation FOCOMPOUND EQU $C014 ; compound FOANNUITY EQU $C016 ; annuity FOSINX EQU $0018 ; sine FOCOSX EQU $001A ; cosine FOTANX EQU $001C ; tangent FOATANX EQU $001E ; arctangent FORANDX EQU $0020 ; random ;——————————————————————————————————————————————————————————— ; Elementary functions. ;——————————————————————————————————————————————————————————— ; 80-bit extended format MACRO FLNX ; base-e log MOVE.W #FOLNX,-(SP) _ELEMS68K ENDM MACRO FLOG2X ; base-2 log MOVE.W #FOLOG2X,-(SP) _ELEMS68K ENDM MACRO FLN1X ; ln (1 + x) MOVE.W #FOLN1X,-(SP) _ELEMS68K ENDM MACRO FLOG21X ; log2 (1 + x) MOVE.W #FOLOG21X,-(SP) _ELEMS68K ENDM MACRO FEXPX ; base-e exponential MOVE.W #FOEXPX,-(SP) _ELEMS68K ENDM MACRO FEXP2X ; base-2 exponential MOVE.W #FOEXP2X,-(SP) _ELEMS68K ENDM MACRO FEXP1X ; exp (x) - 1 MOVE.W #FOEXP1X,-(SP) _ELEMS68K ENDM MACRO FEXP21X ; exp2 (x) - 1 MOVE.W #FOEXP21X,-(SP) _ELEMS68K ENDM MACRO FXPWRI ; integer exponential MOVE.W #FOXPWRI,-(SP) _ELEMS68K ENDM MACRO FXPWRY ; general exponential MOVE.W #FOXPWRY,-(SP) _ELEMS68K ENDM MACRO FCOMPOUND ; compound MOVE.W #FOCOMPOUND,-(SP) _ELEMS68K ENDM MACRO FANNUITY ; annuity MOVE.W #FOANNUITY,-(SP) _ELEMS68K ENDM MACRO FSINX ; sine MOVE.W #FOSINX,-(SP) _ELEMS68K ENDM MACRO FCOSX ; cosine MOVE.W #FOCOSX,-(SP) _ELEMS68K ENDM MACRO FTANX ; tangent MOVE.W #FOTANX,-(SP) _ELEMS68K ENDM MACRO FATANX ; arctangent MOVE.W #FOATANX,-(SP) _ELEMS68K ENDM MACRO FRANDX ; random number generator MOVE.W #FORANDX,-(SP) _ELEMS68K ENDM ; 96-bit extended format MACRO FLNX96 ; base-e log MOVE.W #ELEXT96+FOLNX,-(SP) _ELEMS68K ENDM MACRO FLOG2X96 ; base-2 log MOVE.W #ELEXT96+FOLOG2X,-(SP) _ELEMS68K ENDM MACRO FLN1X96 ; ln (1 + x) MOVE.W #ELEXT96+FOLN1X,-(SP) _ELEMS68K ENDM MACRO FLOG21X96 ; log2 (1 + x) MOVE.W #ELEXT96+FOLOG21X,-(SP) _ELEMS68K ENDM MACRO FEXPX96 ; base-e exponential MOVE.W #ELEXT96+FOEXPX,-(SP) _ELEMS68K ENDM MACRO FEXP2X96 ; base-2 exponential MOVE.W #ELEXT96+FOEXP2X,-(SP) _ELEMS68K ENDM MACRO FEXP1X96 ; exp (x) - 1 MOVE.W #ELEXT96+FOEXP1X,-(SP) _ELEMS68K ENDM MACRO FEXP21X96 ; exp2 (x) - 1 MOVE.W #ELEXT96+FOEXP21X,-(SP) _ELEMS68K ENDM MACRO FXPWRI96 ; integer exponential MOVE.W #ELEXT96+FOXPWRI,-(SP) _ELEMS68K ENDM MACRO FXPWRY96 ; general exponential MOVE.W #ELEXT96+FOXPWRY,-(SP) _ELEMS68K ENDM MACRO FCOMPOUND96 ; compound MOVE.W #ELEXT96+FOCOMPOUND,-(SP) _ELEMS68K ENDM MACRO FANNUITY96 ; annuity MOVE.W #ELEXT96+FOANNUITY,-(SP) _ELEMS68K ENDM MACRO FSINX96 ; sine MOVE.W #ELEXT96+FOSINX,-(SP) _ELEMS68K ENDM MACRO FCOSX96 ; cosine MOVE.W #ELEXT96+FOCOSX,-(SP) _ELEMS68K ENDM MACRO FTANX96 ; tangent MOVE.W #ELEXT96+FOTANX,-(SP) _ELEMS68K ENDM MACRO FATANX96 ; arctangent MOVE.W #ELEXT96+FOATANX,-(SP) _ELEMS68K ENDM MACRO FRANDX96 ; random number generator MOVE.W #ELEXT96+FORANDX,-(SP) _ELEMS68K ENDM ;——————————————————————————————————————————————————————————— ; Scanner and formatter operation code masks ;——————————————————————————————————————————————————————————— FOPSTR2DEC EQU $0002 ;Pascal string to decimal record FOCSTR2DEC EQU $0004 ;C string to decimal record FODEC2STR EQU $0003 ;decimal record to Pascal string ;——————————————————————————————————————————————————————————— ; Scanner and formatter functions ;——————————————————————————————————————————————————————————— ;Pascal string to decimal record MACRO FPSTR2DEC MOVE.W #FOPSTR2DEC, -(SP) _DecStr68K ENDM ;C string to decimal record MACRO FCSTR2DEC MOVE.W #FOCSTR2DEC, -(SP) _DecStr68K ENDM ;decimal record to Pascal string MACRO FDEC2STR MOVE.W #FODEC2STR, -(SP) _DecStr68K ENDM ;——————————————————————————————————————————————————————————— ; NaN codes. ;——————————————————————————————————————————————————————————— NANSQRT EQU 1 ; Invalid square root such as sqrt(-1). NANADD EQU 2 ; Invalid addition such as +INF - +INF. NANDIV EQU 4 ; Invalid division such as 0/0. NANMUL EQU 8 ; Invalid multiply such as 0 * INF. NANREM EQU 9 ; Invalid remainder or mod such as x REM 0. NANASCBIN EQU 17 ; Attempt to convert invalid ASCII string. NANCOMP EQU 20 ; Result of converting comp NaN to floating. NANZERO EQU 21 ; Attempt to create a NaN with a zero code. NANTRIG EQU 33 ; Invalid argument to trig routine. NANINVTRIG EQU 34 ; Invalid argument to inverse trig routine. NANLOG EQU 36 ; Invalid argument to log routine. NANPOWER EQU 37 ; Invalid argument to x^i or x^y routine. NANFINAN EQU 38 ; Invalid argument to financial function. NANINIT EQU 255 ; Uninitialized storage.