Blame | Last modification | View Log | Download | RSS feed
;;
;; Copyright (c) 2016 Marco Granati <mg@unet.bz>
;;
;; Permission to use, copy, modify, and distribute this software for any
;; purpose with or without fee is hereby granted, provided that the above
;; copyright notice and this permission notice appear in all copies.
;;
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
;;
;; name: dpfpu.inc
;; rev.: 2016/03/30
;; o.s. 65C816 version v1.0
.LIST on
; direct page for flotaing point unit
_DPFPU: .SECTION page0, common, ref_only, offset 0 ;FPU D.P.
MNTBITS .EQU (16*8) ; significand bits + guard bits
MANTSIZ .EQU 16 ; significand size
FREGSIZ .EQU 20 ; floating point register size
tm .DS 16 ; temp. mantissa
fsubnf .DB ; subnormal flag used by fac2dec
atncode .EQU fsubnf ; fatanyx octant
sgncmp .DB ; sign comparison: fac vs. arg
; floating Point accumulator (fac)
facm .DS 16 ; guard bits (32 bits)+significand (80 bits)
facexp .DW ; fac biased exponent
facsgn .DB ; fac mantissa sign
facst .DB ; fac status for floating point
; <7>: 1 if fac is invalid (nan or inf)
; <6>: 1 if fac=inf (with <7>=1)
; 0 if fac=nan (with <7>=1)
; <6>: 1 if fac=0 (with <7>=0)
; <5>: always '0'
; fac status for long integer
; <7>: 1 if facm will be regarded as 'signed'
; <6>: 1 if facm = 0
; <5>: always '1'
fexph .DW ; unbiased fac exponent sign extension
facext .DW ; fac guard bits extension
wftmp2 .EQU facext
facsiz .EQU facsgn ; integer only: size in bytes
; floating point operand (arg)
argm .DS 16 ; guard bits (32 bits)+significand (80 bits)
argexp .DW ; arg biased exponent
argsgn .DB ; arg mantissa sign
argst .DB ; arg status for floating point
; <7>: 1 if arg is invalid (nan or inf)
; <6>: 1 if arg=inf (with <7>=1)
; 0 if arg=nan (with <7>=1)
; <6>: 1 if arg=0 (with <7>=0)
; arg status for long integer
; <7>: 1 if facm will be regarded as 'signed'
; <6>: 1 if facm = 0
; <5>: always '1'
aexph .DW ; unbiased arg exponent sign extension
argext .DW
wftmp .EQU aexph ; temp. word (int2dec, fpadd, fpsub)
argsiz .EQU argsgn ; integer only: size in bytes
fcp LP ; long pointer to flaot constants
scsgn .DB ; scaling sign
scexp .DW ; scaling value
dexp .DW ; decimal exponent
dsgn .DB ; decimal float sign
pdeg .DB ; polyn. degree
powfg .EQU pdeg ; flag used by fpowxy
tlp LP ; string long pointer
fpidx .DB ; string index
tfr0 .DS 20 ; temp. float reg. 0
tfr1 .DS 20 ; temp. float reg. 1
tfr2 .DS 20 ; temp. float reg. 2
tfr3 .DS 20 ; temp. float reg. 3
tfr4 .DS 20 ; temp. float reg. 4
tfr5 .DS 20 ; temp. float reg. 5
.DS 4 ; used by xcvt: doesn't change
XCVTEND .EQU ($ - 1) ; last byte of xcvt buffer
; buffer used by decimal conversion (overlap tfr0&tfr1: 40 bytes)
fpstr .EQU tfr0 ; 40 bytes buffer
; buffer used to format a decimal string
xcvt .EQU tfr2 ; 84 bytes buffer
fcpc0 .EQU tfr5 ; constants pointer for exp. function
fcpc1 .EQU tfr5+2
fcpc2 .EQU tfr5+4
fcpp .EQU tfr5+6
fcpq .EQU tfr5+8
fcpd .EQU tfr5+10
fcqd .EQU tfr5+11
fcpolf .EQU tfr5+12 ; polynomial flag
tmdot .EQU tfr5 ; digit count after decimal dot
tmpa .EQU tfr5+2 ; temp: save A&Y
tmpy .EQU tfr5+3
tmsgn .EQU tfr5+4 ; temp.: significand sign
tmcnt .EQU tfr5+5 ; temp.: significand digits count
tesgn .EQU tfr5+6 ; temp.: exponent sign
tecnt .EQU tfr5+7 ; temp.: exponent digits count
mcand1 .EQU tfr5+8 ; multiplicand's
mcand2 .EQU tfr5+10
mcsgn .EQU tfr5+12
dvsor .EQU tfr5+14
quot .EQU tfr5+16
fpprec .DW ; precision
fpfmt .DB ; format
fpaltf .DB ; alternate format
fpcap .DB ; adding for lower case
fpstyle .DB ; flag 'F' style
fpdot .EQU pdeg ; decimal dot flag
fpoct .EQU fpfmt ; octant (circular func's)
fpcsgn .EQU fpaltf ; circular func's: argument sign
fpcot .EQU fpcap ; cotangent flag
fpasin .EQU fpcap ; asin flag
dummy .DB
.ENDS
.LIST off
; pi 4000 921f b544 42d1 8469 898c c517 01b8 = 3.1415926535897932384626433832795028
; 4000 C90FDAA22168C234C4C6628B80DC1CD2
; $D1,$1C,$DC,$80,$8B,$62,$C6,$C4,$34,$C2,$68,$21,$A2,$DA,$0F,$C9,$00,$40
; 4000 C90FDAA22168C234C4C6628B80DC1CD1 40