2 | x_store.sa 3.2 1/24/91
4 | store --- store operand to memory or register
6 | Used by underflow and overflow handlers.
8 | a6 = points to fp value to be stored.
11 | Copyright (C) Motorola, Inc. 1990
14 | THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MOTOROLA
15 | The copyright notice above does not evidence any
16 | actual or intended publication of such source code.
18 X_STORE: |idnt 2,1 | Motorola 040 Floating Point Software Package
23 .byte 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01
42 movel CMDREG3B(%a6),%d0
43 bfextu %d0{#6:#3},%d0 |isolate dest. reg from cmdreg3b
46 moveb (%a1,%d0.w),%d0 |convert reg# to dynamic register mask
49 bsetb #sign_bit,LOCAL_EX(%a0)
51 fmovemx (%a0),%d0 |move to correct register
53 | if fp0-fp3 is being modified, we must put a copy
54 | in the USER_FPn variable on the stack because all exception
55 | handlers restore fp0-fp3 from there.
59 fmovemx %fp0-%fp0,USER_FP0(%a6)
64 fmovemx %fp1-%fp1,USER_FP1(%a6)
69 fmovemx %fp2-%fp2,USER_FP2(%a6)
74 fmovemx %fp3-%fp3,USER_FP3(%a6)
80 bsrl g_opcls |returns opclass in d0
82 beq opc011 |branch if opclass 3
83 movel CMDREG1B(%a6),%d0
84 bfextu %d0{#6:#3},%d0 |extract destination register
88 bsrl g_dfmtou |returns dest format in d0
89 | ;ext=00, sgl=01, dbl=10
90 movel %a0,%a1 |save source addr in a1
91 movel EXC_EA(%a6),%a0 |get the address
92 cmpil #0,%d0 |if dest format is extended
93 beq dest_ext |then branch
94 cmpil #1,%d0 |if dest format is single
95 beq dest_sgl |then branch
97 | fall through to dest_dbl
101 | dest_dbl --- write double precision value to user space
104 | a0 -> destination address
105 | a1 -> source in extended precision
111 |Changes extended precision to double precision.
112 | Note: no attempt is made to round the extended value to double.
113 | dbl_sign = ext_sign
114 | dbl_exp = ext_exp - $3fff(ext bias) + $7ff(dbl bias)
115 | get rid of ext integer bit
116 | dbl_mant = ext_mant{62:12}
118 | --------------- --------------- ---------------
119 | extended -> |s| exp | |1| ms mant | | ls mant |
120 | --------------- --------------- ---------------
121 | 95 64 63 62 32 31 11 0
126 | --------------- ---------------
127 | double -> |s|exp| mant | | mant |
128 | --------------- ---------------
133 movew LOCAL_EX(%a1),%d0 |get exponent
134 subw #0x3fff,%d0 |subtract extended precision bias
135 cmpw #0x4000,%d0 |check if inf
136 beqs inf |if so, special case
137 addw #0x3ff,%d0 |add double precision bias
138 swap %d0 |d0 now in upper word
139 lsll #4,%d0 |d0 now in proper place for dbl prec exp
141 beqs get_mant |if positive, go process mantissa
142 bsetl #31,%d0 |if negative, put in sign information
143 | ; before continuing
144 bras get_mant |go process mantissa
146 movel #0x7ff00000,%d0 |load dbl inf exponent
147 clrl LOCAL_HI(%a1) |clear msb
149 beqs dbl_inf |if positive, go ahead and write it
150 bsetl #31,%d0 |if negative put in sign information
152 movel %d0,LOCAL_EX(%a1) |put the new exp back on the stack
155 movel LOCAL_HI(%a1),%d1 |get ms mantissa
156 bfextu %d1{#1:#20},%d1 |get upper 20 bits of ms
157 orl %d1,%d0 |put these bits in ms word of double
158 movel %d0,LOCAL_EX(%a1) |put the new exp back on the stack
159 movel LOCAL_HI(%a1),%d1 |get ms mantissa
160 movel #21,%d0 |load shift count
161 lsll %d0,%d1 |put lower 11 bits in upper bits
162 movel %d1,LOCAL_HI(%a1) |build lower lword in memory
163 movel LOCAL_LO(%a1),%d1 |get ls mantissa
164 bfextu %d1{#0:#21},%d0 |get ls 21 bits of double
165 orl %d0,LOCAL_HI(%a1) |put them in double result
167 movel #0x8,%d0 |byte count for double precision number
168 exg %a0,%a1 |a0=supervisor source, a1=user dest
169 bsrl mem_write |move the number to the user's memory
172 | dest_sgl --- write single precision value to user space
175 | a0 -> destination address
176 | a1 -> source in extended precision
183 |Changes extended precision to single precision.
184 | sgl_sign = ext_sign
185 | sgl_exp = ext_exp - $3fff(ext bias) + $7f(sgl bias)
186 | get rid of ext integer bit
187 | sgl_mant = ext_mant{62:12}
189 | --------------- --------------- ---------------
190 | extended -> |s| exp | |1| ms mant | | ls mant |
191 | --------------- --------------- ---------------
192 | 95 64 63 62 40 32 31 12 0
198 | single -> |s|exp| mant |
204 movew LOCAL_EX(%a1),%d0 |get exponent
205 subw #0x3fff,%d0 |subtract extended precision bias
206 cmpw #0x4000,%d0 |check if inf
207 beqs sinf |if so, special case
208 addw #0x7f,%d0 |add single precision bias
209 swap %d0 |put exp in upper word of d0
210 lsll #7,%d0 |shift it into single exp bits
212 beqs get_sman |if positive, continue
213 bsetl #31,%d0 |if negative, put in sign first
214 bras get_sman |get mantissa
216 movel #0x7f800000,%d0 |load single inf exp to d0
218 beqs sgl_wrt |if positive, continue
219 bsetl #31,%d0 |if negative, put in sign info
223 movel LOCAL_HI(%a1),%d1 |get ms mantissa
224 bfextu %d1{#1:#23},%d1 |get upper 23 bits of ms
225 orl %d1,%d0 |put these bits in ms word of single
228 movel %d0,L_SCR1(%a6) |put the new exp back on the stack
229 movel #0x4,%d0 |byte count for single precision number
230 tstl %a0 |users destination address
231 beqs sgl_Dn |destination is a data register
232 exg %a0,%a1 |a0=supervisor source, a1=user dest
233 leal L_SCR1(%a6),%a0 |point a0 to data
234 bsrl mem_write |move the number to the user's memory
237 bsrl get_fline |returns fline word in d0
238 andw #0x7,%d0 |isolate register number
239 movel %d0,%d1 |d1 has size:reg formatted for reg_dest
240 orl #0x10,%d1 |reg_dest wants size added to reg#
241 bral reg_dest |size is X, rts in reg_dest will
242 | ;return to caller of dest_sgl
245 tstb LOCAL_SGN(%a1) |put back sign into exponent word
247 bsetb #sign_bit,LOCAL_EX(%a1)
249 clrb LOCAL_SGN(%a1) |clear out the sign byte
251 movel #0x0c,%d0 |byte count for extended number
252 exg %a0,%a1 |a0=supervisor source, a1=user dest
253 bsrl mem_write |move the number to the user's memory