4 | fpsp_snan --- FPSP handler for signalling NAN exception
6 | SNAN for float -> integer conversions (integer conversion of
7 | an SNAN) is a non-maskable run-time exception.
9 | For trap disabled the 040 does the following:
10 | If the dest data format is s, d, or x, then the SNAN bit in the NAN
11 | is set to one and the resulting non-signaling NAN (truncated if
12 | necessary) is transferred to the dest. If the dest format is b, w,
13 | or l, then garbage is written to the dest (actually the upper 32 bits
14 | of the mantissa are sent to the integer unit).
16 | For trap enabled the 040 does the following:
17 | If the inst is move_out, then the results are the same as for trap
18 | disabled with the exception posted. If the instruction is not move_
19 | out, the dest. is not modified, and the exception is posted.
22 | Copyright (C) Motorola, Inc. 1990
25 | For details on the license for this file, please see the
26 | file, README, in this same directory.
28 X_SNAN: |idnt 2,1 | Motorola 040 Floating Point Software Package
45 moveml %d0-%d1/%a0-%a1,USER_DA(%a6)
46 fmovemx %fp0-%fp3,USER_FP0(%a6)
47 fmoveml %fpcr/%fpsr/%fpiar,USER_FPCR(%a6)
50 | Check if trap enabled
52 btstb #snan_bit,FPCR_ENABLE(%a6)
53 bnes ena |If enabled, then branch
55 bsrl move_out |else SNAN disabled
57 | It is possible to have an inex1 exception with the
58 | snan. If the inex enable bit is set in the FPCR, and either
59 | inex2 or inex1 occurred, we must clean up and branch to the
63 moveb FPCR_ENABLE(%a6),%d0
64 andb FPSR_EXCEPT(%a6),%d0
68 | Inexact enabled and reported, and we must take an inexact exception.
71 moveb #INEX_VEC,EXC_VEC+1(%a6)
72 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
73 fmovemx USER_FP0(%a6),%fp0-%fp3
74 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
79 | SNAN is enabled. Check if inst is move_out.
80 | Make any corrections to the 040 output as necessary.
83 btstb #5,CMDREG1B(%a6) |if set, inst is move out
89 moveb (%a7),VER_TMP(%a6)
90 cmpib #VER_40,(%a7) |test for orig unimp frame
92 moveql #13,%d0 |need to zero 14 lwords
95 moveql #11,%d0 |need to zero 12 lwords
99 clrl -(%a7) |clear and dec a7
101 moveb VER_TMP(%a6),(%a7) |format a busy frame
102 moveb #BUSY_SIZE-4,1(%a7)
103 movel USER_FPSR(%a6),FPSR_SHADOW(%a6)
104 orl #sx_mask,E_BYTE(%a6)
105 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
106 fmovemx USER_FP0(%a6),%fp0-%fp3
107 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
112 | Exit snan handler by expanding the unimp frame into a busy frame
115 bclrb #E1,E_BYTE(%a6)
117 moveb (%a7),VER_TMP(%a6)
118 cmpib #VER_40,(%a7) |test for orig unimp frame
120 moveql #13,%d0 |need to zero 14 lwords
123 moveql #11,%d0 |need to zero 12 lwords
127 clrl -(%a7) |clear and dec a7
129 moveb VER_TMP(%a6),(%a7) |format a busy frame
130 moveb #BUSY_SIZE-4,1(%a7) |write busy size
131 movel USER_FPSR(%a6),FPSR_SHADOW(%a6)
132 orl #sx_mask,E_BYTE(%a6)
133 moveml USER_DA(%a6),%d0-%d1/%a0-%a1
134 fmovemx USER_FP0(%a6),%fp0-%fp3
135 fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
144 movel EXC_EA(%a6),%a0 |get <ea> from exc frame
146 bfextu CMDREG1B(%a6){#3:#3},%d0 |move rx field to d0{2:0}
147 cmpil #0,%d0 |check for long
148 beqs sto_long |branch if move_out long
150 cmpil #4,%d0 |check for word
151 beqs sto_word |branch if move_out word
153 cmpil #6,%d0 |check for byte
154 beqs sto_byte |branch if move_out byte
157 | Not byte, word or long
161 | Get the 32 most significant bits of etemp mantissa
164 movel ETEMP_HI(%a6),%d1
165 movel #4,%d0 |load byte count
167 | Set signalling nan bit
171 | Store to the users destination address
173 tstl %a0 |check if <ea> is 0
174 beqs wrt_dn |destination is a data register
176 movel %d1,-(%a7) |move the snan onto the stack
177 movel %a0,%a1 |load dest addr into a1
178 movel %a7,%a0 |load src addr of snan into a0
179 bsrl mem_write |write snan to user memory
180 movel (%a7)+,%d1 |clear off stack
183 | Get the 16 most significant bits of etemp mantissa
186 movel ETEMP_HI(%a6),%d1
187 movel #2,%d0 |load byte count
189 | Set signalling nan bit
193 | Store to the users destination address
195 tstl %a0 |check if <ea> is 0
196 beqs wrt_dn |destination is a data register
198 movel %d1,-(%a7) |move the snan onto the stack
199 movel %a0,%a1 |load dest addr into a1
200 movel %a7,%a0 |point to low word
201 bsrl mem_write |write snan to user memory
202 movel (%a7)+,%d1 |clear off stack
205 | Get the 8 most significant bits of etemp mantissa
208 movel ETEMP_HI(%a6),%d1
209 movel #1,%d0 |load byte count
211 | Set signalling nan bit
215 | Store to the users destination address
217 tstl %a0 |check if <ea> is 0
218 beqs wrt_dn |destination is a data register
219 movel %d1,-(%a7) |move the snan onto the stack
220 movel %a0,%a1 |load dest addr into a1
221 movel %a7,%a0 |point to source byte
222 bsrl mem_write |write snan to user memory
223 movel (%a7)+,%d1 |clear off stack
227 | wrt_dn --- write to a data register
229 | We get here with D1 containing the data to write and D0 the
230 | number of bytes to write: 1=byte,2=word,4=long.
233 movel %d1,L_SCR1(%a6) |data
234 movel %d0,-(%a7) |size
235 bsrl get_fline |returns fline word in d0
237 andil #0x7,%d1 |d1 now holds register number
238 movel (%sp)+,%d0 |get original size
252 | Check if it is a src nan or dst nan
256 bfextu %d0{#0:#3},%d0 |isolate dtag in lsbs
258 cmpib #3,%d0 |check for nan in destination
259 bnes issrc |destination nan has priority
261 btstb #6,FPTEMP_HI(%a6) |check if dest nan is an snan
262 bnes issrc |no, so check source for snan
263 movew FPTEMP_EX(%a6),%d0
266 movew ETEMP_EX(%a6),%d0
268 btstl #15,%d0 |test for sign of snan
270 bsetb #neg_bit,FPSR_CC(%a6)
273 bclrb #neg_bit,FPSR_CC(%a6)