1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
|
| fpsp.h 3.3 3.3
|
| Copyright (C) Motorola, Inc. 1990
| All Rights Reserved
|
| THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
| The copyright notice above does not evidence any
| actual or intended publication of such source code.
| fpsp.h --- stack frame offsets during FPSP exception handling
|
| These equates are used to access the exception frame, the fsave
| frame and any local variables needed by the FPSP package.
|
| All FPSP handlers begin by executing:
|
| link a6,#-LOCAL_SIZE
| fsave -(a7)
| movem.l d0-d1/a0-a1,USER_DA(a6)
| fmovem.x fp0-fp3,USER_FP0(a6)
| fmove.l fpsr/fpcr/fpiar,USER_FPSR(a6)
|
| After initialization, the stack looks like this:
|
| A7 ---> +-------------------------------+
| | |
| | FPU fsave area |
| | |
| +-------------------------------+
| | |
| | FPSP Local Variables |
| | including |
| | saved registers |
| | |
| +-------------------------------+
| A6 ---> | Saved A6 |
| +-------------------------------+
| | |
| | Exception Frame |
| | |
| | |
|
| Positive offsets from A6 refer to the exception frame. Negative
| offsets refer to the Local Variable area and the fsave area.
| The fsave frame is also accessible from the top via A7.
|
| On exit, the handlers execute:
|
| movem.l USER_DA(a6),d0-d1/a0-a1
| fmovem.x USER_FP0(a6),fp0-fp3
| fmove.l USER_FPSR(a6),fpsr/fpcr/fpiar
| frestore (a7)+
| unlk a6
|
| and then either "bra fpsp_done" if the exception was completely
| handled by the package, or "bra real_xxxx" which is an external
| label to a routine that will process a real exception of the
| type that was generated. Some handlers may omit the "frestore"
| if the FPU state after the exception is idle.
|
| Sometimes the exception handler will transform the fsave area
| because it needs to report an exception back to the user. This
| can happen if the package is entered for an unimplemented float
| instruction that generates (say) an underflow. Alternatively,
| a second fsave frame can be pushed onto the stack and the
| handler exit code will reload the new frame and discard the old.
|
| The registers d0, d1, a0, a1 and fp0-fp3 are always saved and
| restored from the "local variable" area and can be used as
| temporaries. If a routine needs to change any
| of these registers, it should modify the saved copy and let
| the handler exit code restore the value.
|
|----------------------------------------------------------------------
|
| Local Variables on the stack
|
.set LOCAL_SIZE,192 | bytes needed for local variables
.set LV,-LOCAL_SIZE | convenient base value
|
.set USER_DA,LV+0 | save space for D0-D1,A0-A1
.set USER_D0,LV+0 | saved user D0
.set USER_D1,LV+4 | saved user D1
.set USER_A0,LV+8 | saved user A0
.set USER_A1,LV+12 | saved user A1
.set USER_FP0,LV+16 | saved user FP0
.set USER_FP1,LV+28 | saved user FP1
.set USER_FP2,LV+40 | saved user FP2
.set USER_FP3,LV+52 | saved user FP3
.set USER_FPCR,LV+64 | saved user FPCR
.set FPCR_ENABLE,USER_FPCR+2 | FPCR exception enable
.set FPCR_MODE,USER_FPCR+3 | FPCR rounding mode control
.set USER_FPSR,LV+68 | saved user FPSR
.set FPSR_CC,USER_FPSR+0 | FPSR condition code
.set FPSR_QBYTE,USER_FPSR+1 | FPSR quotient
.set FPSR_EXCEPT,USER_FPSR+2 | FPSR exception
.set FPSR_AEXCEPT,USER_FPSR+3 | FPSR accrued exception
.set USER_FPIAR,LV+72 | saved user FPIAR
.set FP_SCR1,LV+76 | room for a temporary float value
.set FP_SCR2,LV+92 | room for a temporary float value
.set L_SCR1,LV+108 | room for a temporary long value
.set L_SCR2,LV+112 | room for a temporary long value
.set STORE_FLG,LV+116
.set BINDEC_FLG,LV+117 | used in bindec
.set DNRM_FLG,LV+118 | used in res_func
.set RES_FLG,LV+119 | used in res_func
.set DY_MO_FLG,LV+120 | dyadic/monadic flag
.set UFLG_TMP,LV+121 | temporary for uflag errata
.set CU_ONLY,LV+122 | cu-only flag
.set VER_TMP,LV+123 | temp holding for version number
.set L_SCR3,LV+124 | room for a temporary long value
.set FP_SCR3,LV+128 | room for a temporary float value
.set FP_SCR4,LV+144 | room for a temporary float value
.set FP_SCR5,LV+160 | room for a temporary float value
.set FP_SCR6,LV+176
|
|NEXT equ LV+192 ;need to increase LOCAL_SIZE
|
|--------------------------------------------------------------------------
|
| fsave offsets and bit definitions
|
| Offsets are defined from the end of an fsave because the last 10
| words of a busy frame are the same as the unimplemented frame.
|
.set CU_SAVEPC,LV-92 | micro-pc for CU (1 byte)
.set FPR_DIRTY_BITS,LV-91 | fpr dirty bits
|
.set WBTEMP,LV-76 | write back temp (12 bytes)
.set WBTEMP_EX,WBTEMP | wbtemp sign and exponent (2 bytes)
.set WBTEMP_HI,WBTEMP+4 | wbtemp mantissa [63:32]
|