fpsp.h revision 1.2 1 1.2 cgd * $NetBSD: fpsp.h,v 1.2 1994/10/26 07:49:04 cgd Exp $
2 1.2 cgd
3 1.1 mycroft * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 1.1 mycroft * M68000 Hi-Performance Microprocessor Division
5 1.1 mycroft * M68040 Software Package
6 1.1 mycroft *
7 1.1 mycroft * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
8 1.1 mycroft * All rights reserved.
9 1.1 mycroft *
10 1.1 mycroft * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11 1.1 mycroft * To the maximum extent permitted by applicable law,
12 1.1 mycroft * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13 1.1 mycroft * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14 1.1 mycroft * PARTICULAR PURPOSE and any warranty against infringement with
15 1.1 mycroft * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16 1.1 mycroft * and any accompanying written materials.
17 1.1 mycroft *
18 1.1 mycroft * To the maximum extent permitted by applicable law,
19 1.1 mycroft * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20 1.1 mycroft * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21 1.1 mycroft * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22 1.1 mycroft * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23 1.1 mycroft * SOFTWARE. Motorola assumes no responsibility for the maintenance
24 1.1 mycroft * and support of the SOFTWARE.
25 1.1 mycroft *
26 1.1 mycroft * You are hereby granted a copyright license to use, modify, and
27 1.1 mycroft * distribute the SOFTWARE so long as this entire notice is retained
28 1.1 mycroft * without alteration in any modified and/or redistributed versions,
29 1.1 mycroft * and that such modified versions are clearly identified as such.
30 1.1 mycroft * No licenses are granted by implication, estoppel or otherwise
31 1.1 mycroft * under any patents or trademarks of Motorola, Inc.
32 1.1 mycroft
33 1.1 mycroft *
34 1.1 mycroft * fpsp.h 3.3 3.3
35 1.1 mycroft *
36 1.1 mycroft
37 1.1 mycroft * fpsp.h --- stack frame offsets during FPSP exception handling
38 1.1 mycroft *
39 1.1 mycroft * These equates are used to access the exception frame, the fsave
40 1.1 mycroft * frame and any local variables needed by the FPSP package.
41 1.1 mycroft *
42 1.1 mycroft * All FPSP handlers begin by executing:
43 1.1 mycroft *
44 1.1 mycroft * link a6,#-LOCAL_SIZE
45 1.1 mycroft * fsave -(a7)
46 1.1 mycroft * movem.l d0-d1/a0-a1,USER_DA(a6)
47 1.1 mycroft * fmovem.x fp0-fp3,USER_FP0(a6)
48 1.1 mycroft * fmove.l fpsr/fpcr/fpiar,USER_FPSR(a6)
49 1.1 mycroft *
50 1.1 mycroft * After initialization, the stack looks like this:
51 1.1 mycroft *
52 1.1 mycroft * A7 ---> +-------------------------------+
53 1.1 mycroft * | |
54 1.1 mycroft * | FPU fsave area |
55 1.1 mycroft * | |
56 1.1 mycroft * +-------------------------------+
57 1.1 mycroft * | |
58 1.1 mycroft * | FPSP Local Variables |
59 1.1 mycroft * | including |
60 1.1 mycroft * | saved registers |
61 1.1 mycroft * | |
62 1.1 mycroft * +-------------------------------+
63 1.1 mycroft * A6 ---> | Saved A6 |
64 1.1 mycroft * +-------------------------------+
65 1.1 mycroft * | |
66 1.1 mycroft * | Exception Frame |
67 1.1 mycroft * | |
68 1.1 mycroft * | |
69 1.1 mycroft *
70 1.1 mycroft * Positive offsets from A6 refer to the exception frame. Negative
71 1.1 mycroft * offsets refer to the Local Variable area and the fsave area.
72 1.1 mycroft * The fsave frame is also accessible 'from the top' via A7.
73 1.1 mycroft *
74 1.1 mycroft * On exit, the handlers execute:
75 1.1 mycroft *
76 1.1 mycroft * movem.l USER_DA(a6),d0-d1/a0-a1
77 1.1 mycroft * fmovem.x USER_FP0(a6),fp0-fp3
78 1.1 mycroft * fmove.l USER_FPSR(a6),fpsr/fpcr/fpiar
79 1.1 mycroft * frestore (a7)+
80 1.1 mycroft * unlk a6
81 1.1 mycroft *
82 1.1 mycroft * and then either 'bra fpsp_done' if the exception was completely
83 1.1 mycroft * handled by the package, or 'bra real_xxxx' which is an external
84 1.1 mycroft * label to a routine that will process a real exception of the
85 1.1 mycroft * type that was generated. Some handlers may omit the 'frestore'
86 1.1 mycroft * if the FPU state after the exception is idle.
87 1.1 mycroft *
88 1.1 mycroft * Sometimes the exception handler will transform the fsave area
89 1.1 mycroft * because it needs to report an exception back to the user. This
90 1.1 mycroft * can happen if the package is entered for an unimplemented float
91 1.1 mycroft * instruction that generates (say) an underflow. Alternatively,
92 1.1 mycroft * a second fsave frame can be pushed onto the stack and the
93 1.1 mycroft * handler exit code will reload the new frame and discard the old.
94 1.1 mycroft *
95 1.1 mycroft * The registers d0, d1, a0, a1 and fp0-fp3 are always saved and
96 1.1 mycroft * restored from the 'local variable' area and can be used as
97 1.1 mycroft * temporaries. If a routine needs to change any
98 1.1 mycroft * of these registers, it should modify the saved copy and let
99 1.1 mycroft * the handler exit code restore the value.
100 1.1 mycroft *
101 1.1 mycroft *----------------------------------------------------------------------
102 1.1 mycroft *
103 1.1 mycroft * Local Variables on the stack
104 1.1 mycroft *
105 1.1 mycroft LOCAL_SIZE equ 192 ;bytes needed for local variables
106 1.1 mycroft LV equ -LOCAL_SIZE ;convenient base value
107 1.1 mycroft *
108 1.1 mycroft USER_DA equ LV+0 ;save space for D0-D1,A0-A1
109 1.1 mycroft USER_D0 equ LV+0 ;saved user D0
110 1.1 mycroft USER_D1 equ LV+4 ;saved user D1
111 1.1 mycroft USER_A0 equ LV+8 ;saved user A0
112 1.1 mycroft USER_A1 equ LV+12 ;saved user A1
113 1.1 mycroft USER_FP0 equ LV+16 ;saved user FP0
114 1.1 mycroft USER_FP1 equ LV+28 ;saved user FP1
115 1.1 mycroft USER_FP2 equ LV+40 ;saved user FP2
116 1.1 mycroft USER_FP3 equ LV+52 ;saved user FP3
117 1.1 mycroft USER_FPCR equ LV+64 ;saved user FPCR
118 1.1 mycroft FPCR_ENABLE equ USER_FPCR+2 ; FPCR exception enable
119 1.1 mycroft FPCR_MODE equ USER_FPCR+3 ; FPCR rounding mode control
120 1.1 mycroft USER_FPSR equ LV+68 ;saved user FPSR
121 1.1 mycroft FPSR_CC equ USER_FPSR+0 ; FPSR condition code
122 1.1 mycroft FPSR_QBYTE equ USER_FPSR+1 ; FPSR quotient
123 1.1 mycroft FPSR_EXCEPT equ USER_FPSR+2 ; FPSR exception
124 1.1 mycroft FPSR_AEXCEPT equ USER_FPSR+3 ; FPSR accrued exception
125 1.1 mycroft USER_FPIAR equ LV+72 ;saved user FPIAR
126 1.1 mycroft FP_SCR1 equ LV+76 ;room for a temporary float value
127 1.1 mycroft FP_SCR2 equ LV+92 ;room for a temporary float value
128 1.1 mycroft L_SCR1 equ LV+108 ;room for a temporary long value
129 1.1 mycroft L_SCR2 equ LV+112 ;room for a temporary long value
130 1.1 mycroft STORE_FLG equ LV+116
131 1.1 mycroft BINDEC_FLG equ LV+117 ;used in bindec
132 1.1 mycroft DNRM_FLG equ LV+118 ;used in res_func
133 1.1 mycroft RES_FLG equ LV+119 ;used in res_func
134 1.1 mycroft DY_MO_FLG equ LV+120 ;dyadic/monadic flag
135 1.1 mycroft UFLG_TMP equ LV+121 ;temporary for uflag errata
136 1.1 mycroft CU_ONLY equ LV+122 ;cu-only flag
137 1.1 mycroft VER_TMP equ LV+123 ;temp holding for version number
138 1.1 mycroft L_SCR3 equ LV+124 ;room for a temporary long value
139 1.1 mycroft FP_SCR3 equ LV+128 ;room for a temporary float value
140 1.1 mycroft FP_SCR4 equ LV+144 ;room for a temporary float value
141 1.1 mycroft FP_SCR5 equ LV+160 ;room for a temporary float value
142 1.1 mycroft FP_SCR6 equ LV+176
143 1.1 mycroft *
144 1.1 mycroft *NEXT equ LV+192 ;need to increase LOCAL_SIZE
145 1.1 mycroft *
146 1.1 mycroft *--------------------------------------------------------------------------
147 1.1 mycroft *
148 1.1 mycroft * fsave offsets and bit definitions
149 1.1 mycroft *
150 1.1 mycroft * Offsets are defined from the end of an fsave because the last 10
151 1.1 mycroft * words of a busy frame are the same as the unimplemented frame.
152 1.1 mycroft *
153 1.1 mycroft CU_SAVEPC equ LV-92 ;micro-pc for CU (1 byte)
154 1.1 mycroft FPR_DIRTY_BITS equ LV-91 ;fpr dirty bits
155 1.1 mycroft *
156 1.1 mycroft WBTEMP equ LV-76 ;write back temp (12 bytes)
157 1.1 mycroft WBTEMP_EX equ WBTEMP ;wbtemp sign and exponent (2 bytes)
158 1.1 mycroft WBTEMP_HI equ WBTEMP+4 ;wbtemp mantissa [63:32] (4 bytes)
159 1.1 mycroft WBTEMP_LO equ WBTEMP+8 ;wbtemp mantissa [31:00] (4 bytes)
160 1.1 mycroft *
161 1.1 mycroft WBTEMP_SGN equ WBTEMP+2 ;used to store sign
162 1.1 mycroft *
163 1.1 mycroft FPSR_SHADOW equ LV-64 ;fpsr shadow reg
164 1.1 mycroft *
165 1.1 mycroft FPIARCU equ LV-60 ;Instr. addr. reg. for CU (4 bytes)
166 1.1 mycroft *
167 1.1 mycroft CMDREG2B equ LV-52 ;cmd reg for machine 2
168 1.1 mycroft CMDREG3B equ LV-48 ;cmd reg for E3 exceptions (2 bytes)
169 1.1 mycroft *
170 1.1 mycroft NMNEXC equ LV-44 ;NMNEXC (unsup,snan bits only)
171 1.1 mycroft nmn_unsup_bit equ 1
172 1.1 mycroft nmn_snan_bit equ 0
173 1.1 mycroft *
174 1.1 mycroft NMCEXC equ LV-43 ;NMNEXC & NMCEXC
175 1.1 mycroft nmn_operr_bit equ 7
176 1.1 mycroft nmn_ovfl_bit equ 6
177 1.1 mycroft nmn_unfl_bit equ 5
178 1.1 mycroft nmc_unsup_bit equ 4
179 1.1 mycroft nmc_snan_bit equ 3
180 1.1 mycroft nmc_operr_bit equ 2
181 1.1 mycroft nmc_ovfl_bit equ 1
182 1.1 mycroft nmc_unfl_bit equ 0
183 1.1 mycroft *
184 1.1 mycroft STAG equ LV-40 ;source tag (1 byte)
185 1.1 mycroft WBTEMP_GRS equ LV-40 ;alias wbtemp guard, round, sticky
186 1.1 mycroft guard_bit equ 1 ;guard bit is bit number 1
187 1.1 mycroft round_bit equ 0 ;round bit is bit number 0
188 1.1 mycroft stag_mask equ $E0 ;upper 3 bits are source tag type
189 1.1 mycroft denorm_bit equ 7 ;bit determins if denorm or unnorm
190 1.1 mycroft etemp15_bit equ 4 ;etemp exponent bit #15
191 1.1 mycroft wbtemp66_bit equ 2 ;wbtemp mantissa bit #66
192 1.1 mycroft wbtemp1_bit equ 1 ;wbtemp mantissa bit #1
193 1.1 mycroft wbtemp0_bit equ 0 ;wbtemp mantissa bit #0
194 1.1 mycroft *
195 1.1 mycroft STICKY equ LV-39 ;holds sticky bit
196 1.1 mycroft sticky_bit equ 7
197 1.1 mycroft *
198 1.1 mycroft CMDREG1B equ LV-36 ;cmd reg for E1 exceptions (2 bytes)
199 1.1 mycroft kfact_bit equ 12 ;distinguishes static/dynamic k-factor
200 1.1 mycroft * ;on packed move out's. NOTE: this
201 1.1 mycroft * ;equate only works when CMDREG1B is in
202 1.1 mycroft * ;a register.
203 1.1 mycroft *
204 1.1 mycroft CMDWORD equ LV-35 ;command word in cmd1b
205 1.1 mycroft direction_bit equ 5 ;bit 0 in opclass
206 1.1 mycroft size_bit2 equ 12 ;bit 2 in size field
207 1.1 mycroft *
208 1.1 mycroft DTAG equ LV-32 ;dest tag (1 byte)
209 1.1 mycroft dtag_mask equ $E0 ;upper 3 bits are dest type tag
210 1.1 mycroft fptemp15_bit equ 4 ;fptemp exponent bit #15
211 1.1 mycroft *
212 1.1 mycroft WB_BYTE equ LV-31 ;holds WBTE15 bit (1 byte)
213 1.1 mycroft wbtemp15_bit equ 4 ;wbtemp exponent bit #15
214 1.1 mycroft *
215 1.1 mycroft E_BYTE equ LV-28 ;holds E1 and E3 bits (1 byte)
216 1.1 mycroft E1 equ 2 ;which bit is E1 flag
217 1.1 mycroft E3 equ 1 ;which bit is E3 flag
218 1.1 mycroft SFLAG equ 0 ;which bit is S flag
219 1.1 mycroft *
220 1.1 mycroft T_BYTE equ LV-27 ;holds T and U bits (1 byte)
221 1.1 mycroft XFLAG equ 7 ;which bit is X flag
222 1.1 mycroft UFLAG equ 5 ;which bit is U flag
223 1.1 mycroft TFLAG equ 4 ;which bit is T flag
224 1.1 mycroft *
225 1.1 mycroft FPTEMP equ LV-24 ;fptemp (12 bytes)
226 1.1 mycroft FPTEMP_EX equ FPTEMP ;fptemp sign and exponent (2 bytes)
227 1.1 mycroft FPTEMP_HI equ FPTEMP+4 ;fptemp mantissa [63:32] (4 bytes)
228 1.1 mycroft FPTEMP_LO equ FPTEMP+8 ;fptemp mantissa [31:00] (4 bytes)
229 1.1 mycroft *
230 1.1 mycroft FPTEMP_SGN equ FPTEMP+2 ;used to store sign
231 1.1 mycroft *
232 1.1 mycroft ETEMP equ LV-12 ;etemp (12 bytes)
233 1.1 mycroft ETEMP_EX equ ETEMP ;etemp sign and exponent (2 bytes)
234 1.1 mycroft ETEMP_HI equ ETEMP+4 ;etemp mantissa [63:32] (4 bytes)
235 1.1 mycroft ETEMP_LO equ ETEMP+8 ;etemp mantissa [31:00] (4 bytes)
236 1.1 mycroft *
237 1.1 mycroft ETEMP_SGN equ ETEMP+2 ;used to store sign
238 1.1 mycroft *
239 1.1 mycroft EXC_SR equ 4 ;exception frame status register
240 1.1 mycroft EXC_PC equ 6 ;exception frame program counter
241 1.1 mycroft EXC_VEC equ 10 ;exception frame vector (format+vector#)
242 1.1 mycroft EXC_EA equ 12 ;exception frame effective address
243 1.1 mycroft *
244 1.1 mycroft *--------------------------------------------------------------------------
245 1.1 mycroft *
246 1.1 mycroft * FPSR/FPCR bits
247 1.1 mycroft *
248 1.1 mycroft neg_bit equ 3 negative result
249 1.1 mycroft z_bit equ 2 zero result
250 1.1 mycroft inf_bit equ 1 infinity result
251 1.1 mycroft nan_bit equ 0 not-a-number result
252 1.1 mycroft *
253 1.1 mycroft q_sn_bit equ 7 sign bit of quotient byte
254 1.1 mycroft *
255 1.1 mycroft bsun_bit equ 7 branch on unordered
256 1.1 mycroft snan_bit equ 6 signalling nan
257 1.1 mycroft operr_bit equ 5 operand error
258 1.1 mycroft ovfl_bit equ 4 overflow
259 1.1 mycroft unfl_bit equ 3 underflow
260 1.1 mycroft dz_bit equ 2 divide by zero
261 1.1 mycroft inex2_bit equ 1 inexact result 2
262 1.1 mycroft inex1_bit equ 0 inexact result 1
263 1.1 mycroft *
264 1.1 mycroft aiop_bit equ 7 accrued illegal operation
265 1.1 mycroft aovfl_bit equ 6 accrued overflow
266 1.1 mycroft aunfl_bit equ 5 accrued underflow
267 1.1 mycroft adz_bit equ 4 accrued divide by zero
268 1.1 mycroft ainex_bit equ 3 accrued inexact
269 1.1 mycroft *
270 1.1 mycroft * FPSR individual bit masks
271 1.1 mycroft *
272 1.1 mycroft neg_mask equ $08000000
273 1.1 mycroft z_mask equ $04000000
274 1.1 mycroft inf_mask equ $02000000
275 1.1 mycroft nan_mask equ $01000000
276 1.1 mycroft *
277 1.1 mycroft bsun_mask equ $00008000
278 1.1 mycroft snan_mask equ $00004000
279 1.1 mycroft operr_mask equ $00002000
280 1.1 mycroft ovfl_mask equ $00001000
281 1.1 mycroft unfl_mask equ $00000800
282 1.1 mycroft dz_mask equ $00000400
283 1.1 mycroft inex2_mask equ $00000200
284 1.1 mycroft inex1_mask equ $00000100
285 1.1 mycroft *
286 1.1 mycroft aiop_mask equ $00000080 accrued illegal operation
287 1.1 mycroft aovfl_mask equ $00000040 accrued overflow
288 1.1 mycroft aunfl_mask equ $00000020 accrued underflow
289 1.1 mycroft adz_mask equ $00000010 accrued divide by zero
290 1.1 mycroft ainex_mask equ $00000008 accrued inexact
291 1.1 mycroft *
292 1.1 mycroft * FPSR combinations used in the FPSP
293 1.1 mycroft *
294 1.1 mycroft dzinf_mask equ inf_mask+dz_mask+adz_mask
295 1.1 mycroft opnan_mask equ nan_mask+operr_mask+aiop_mask
296 1.1 mycroft nzi_mask equ $01ffffff clears N, Z, and I
297 1.1 mycroft unfinx_mask equ unfl_mask+inex2_mask+aunfl_mask+ainex_mask
298 1.1 mycroft unf2inx_mask equ unfl_mask+inex2_mask+ainex_mask
299 1.1 mycroft ovfinx_mask equ ovfl_mask+inex2_mask+aovfl_mask+ainex_mask
300 1.1 mycroft inx1a_mask equ inex1_mask+ainex_mask
301 1.1 mycroft inx2a_mask equ inex2_mask+ainex_mask
302 1.1 mycroft snaniop_mask equ nan_mask+snan_mask+aiop_mask
303 1.1 mycroft naniop_mask equ nan_mask+aiop_mask
304 1.1 mycroft neginf_mask equ neg_mask+inf_mask
305 1.1 mycroft infaiop_mask equ inf_mask+aiop_mask
306 1.1 mycroft negz_mask equ neg_mask+z_mask
307 1.1 mycroft opaop_mask equ operr_mask+aiop_mask
308 1.1 mycroft unfl_inx_mask equ unfl_mask+aunfl_mask+ainex_mask
309 1.1 mycroft ovfl_inx_mask equ ovfl_mask+aovfl_mask+ainex_mask
310 1.1 mycroft *
311 1.1 mycroft *--------------------------------------------------------------------------
312 1.1 mycroft *
313 1.1 mycroft * FPCR rounding modes
314 1.1 mycroft *
315 1.1 mycroft x_mode equ $00 round to extended
316 1.1 mycroft s_mode equ $40 round to single
317 1.1 mycroft d_mode equ $80 round to double
318 1.1 mycroft *
319 1.1 mycroft rn_mode equ $00 round nearest
320 1.1 mycroft rz_mode equ $10 round to zero
321 1.1 mycroft rm_mode equ $20 round to minus infinity
322 1.1 mycroft rp_mode equ $30 round to plus infinity
323 1.1 mycroft *
324 1.1 mycroft *--------------------------------------------------------------------------
325 1.1 mycroft *
326 1.1 mycroft * Miscellaneous equates
327 1.1 mycroft *
328 1.1 mycroft signan_bit equ 6 signalling nan bit in mantissa
329 1.1 mycroft sign_bit equ 7
330 1.1 mycroft *
331 1.1 mycroft rnd_stky_bit equ 29 round/sticky bit of mantissa
332 1.1 mycroft * this can only be used if in a data register
333 1.1 mycroft sx_mask equ $01800000 set s and x bits in word $48
334 1.1 mycroft *
335 1.1 mycroft LOCAL_EX equ 0
336 1.1 mycroft LOCAL_SGN equ 2
337 1.1 mycroft LOCAL_HI equ 4
338 1.1 mycroft LOCAL_LO equ 8
339 1.1 mycroft LOCAL_GRS equ 12 valid ONLY for FP_SCR1, FP_SCR2
340 1.1 mycroft *
341 1.1 mycroft *
342 1.1 mycroft norm_tag equ $00 tag bits in {7:5} position
343 1.1 mycroft zero_tag equ $20
344 1.1 mycroft inf_tag equ $40
345 1.1 mycroft nan_tag equ $60
346 1.1 mycroft dnrm_tag equ $80
347 1.1 mycroft *
348 1.1 mycroft * fsave sizes and formats
349 1.1 mycroft *
350 1.1 mycroft VER_4 equ $40 fpsp compatible version numbers
351 1.1 mycroft * are in the $40s {$40-$4f}
352 1.1 mycroft VER_40 equ $40 original version number
353 1.1 mycroft VER_41 equ $41 revision version number
354 1.1 mycroft *
355 1.1 mycroft BUSY_SIZE equ 100 size of busy frame
356 1.1 mycroft BUSY_FRAME equ LV-BUSY_SIZE start of busy frame
357 1.1 mycroft *
358 1.1 mycroft UNIMP_40_SIZE equ 44 size of orig unimp frame
359 1.1 mycroft UNIMP_41_SIZE equ 52 size of rev unimp frame
360 1.1 mycroft *
361 1.1 mycroft IDLE_SIZE equ 4 size of idle frame
362 1.1 mycroft IDLE_FRAME equ LV-IDLE_SIZE start of idle frame
363 1.1 mycroft *
364 1.1 mycroft * exception vectors
365 1.1 mycroft *
366 1.1 mycroft TRACE_VEC equ $2024 trace trap
367 1.1 mycroft FLINE_VEC equ $002C 'real' F-line
368 1.1 mycroft UNIMP_VEC equ $202C unimplemented
369 1.1 mycroft INEX_VEC equ $00C4
370 1.1 mycroft *
371 1.1 mycroft dbl_thresh equ $3C01
372 1.1 mycroft sgl_thresh equ $3F81
373 1.1 mycroft *
374