Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | - | 1 | ;; |
2 | ;; Copyright (c) 2016 Marco Granati <mg@unet.bz> |
||
3 | ;; |
||
4 | ;; Permission to use, copy, modify, and distribute this software for any |
||
5 | ;; purpose with or without fee is hereby granted, provided that the above |
||
6 | ;; copyright notice and this permission notice appear in all copies. |
||
7 | ;; |
||
8 | ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||
9 | ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||
10 | ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||
11 | ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||
12 | ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||
13 | ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||
14 | ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||
15 | ;; |
||
16 | |||
17 | ;; name: dpfpu.inc |
||
18 | ;; rev.: 2016/03/30 |
||
19 | ;; o.s. 65C816 version v1.0 |
||
20 | |||
21 | .LIST on |
||
22 | |||
23 | ; direct page for flotaing point unit |
||
24 | _DPFPU: .SECTION page0, common, ref_only, offset 0 ;FPU D.P. |
||
25 | |||
26 | MNTBITS .EQU (16*8) ; significand bits + guard bits |
||
27 | MANTSIZ .EQU 16 ; significand size |
||
28 | FREGSIZ .EQU 20 ; floating point register size |
||
29 | |||
30 | tm .DS 16 ; temp. mantissa |
||
31 | |||
32 | fsubnf .DB ; subnormal flag used by fac2dec |
||
33 | atncode .EQU fsubnf ; fatanyx octant |
||
34 | |||
35 | sgncmp .DB ; sign comparison: fac vs. arg |
||
36 | |||
37 | ; floating Point accumulator (fac) |
||
38 | facm .DS 16 ; guard bits (32 bits)+significand (80 bits) |
||
39 | facexp .DW ; fac biased exponent |
||
40 | facsgn .DB ; fac mantissa sign |
||
41 | facst .DB ; fac status for floating point |
||
42 | ; <7>: 1 if fac is invalid (nan or inf) |
||
43 | ; <6>: 1 if fac=inf (with <7>=1) |
||
44 | ; 0 if fac=nan (with <7>=1) |
||
45 | ; <6>: 1 if fac=0 (with <7>=0) |
||
46 | ; <5>: always '0' |
||
47 | |||
48 | ; fac status for long integer |
||
49 | ; <7>: 1 if facm will be regarded as 'signed' |
||
50 | ; <6>: 1 if facm = 0 |
||
51 | ; <5>: always '1' |
||
52 | |||
53 | fexph .DW ; unbiased fac exponent sign extension |
||
54 | facext .DW ; fac guard bits extension |
||
55 | wftmp2 .EQU facext |
||
56 | facsiz .EQU facsgn ; integer only: size in bytes |
||
57 | |||
58 | ; floating point operand (arg) |
||
59 | argm .DS 16 ; guard bits (32 bits)+significand (80 bits) |
||
60 | argexp .DW ; arg biased exponent |
||
61 | argsgn .DB ; arg mantissa sign |
||
62 | argst .DB ; arg status for floating point |
||
63 | ; <7>: 1 if arg is invalid (nan or inf) |
||
64 | ; <6>: 1 if arg=inf (with <7>=1) |
||
65 | ; 0 if arg=nan (with <7>=1) |
||
66 | ; <6>: 1 if arg=0 (with <7>=0) |
||
67 | |||
68 | ; arg status for long integer |
||
69 | ; <7>: 1 if facm will be regarded as 'signed' |
||
70 | ; <6>: 1 if facm = 0 |
||
71 | ; <5>: always '1' |
||
72 | |||
73 | aexph .DW ; unbiased arg exponent sign extension |
||
74 | argext .DW |
||
75 | |||
76 | wftmp .EQU aexph ; temp. word (int2dec, fpadd, fpsub) |
||
77 | argsiz .EQU argsgn ; integer only: size in bytes |
||
78 | |||
79 | fcp LP ; long pointer to flaot constants |
||
80 | scsgn .DB ; scaling sign |
||
81 | scexp .DW ; scaling value |
||
82 | dexp .DW ; decimal exponent |
||
83 | dsgn .DB ; decimal float sign |
||
84 | pdeg .DB ; polyn. degree |
||
85 | powfg .EQU pdeg ; flag used by fpowxy |
||
86 | |||
87 | tlp LP ; string long pointer |
||
88 | fpidx .DB ; string index |
||
89 | |||
90 | tfr0 .DS 20 ; temp. float reg. 0 |
||
91 | tfr1 .DS 20 ; temp. float reg. 1 |
||
92 | tfr2 .DS 20 ; temp. float reg. 2 |
||
93 | tfr3 .DS 20 ; temp. float reg. 3 |
||
94 | tfr4 .DS 20 ; temp. float reg. 4 |
||
95 | tfr5 .DS 20 ; temp. float reg. 5 |
||
96 | .DS 4 ; used by xcvt: doesn't change |
||
97 | |||
98 | XCVTEND .EQU ($ - 1) ; last byte of xcvt buffer |
||
99 | |||
100 | ; buffer used by decimal conversion (overlap tfr0&tfr1: 40 bytes) |
||
101 | fpstr .EQU tfr0 ; 40 bytes buffer |
||
102 | ; buffer used to format a decimal string |
||
103 | xcvt .EQU tfr2 ; 84 bytes buffer |
||
104 | |||
105 | fcpc0 .EQU tfr5 ; constants pointer for exp. function |
||
106 | fcpc1 .EQU tfr5+2 |
||
107 | fcpc2 .EQU tfr5+4 |
||
108 | fcpp .EQU tfr5+6 |
||
109 | fcpq .EQU tfr5+8 |
||
110 | fcpd .EQU tfr5+10 |
||
111 | fcqd .EQU tfr5+11 |
||
112 | fcpolf .EQU tfr5+12 ; polynomial flag |
||
113 | |||
114 | tmdot .EQU tfr5 ; digit count after decimal dot |
||
115 | tmpa .EQU tfr5+2 ; temp: save A&Y |
||
116 | tmpy .EQU tfr5+3 |
||
117 | tmsgn .EQU tfr5+4 ; temp.: significand sign |
||
118 | tmcnt .EQU tfr5+5 ; temp.: significand digits count |
||
119 | tesgn .EQU tfr5+6 ; temp.: exponent sign |
||
120 | tecnt .EQU tfr5+7 ; temp.: exponent digits count |
||
121 | |||
122 | mcand1 .EQU tfr5+8 ; multiplicand's |
||
123 | mcand2 .EQU tfr5+10 |
||
124 | mcsgn .EQU tfr5+12 |
||
125 | dvsor .EQU tfr5+14 |
||
126 | quot .EQU tfr5+16 |
||
127 | |||
128 | fpprec .DW ; precision |
||
129 | fpfmt .DB ; format |
||
130 | fpaltf .DB ; alternate format |
||
131 | fpcap .DB ; adding for lower case |
||
132 | fpstyle .DB ; flag 'F' style |
||
133 | fpdot .EQU pdeg ; decimal dot flag |
||
134 | fpoct .EQU fpfmt ; octant (circular func's) |
||
135 | fpcsgn .EQU fpaltf ; circular func's: argument sign |
||
136 | fpcot .EQU fpcap ; cotangent flag |
||
137 | fpasin .EQU fpcap ; asin flag |
||
138 | |||
139 | dummy .DB |
||
140 | |||
141 | .ENDS |
||
142 | .LIST off |
||
143 | |||
144 | ; pi 4000 921f b544 42d1 8469 898c c517 01b8 = 3.1415926535897932384626433832795028 |
||
145 | ; 4000 C90FDAA22168C234C4C6628B80DC1CD2 |
||
146 | ; $D1,$1C,$DC,$80,$8B,$62,$C6,$C4,$34,$C2,$68,$21,$A2,$DA,$0F,$C9,$00,$40 |
||
147 | ; 4000 C90FDAA22168C234C4C6628B80DC1CD1 40 |