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