source: rtems/c/src/lib/libcpu/m68k/m68040/fpsp/x_store.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: 7.1 KB
Line 
1//
2//
3//      x_store.sa 3.2 1/24/91
4//
5//      store --- store operand to memory or register
6//
7//      Used by underflow and overflow handlers.
8//
9//      a6 = points to fp value to be stored.
10//
11
12//              Copyright (C) Motorola, Inc. 1990
13//                      All Rights Reserved
14//
15//      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
16//      The copyright notice above does not evidence any
17//      actual or intended publication of such source code.
18
19X_STORE:        //idnt    2,1 | Motorola 040 Floating Point Software Package
20
21        |section        8
22
23fpreg_mask:
24        .byte   0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01
25
26#include "fpsp.defs"
27
28        |xref   mem_write
29        |xref   get_fline
30        |xref   g_opcls
31        |xref   g_dfmtou
32        |xref   reg_dest
33
34        .global dest_ext
35        .global dest_dbl
36        .global dest_sgl
37
38        .global store
39store:
40        btstb   #E3,E_BYTE(%a6)
41        beqs    E1_sto
42E3_sto:
43        movel   CMDREG3B(%a6),%d0
44        bfextu  %d0{#6:#3},%d0          //isolate dest. reg from cmdreg3b
45sto_fp:
46        lea     fpreg_mask,%a1
47        moveb   (%a1,%d0.w),%d0         //convert reg# to dynamic register mask
48        tstb    LOCAL_SGN(%a0)
49        beqs    is_pos
50        bsetb   #sign_bit,LOCAL_EX(%a0)
51is_pos:
52        fmovemx (%a0),%d0               //move to correct register
53//
54//      if fp0-fp3 is being modified, we must put a copy
55//      in the USER_FPn variable on the stack because all exception
56//      handlers restore fp0-fp3 from there.
57//
58        cmpb    #0x80,%d0
59        bnes    not_fp0
60        fmovemx %fp0-%fp0,USER_FP0(%a6)
61        rts
62not_fp0:
63        cmpb    #0x40,%d0
64        bnes    not_fp1
65        fmovemx %fp1-%fp1,USER_FP1(%a6)
66        rts
67not_fp1:
68        cmpb    #0x20,%d0
69        bnes    not_fp2
70        fmovemx %fp2-%fp2,USER_FP2(%a6)
71        rts
72not_fp2:
73        cmpb    #0x10,%d0
74        bnes    not_fp3
75        fmovemx %fp3-%fp3,USER_FP3(%a6)
76        rts
77not_fp3:
78        rts
79
80E1_sto:
81        bsrl    g_opcls         //returns opclass in d0
82        cmpib   #3,%d0
83        beq     opc011          //branch if opclass 3
84        movel   CMDREG1B(%a6),%d0
85        bfextu  %d0{#6:#3},%d0  //extract destination register
86        bras    sto_fp
87
88opc011:
89        bsrl    g_dfmtou        //returns dest format in d0
90//                              ;ext=00, sgl=01, dbl=10
91        movel   %a0,%a1         //save source addr in a1
92        movel   EXC_EA(%a6),%a0 //get the address
93        cmpil   #0,%d0          //if dest format is extended
94        beq     dest_ext        //then branch
95        cmpil   #1,%d0          //if dest format is single
96        beq     dest_sgl        //then branch
97//
98//      fall through to dest_dbl
99//
100
101//
102//      dest_dbl --- write double precision value to user space
103//
104//Input
105//      a0 -> destination address
106//      a1 -> source in extended precision
107//Output
108//      a0 -> destroyed
109//      a1 -> destroyed
110//      d0 -> 0
111//
112//Changes extended precision to double precision.
113// Note: no attempt is made to round the extended value to double.
114//      dbl_sign = ext_sign
115//      dbl_exp = ext_exp - $3fff(ext bias) + $7ff(dbl bias)
116//      get rid of ext integer bit
117//      dbl_mant = ext_mant{62:12}
118//
119//              ---------------   ---------------    ---------------
120//  extended ->  |s|    exp    |   |1| ms mant   |    | ls mant     |
121//              ---------------   ---------------    ---------------
122//               95         64    63 62       32      31     11   0
123//                                   |                       |
124//                                   |                       |
125//                                   |                       |
126//                                   v                       v
127//                            ---------------   ---------------
128//  double   ->               |s|exp| mant  |   |  mant       |
129//                            ---------------   ---------------
130//                            63     51   32   31              0
131//
132dest_dbl:
133        clrl    %d0             //clear d0
134        movew   LOCAL_EX(%a1),%d0       //get exponent
135        subw    #0x3fff,%d0     //subtract extended precision bias
136        cmpw    #0x4000,%d0     //check if inf
137        beqs    inf             //if so, special case
138        addw    #0x3ff,%d0      //add double precision bias
139        swap    %d0             //d0 now in upper word
140        lsll    #4,%d0          //d0 now in proper place for dbl prec exp
141        tstb    LOCAL_SGN(%a1)
142        beqs    get_mant        //if positive, go process mantissa
143        bsetl   #31,%d0         //if negative, put in sign information
144//                              ; before continuing
145        bras    get_mant        //go process mantissa
146inf:
147        movel   #0x7ff00000,%d0 //load dbl inf exponent
148        clrl    LOCAL_HI(%a1)   //clear msb
149        tstb    LOCAL_SGN(%a1)
150        beqs    dbl_inf         //if positive, go ahead and write it
151        bsetl   #31,%d0         //if negative put in sign information
152dbl_inf:
153        movel   %d0,LOCAL_EX(%a1)       //put the new exp back on the stack
154        bras    dbl_wrt
155get_mant:
156        movel   LOCAL_HI(%a1),%d1       //get ms mantissa
157        bfextu  %d1{#1:#20},%d1 //get upper 20 bits of ms
158        orl     %d1,%d0         //put these bits in ms word of double
159        movel   %d0,LOCAL_EX(%a1)       //put the new exp back on the stack
160        movel   LOCAL_HI(%a1),%d1       //get ms mantissa
161        movel   #21,%d0         //load shift count
162        lsll    %d0,%d1         //put lower 11 bits in upper bits
163        movel   %d1,LOCAL_HI(%a1)       //build lower lword in memory
164        movel   LOCAL_LO(%a1),%d1       //get ls mantissa
165        bfextu  %d1{#0:#21},%d0 //get ls 21 bits of double
166        orl     %d0,LOCAL_HI(%a1)       //put them in double result
167dbl_wrt:
168        movel   #0x8,%d0                //byte count for double precision number
169        exg     %a0,%a1         //a0=supervisor source, a1=user dest
170        bsrl    mem_write       //move the number to the user's memory
171        rts
172//
173//      dest_sgl --- write single precision value to user space
174//
175//Input
176//      a0 -> destination address
177//      a1 -> source in extended precision
178//
179//Output
180//      a0 -> destroyed
181//      a1 -> destroyed
182//      d0 -> 0
183//
184//Changes extended precision to single precision.
185//      sgl_sign = ext_sign
186//      sgl_exp = ext_exp - $3fff(ext bias) + $7f(sgl bias)
187//      get rid of ext integer bit
188//      sgl_mant = ext_mant{62:12}
189//
190//              ---------------   ---------------    ---------------
191//  extended ->  |s|    exp    |   |1| ms mant   |    | ls mant     |
192//              ---------------   ---------------    ---------------
193//               95         64    63 62    40 32      31     12   0
194//                                   |     |
195//                                   |     |
196//                                   |     |
197//                                   v     v
198//                            ---------------
199//  single   ->               |s|exp| mant  |
200//                            ---------------
201//                            31     22     0
202//
203dest_sgl:
204        clrl    %d0
205        movew   LOCAL_EX(%a1),%d0       //get exponent
206        subw    #0x3fff,%d0     //subtract extended precision bias
207        cmpw    #0x4000,%d0     //check if inf
208        beqs    sinf            //if so, special case
209        addw    #0x7f,%d0               //add single precision bias
210        swap    %d0             //put exp in upper word of d0
211        lsll    #7,%d0          //shift it into single exp bits
212        tstb    LOCAL_SGN(%a1)
213        beqs    get_sman        //if positive, continue
214        bsetl   #31,%d0         //if negative, put in sign first
215        bras    get_sman        //get mantissa
216sinf:
217        movel   #0x7f800000,%d0 //load single inf exp to d0
218        tstb    LOCAL_SGN(%a1)
219        beqs    sgl_wrt         //if positive, continue
220        bsetl   #31,%d0         //if negative, put in sign info
221        bras    sgl_wrt
222
223get_sman:
224        movel   LOCAL_HI(%a1),%d1       //get ms mantissa
225        bfextu  %d1{#1:#23},%d1 //get upper 23 bits of ms
226        orl     %d1,%d0         //put these bits in ms word of single
227
228sgl_wrt:
229        movel   %d0,L_SCR1(%a6) //put the new exp back on the stack
230        movel   #0x4,%d0                //byte count for single precision number
231        tstl    %a0             //users destination address
232        beqs    sgl_Dn          //destination is a data register
233        exg     %a0,%a1         //a0=supervisor source, a1=user dest
234        leal    L_SCR1(%a6),%a0 //point a0 to data
235        bsrl    mem_write       //move the number to the user's memory
236        rts
237sgl_Dn:
238        bsrl    get_fline       //returns fline word in d0
239        andw    #0x7,%d0                //isolate register number
240        movel   %d0,%d1         //d1 has size:reg formatted for reg_dest
241        orl     #0x10,%d1               //reg_dest wants size added to reg#
242        bral    reg_dest        //size is X, rts in reg_dest will
243//                              ;return to caller of dest_sgl
244
245dest_ext:
246        tstb    LOCAL_SGN(%a1)  //put back sign into exponent word
247        beqs    dstx_cont
248        bsetb   #sign_bit,LOCAL_EX(%a1)
249dstx_cont:
250        clrb    LOCAL_SGN(%a1)  //clear out the sign byte
251
252        movel   #0x0c,%d0               //byte count for extended number
253        exg     %a0,%a1         //a0=supervisor source, a1=user dest
254        bsrl    mem_write       //move the number to the user's memory
255        rts
256
257        |end
Note: See TracBrowser for help on using the repository browser.