4 | fpsp_ovfl --- FPSP handler for overflow exception
6 | Overflow occurs when a floating-point intermediate result is
7 | too large to be represented in a floating-point data register,
8 | or when storing to memory, the contents of a floating-point
9 | data register are too large to be represented in the
12 | Trap disabled results
14 | If the instruction is move_out, then garbage is stored in the
15 | destination. If the instruction is not move_out, then the
16 | destination is not affected. For 68881 compatibility, the
17 | following values should be stored at the destination, based
18 | on the current rounding mode:
20 | RN Infinity with the sign of the intermediate result.
21 | RZ Largest magnitude number, with the sign of the
22 | intermediate result.
23 | RM For pos overflow, the largest pos number. For neg overflow,
25 | RP For pos overflow, +infinity. For neg overflow, the largest
28 | Trap enabled results
29 | All trap disabled code applies. In addition the exceptional
30 | operand needs to be made available to the users exception handler
31 | with a bias of $6000 subtracted from the exponent.
35 | Copyright (C) Motorola, Inc. 1990
38 | For details on the license for this file, please see the
39 | file, README, in this same directory.
41 X_OVFL: |idnt 2,1 | Motorola 040 Floating Point Software Package
60 moveml %d0-%d1/%a0-%a1,USER_DA(%a6)
61 fmovemx %fp0-%fp3,USER_FP0(%a6)
62 fmoveml %fpcr/%fpsr/%fpiar,USER_FPCR(%a6)
65 | The 040 doesn't set the AINEX bit in the FPSR, the following
66 | line temporarily rectifies this error.
68 bsetb #ainex_bit,FPSR_AEXCEPT(%a6)
70 bsrl ovf_adj |denormalize, round & store interm op
72 | if overflow traps not enabled check for inexact exception
74 btstb #ovfl_bit,FPCR_ENABLE(%a6)
79 bfextu CMDREG3B(%a6){#6:#3},%d0 |get dest reg no
80 bclrb %d0,FPR_DIRTY_BITS(%a6) |clr dest dirty bit
82 movel USER_FPSR(%a6),FPSR_SHADOW(%a6)
83 orl #sx_mask,E_BYTE(%a6)
85 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
86 fmovemx USER_FP0(%a6),%fp0-%fp3
87 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
92 | It is possible to have either inex2 or inex1 exceptions with the
93 | ovfl. If the inex enable bit is set in the FPCR, and either
94 | inex2 or inex1 occurred, we must clean up and branch to the
98 | move.b FPCR_ENABLE(%a6),%d0
99 | and.b FPSR_EXCEPT(%a6),%d0
101 btstb #inex2_bit,FPCR_ENABLE(%a6)
104 | Inexact enabled and reported, and we must take an inexact exception.
107 btstb #E3,E_BYTE(%a6)
109 bfextu CMDREG3B(%a6){#6:#3},%d0 |get dest reg no
110 bclrb %d0,FPR_DIRTY_BITS(%a6) |clr dest dirty bit
112 movel USER_FPSR(%a6),FPSR_SHADOW(%a6)
113 orl #sx_mask,E_BYTE(%a6)
115 moveb #INEX_VEC,EXC_VEC+1(%a6)
116 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
117 fmovemx USER_FP0(%a6),%fp0-%fp3
118 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
124 bclrb #E3,E_BYTE(%a6) |test and clear E3 bit
127 | Clear dirty bit on dest resister in the frame before branching
130 bfextu CMDREG3B(%a6){#6:#3},%d0 |get dest reg no
131 bclrb %d0,FPR_DIRTY_BITS(%a6) |clr dest dirty bit
132 bsrl b1238_fix |test for bug1238 case
134 movel USER_FPSR(%a6),FPSR_SHADOW(%a6)
135 orl #sx_mask,E_BYTE(%a6)
136 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
137 fmovemx USER_FP0(%a6),%fp0-%fp3
138 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
143 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
144 fmovemx USER_FP0(%a6),%fp0-%fp3
145 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
154 | Have a0 point to the correct operand.
156 btstb #E3,E_BYTE(%a6) |test E3 bit
165 bclrb #sign_bit,LOCAL_EX(%a0)
168 bsrl g_opcls |returns opclass in d0
169 cmpiw #3,%d0 |check for opclass3
173 | FPSR_CC is saved and restored because ovf_r_x3 affects it. The
174 | CCs are defined to be 'not affected' for the opclass3 instruction.
176 moveb FPSR_CC(%a6),L_SCR1(%a6)
177 bsrl ovf_r_x3 |returns a0 pointing to result
178 moveb L_SCR1(%a6),FPSR_CC(%a6)
179 bral store |stores to memory or register
182 bsrl ovf_r_x2 |returns a0 pointing to result
183 bral store |stores to memory or register