; File:  E16.SANE
;
;
; Copyright Apple Computer, Inc. 1986-90
; All Rights Reserved
;
;
SIGDIGLEN EQU $001C
IEEEDEFAULTENV EQU $0000
FLOATDECIMAL EQU $0000
FIXEDDECIMAL EQU $0001
INVALID EQU $0001
UNDERFLOW EQU $0002
OVERFLOW EQU $0004
DIVBYZERO EQU $0008
INEXACT EQU $0010
;-----------------------------------------------------------
; Tool Set and Function Numbers.
;-----------------------------------------------------------
SANEtsNum       equ     $A              ; SANE tool set number

FPNum           equ     $9              ; Function number for Arithmetic
DecStrNum       equ     $A              ; Function number for Scanner/Formatter
ElemNum         equ     $B              ; Function no. for Elementary functions

;-----------------------------------------------------------
; Operation code masks.
;-----------------------------------------------------------
FOADD           equ     $00             ; add
FOSUB           equ     $02             ; subtract
FOMUL           equ     $04             ; multiply
FODIV           equ     $06             ; divide
FOCMP           equ     $08             ; compare, no exception from unordered
FOCPX           equ     $0A             ; compare, signal invalid if unordered
FOREM           equ     $0C             ; remainder
FOZ2X           equ     $0E             ; convert to extended
FOX2Z           equ     $10             ; convert from extended
FOSQRT          equ     $12             ; square root
FORTI           equ     $14             ; round to integral value
FOTTI           equ     $16             ; truncate to integral value
FOSCALB         equ     $18             ; binary scale
FOLOGB          equ     $1A             ; binary log
FOCLASS         equ     $1C             ; classify
FONEXT          equ     $1E             ; next-after

FOSETENV        equ     $01             ; set environment
FOGETENV        equ     $03             ; get environment
FOSETHV         equ     $05             ; set halt vector
FOGETHV         equ     $07             ; get halt vector
FOD2B           equ     $09             ; convert decimal to binary
FOB2D           equ     $0B             ; convert binary to decimal
FONEG           equ     $0D             ; negate
FOABS           equ     $0F             ; absolute value
FOCPYSGN        equ     $11             ; copy sign
; UNDEFINED     equ     $13
FOSETXCP        equ     $15             ; set exception
FOPROCENTRY     equ     $17             ; procedure-entry
FOPROCEXIT      equ     $19             ; procedure-exit
FOTESTXCP       equ     $1B             ; test exception
; UNDEFINED     equ     $1D
; UNDEFINED     equ     $1F

;-----------------------------------------------------------
; Operand format masks.
;-----------------------------------------------------------
FFEXT           equ     $000            ; extended -- 80-bit float
FFDBL           equ     $100            ; double   -- 64-bit float
FFSGL           equ     $200            ; single   -- 32-bit float
FFLNG           equ     $300            ; longint  -- 32-bit integer                                                   
FFINT           equ     $400            ; integer  -- 16-bit integer
FFCOMP          equ     $500            ; comp     -- 64-bit integer
; UNDEFINED     equ     $600
; UNDEFINED     equ     $700

;-----------------------------------------------------------
; Class and sign inquiries.
;-----------------------------------------------------------
FCSNAN          equ     $FC             ; -4: signaling NAN
FCQNAN          equ     $FD             ; -3: quiet NAN
FCINF           equ     $FE             ; -2: infinite
FCZERO          equ     $FF             ; -1: zero
FCNORM          equ     $00             ;  0: normal
FCDENORM        equ     $01             ;  1: denormal

;-----------------------------------------------------------
; Exceptions.
;-----------------------------------------------------------
FBINVALID       equ     $1
FBUFLOW         equ     $2
FBOFLOW         equ     $4
FBDIVZER        equ     $8
FBINEXACT       equ     $10

;-----------------------------------------------------------
; Elementary function operation code masks.
;-----------------------------------------------------------
FOLNX           equ     $00             ; base-e log 
FOLOG2X         equ     $02             ; base-2 log
FOLN1X          equ     $04             ; ln (1 + x)
FOLOG21X        equ     $06             ; log2 (1 + x)
FOEXPX          equ     $08             ; base-e exponential  
FOEXP2X         equ     $0A             ; base-2 exponential
FOEXP1X         equ     $0C             ; exp (x) - 1
FOEXP21X        equ     $0E             ; exp2 (x) - 1
FOXPWRI         equ     $10             ; integer exponentiation
FOXPWRY         equ     $12             ; general exponentiation
FOCOMPOUND      equ     $14             ; compound
FOANNUITY       equ     $16             ; annuity
FOATANX         equ     $18             ; arctangent
FOSINX          equ     $1A             ; sine
FOCOSX          equ     $1C             ; cosine
FOTANX          equ     $1E             ; tangent
FORANDX         equ     $20             ; random

;-----------------------------------------------------------
; Scanner and formatter operation code masks.
;-----------------------------------------------------------
FOPSTR2DEC      equ     0               ; Pascal string to decimal record
FOCSTR2DEC      equ     2               ; C string (char stream) to dec. record
FODEC2STR       equ     1               ; decimal record to (Pascal) string

;-----------------------------------------------------------
; 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 rem or mod such as x REM 0 
NANASCBIN       equ     17              ; Conversion of invalid ASCII string 
NANCOMP         equ     20              ; Comp NaN converted to floating
NANZERO         equ     21              ; Attempt to create a NaN with zero code
NANTRIG         equ     33              ; Invalid argument to trig routine 
NANINVTRIG      equ     34              ; Invalid arg 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 
            

relop_GREATERTHAN EQU 0 ;
relop_LESSTHAN EQU 1 ;
relop_EQUALTO EQU 2 ;
relop_UNORDERED EQU 3 ;

numclass_SNAN EQU 0 ;
numclass_QNAN EQU 1 ;
numclass_INFINITE EQU 2 ;
numclass_ZERONUM EQU 3 ;
numclass_NORMALNUM EQU 4 ;
numclass_DENORMALNUM EQU 5 ;

rounddir_TONEAREST EQU 0 ;
rounddir_UPWARD EQU 1 ;
rounddir_DOWNWARD EQU 2 ;
rounddir_TOWARDZERO EQU 3 ;

roundpre_EXTPRECISION EQU 0 ;
roundpre_DBLPRECISION EQU 1 ;
roundpre_FLOATPRECISION EQU 2 ;

