source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/x_snan.S @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 6.7 KB
Line 
1//
2//
3//      x_snan.sa 3.3 7/1/91
4//
5// fpsp_snan --- FPSP handler for signalling NAN exception
6//
7// SNAN for float -> integer conversions (integer conversion of
8// an SNAN) is a non-maskable run-time exception.
9//
10// For trap disabled the 040 does the following:
11// If the dest data format is s, d, or x, then the SNAN bit in the NAN
12// is set to one and the resulting non-signaling NAN (truncated if
13// necessary) is transferred to the dest.  If the dest format is b, w,
14// or l, then garbage is written to the dest (actually the upper 32 bits
15// of the mantissa are sent to the integer unit).
16//
17// For trap enabled the 040 does the following:
18// If the inst is move_out, then the results are the same as for trap
19// disabled with the exception posted.  If the instruction is not move_
20// out, the dest. is not modified, and the exception is posted.
21//
22
23//              Copyright (C) Motorola, Inc. 1990
24//                      All Rights Reserved
25//
26//      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
27//      The copyright notice above does not evidence any
28//      actual or intended publication of such source code.
29
30X_SNAN: //idnt    2,1 | Motorola 040 Floating Point Software Package
31
32        |section        8
33
34#include "fpsp.defs"
35
36        |xref   get_fline
37        |xref   mem_write
38        |xref   real_snan
39        |xref   real_inex
40        |xref   fpsp_done
41        |xref   reg_dest
42
43        .global fpsp_snan
44fpsp_snan:
45        link            %a6,#-LOCAL_SIZE
46        fsave           -(%a7)
47        moveml          %d0-%d1/%a0-%a1,USER_DA(%a6)
48        fmovemx %fp0-%fp3,USER_FP0(%a6)
49        fmoveml %fpcr/%fpsr/%fpiar,USER_FPCR(%a6)
50
51//
52// Check if trap enabled
53//
54        btstb           #snan_bit,FPCR_ENABLE(%a6)
55        bnes            ena             //If enabled, then branch
56
57        bsrl            move_out        //else SNAN disabled
58//
59// It is possible to have an inex1 exception with the
60// snan.  If the inex enable bit is set in the FPCR, and either
61// inex2 or inex1 occurred, we must clean up and branch to the
62// real inex handler.
63//
64ck_inex:
65        moveb   FPCR_ENABLE(%a6),%d0
66        andb    FPSR_EXCEPT(%a6),%d0
67        andib   #0x3,%d0
68        beq     end_snan
69//
70// Inexact enabled and reported, and we must take an inexact exception.
71//
72take_inex:
73        moveb           #INEX_VEC,EXC_VEC+1(%a6)
74        moveml          USER_DA(%a6),%d0-%d1/%a0-%a1
75        fmovemx USER_FP0(%a6),%fp0-%fp3
76        fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
77        frestore        (%a7)+
78        unlk            %a6
79        bral            real_inex
80//
81// SNAN is enabled.  Check if inst is move_out.
82// Make any corrections to the 040 output as necessary.
83//
84ena:
85        btstb           #5,CMDREG1B(%a6) //if set, inst is move out
86        beq             not_out
87
88        bsrl            move_out
89
90report_snan:
91        moveb           (%a7),VER_TMP(%a6)
92        cmpib           #VER_40,(%a7)   //test for orig unimp frame
93        bnes            ck_rev
94        moveql          #13,%d0         //need to zero 14 lwords
95        bras            rep_con
96ck_rev:
97        moveql          #11,%d0         //need to zero 12 lwords
98rep_con:
99        clrl            (%a7)
100loop1:
101        clrl            -(%a7)          //clear and dec a7
102        dbra            %d0,loop1
103        moveb           VER_TMP(%a6),(%a7) //format a busy frame
104        moveb           #BUSY_SIZE-4,1(%a7)
105        movel           USER_FPSR(%a6),FPSR_SHADOW(%a6)
106        orl             #sx_mask,E_BYTE(%a6)
107        moveml          USER_DA(%a6),%d0-%d1/%a0-%a1
108        fmovemx USER_FP0(%a6),%fp0-%fp3
109        fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
110        frestore        (%a7)+
111        unlk            %a6
112        bral            real_snan
113//
114// Exit snan handler by expanding the unimp frame into a busy frame
115//
116end_snan:
117        bclrb           #E1,E_BYTE(%a6)
118
119        moveb           (%a7),VER_TMP(%a6)
120        cmpib           #VER_40,(%a7)   //test for orig unimp frame
121        bnes            ck_rev2
122        moveql          #13,%d0         //need to zero 14 lwords
123        bras            rep_con2
124ck_rev2:
125        moveql          #11,%d0         //need to zero 12 lwords
126rep_con2:
127        clrl            (%a7)
128loop2:
129        clrl            -(%a7)          //clear and dec a7
130        dbra            %d0,loop2
131        moveb           VER_TMP(%a6),(%a7) //format a busy frame
132        moveb           #BUSY_SIZE-4,1(%a7) //write busy size
133        movel           USER_FPSR(%a6),FPSR_SHADOW(%a6)
134        orl             #sx_mask,E_BYTE(%a6)
135        moveml          USER_DA(%a6),%d0-%d1/%a0-%a1
136        fmovemx USER_FP0(%a6),%fp0-%fp3
137        fmoveml USER_FPCR(%a6),%fpcr/%fpsr/%fpiar
138        frestore        (%a7)+
139        unlk            %a6
140        bral            fpsp_done
141
142//
143// Move_out
144//
145move_out:
146        movel           EXC_EA(%a6),%a0 //get <ea> from exc frame
147
148        bfextu          CMDREG1B(%a6){#3:#3},%d0 //move rx field to d0{2:0}
149        cmpil           #0,%d0          //check for long
150        beqs            sto_long        //branch if move_out long
151
152        cmpil           #4,%d0          //check for word
153        beqs            sto_word        //branch if move_out word
154
155        cmpil           #6,%d0          //check for byte
156        beqs            sto_byte        //branch if move_out byte
157
158//
159// Not byte, word or long
160//
161        rts
162//
163// Get the 32 most significant bits of etemp mantissa
164//
165sto_long:
166        movel           ETEMP_HI(%a6),%d1
167        movel           #4,%d0          //load byte count
168//
169// Set signalling nan bit
170//
171        bsetl           #30,%d1
172//
173// Store to the users destination address
174//
175        tstl            %a0             //check if <ea> is 0
176        beqs            wrt_dn          //destination is a data register
177
178        movel           %d1,-(%a7)      //move the snan onto the stack
179        movel           %a0,%a1         //load dest addr into a1
180        movel           %a7,%a0         //load src addr of snan into a0
181        bsrl            mem_write       //write snan to user memory
182        movel           (%a7)+,%d1      //clear off stack
183        rts
184//
185// Get the 16 most significant bits of etemp mantissa
186//
187sto_word:
188        movel           ETEMP_HI(%a6),%d1
189        movel           #2,%d0          //load byte count
190//
191// Set signalling nan bit
192//
193        bsetl           #30,%d1
194//
195// Store to the users destination address
196//
197        tstl            %a0             //check if <ea> is 0
198        beqs            wrt_dn          //destination is a data register
199
200        movel           %d1,-(%a7)      //move the snan onto the stack
201        movel           %a0,%a1         //load dest addr into a1
202        movel           %a7,%a0         //point to low word
203        bsrl            mem_write       //write snan to user memory
204        movel           (%a7)+,%d1      //clear off stack
205        rts
206//
207// Get the 8 most significant bits of etemp mantissa
208//
209sto_byte:
210        movel           ETEMP_HI(%a6),%d1
211        movel           #1,%d0          //load byte count
212//
213// Set signalling nan bit
214//
215        bsetl           #30,%d1
216//
217// Store to the users destination address
218//
219        tstl            %a0             //check if <ea> is 0
220        beqs            wrt_dn          //destination is a data register
221        movel           %d1,-(%a7)      //move the snan onto the stack
222        movel           %a0,%a1         //load dest addr into a1
223        movel           %a7,%a0         //point to source byte
224        bsrl            mem_write       //write snan to user memory
225        movel           (%a7)+,%d1      //clear off stack
226        rts
227
228//
229//      wrt_dn --- write to a data register
230//
231//      We get here with D1 containing the data to write and D0 the
232//      number of bytes to write: 1=byte,2=word,4=long.
233//
234wrt_dn:
235        movel           %d1,L_SCR1(%a6) //data
236        movel           %d0,-(%a7)      //size
237        bsrl            get_fline       //returns fline word in d0
238        movel           %d0,%d1
239        andil           #0x7,%d1                //d1 now holds register number
240        movel           (%sp)+,%d0      //get original size
241        cmpil           #4,%d0
242        beqs            wrt_long
243        cmpil           #2,%d0
244        bnes            wrt_byte
245wrt_word:
246        orl             #0x8,%d1
247        bral            reg_dest
248wrt_long:
249        orl             #0x10,%d1
250        bral            reg_dest
251wrt_byte:
252        bral            reg_dest
253//
254// Check if it is a src nan or dst nan
255//
256not_out:
257        movel           DTAG(%a6),%d0
258        bfextu          %d0{#0:#3},%d0  //isolate dtag in lsbs
259
260        cmpib           #3,%d0          //check for nan in destination
261        bnes            issrc           //destination nan has priority
262dst_nan:
263        btstb           #6,FPTEMP_HI(%a6) //check if dest nan is an snan
264        bnes            issrc           //no, so check source for snan
265        movew           FPTEMP_EX(%a6),%d0
266        bras            cont
267issrc:
268        movew           ETEMP_EX(%a6),%d0
269cont:
270        btstl           #15,%d0         //test for sign of snan
271        beqs            clr_neg
272        bsetb           #neg_bit,FPSR_CC(%a6)
273        bra             report_snan
274clr_neg:
275        bclrb           #neg_bit,FPSR_CC(%a6)
276        bra             report_snan
277
278        |end
Note: See TracBrowser for help on using the repository browser.