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