3 * MOTOROLA MICROPROCESSOR & MEMORY TECHNOLOGY GROUP
4 * M68000 Hi-Performance Microprocessor Division
5 * M68040 Software Package
7 * M68040 Software Package Copyright (c) 1993, 1994 Motorola Inc.
10 * THE SOFTWARE is provided on an "AS IS" basis and without warranty.
11 * To the maximum extent permitted by applicable law,
12 * MOTOROLA DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
13 * INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
14 * PARTICULAR PURPOSE and any warranty against infringement with
15 * regard to the SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
16 * and any accompanying written materials.
18 * To the maximum extent permitted by applicable law,
19 * IN NO EVENT SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER
20 * (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS
21 * PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR
22 * OTHER PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE
23 * SOFTWARE. Motorola assumes no responsibility for the maintenance
24 * and support of the SOFTWARE.
26 * You are hereby granted a copyright license to use, modify, and
27 * distribute the SOFTWARE so long as this entire notice is retained
28 * without alteration in any modified and/or redistributed versions,
29 * and that such modified versions are clearly identified as such.
30 * No licenses are granted by implication, estoppel or otherwise
31 * under any patents or trademarks of Motorola, Inc.
34 * smovecr.sa 3.1 12/10/90
36 * The entry point sMOVECR returns the constant at the
37 * offset given in the instruction field.
39 * Input: An offset in the instruction word.
41 * Output: The constant rounded to the user's rounding
42 * mode unchecked for overflow.
47 SMOVECR IDNT 2,1 Motorola 040 Floating Point Software Package
71 bfextu CMDREG1B(a6){9:7},d0 ;get offset
72 bfextu USER_FPCR(a6){26:2},d1 ;get rmode
74 * check range of offset
76 tst.b d0 ;if zero, offset is to pi
77 beq.b PI_TBL ;it is pi
78 cmpi.b #$0a,d0 ;check range $01 - $0a
79 ble.b Z_VAL ;if in this range, return zero
80 cmpi.b #$0e,d0 ;check range $0b - $0e
81 ble.b SM_TBL ;valid constants in this range
82 cmpi.b #$2f,d0 ;check range $10 - $2f
83 ble.b Z_VAL ;if in this range, return zero
84 cmpi.b #$3f,d0 ;check range $30 - $3f
85 ble BG_TBL ;valid constants in this range
90 tst.b d1 ;offset is zero, check for rmode
91 beq.b PI_RN ;if zero, rn mode
92 cmpi.b #$3,d1 ;check for rp
93 beq.b PI_RP ;if 3, rp mode
95 lea.l PIRZRM,a0 ;rmode is rz or rm, load PIRZRM in a0
98 lea.l PIRN,a0 ;rmode is rn, load PIRN in a0
101 lea.l PIRP,a0 ;rmode is rp, load PIRP in a0
104 subi.l #$b,d0 ;make offset in 0 - 4 range
105 tst.b d1 ;check for rmode
106 beq.b SM_RN ;if zero, rn mode
107 cmpi.b #$3,d1 ;check for rp
108 beq.b SM_RP ;if 3, rp mode
110 lea.l SMALRZRM,a0 ;rmode is rz or rm, load SMRZRM in a0
111 cmpi.b #$2,d0 ;check if result is inex
112 ble set_finx ;if 0 - 2, it is inexact
113 bra no_finx ;if 3, it is exact
115 lea.l SMALRN,a0 ;rmode is rn, load SMRN in a0
116 cmpi.b #$2,d0 ;check if result is inex
117 ble set_finx ;if 0 - 2, it is inexact
118 bra no_finx ;if 3, it is exact
120 lea.l SMALRP,a0 ;rmode is rp, load SMRP in a0
121 cmpi.b #$2,d0 ;check if result is inex
122 ble set_finx ;if 0 - 2, it is inexact
123 bra no_finx ;if 3, it is exact
125 subi.l #$30,d0 ;make offset in 0 - f range
126 tst.b d1 ;check for rmode
127 beq.b BG_RN ;if zero, rn mode
128 cmpi.b #$3,d1 ;check for rp
129 beq.b BG_RP ;if 3, rp mode
131 lea.l BIGRZRM,a0 ;rmode is rz or rm, load BGRZRM in a0
132 cmpi.b #$1,d0 ;check if result is inex
133 ble set_finx ;if 0 - 1, it is inexact
134 cmpi.b #$7,d0 ;second check
135 ble no_finx ;if 0 - 7, it is exact
136 bra set_finx ;if 8 - f, it is inexact
138 lea.l BIGRN,a0 ;rmode is rn, load BGRN in a0
139 cmpi.b #$1,d0 ;check if result is inex
140 ble set_finx ;if 0 - 1, it is inexact
141 cmpi.b #$7,d0 ;second check
142 ble no_finx ;if 0 - 7, it is exact
143 bra set_finx ;if 8 - f, it is inexact
145 lea.l BIGRP,a0 ;rmode is rp, load SMRP in a0
146 cmpi.b #$1,d0 ;check if result is inex
147 ble set_finx ;if 0 - 1, it is inexact
148 cmpi.b #$7,d0 ;second check
149 ble no_finx ;if 0 - 7, it is exact
150 * bra set_finx ;if 8 - f, it is inexact
152 or.l #inx2a_mask,USER_FPSR(a6) ;set inex2/ainex
154 mulu.l #12,d0 ;use offset to point into tables
155 move.l d1,L_SCR1(a6) ;load mode for round call
156 bfextu USER_FPCR(a6){24:2},d1 ;get precision
157 tst.l d1 ;check if extended precision
159 * Precision is extended
161 bne.b not_ext ;if extended, do not call round
162 fmovem.x (a0,d0),fp0 ;return result in fp0
165 * Precision is single or double
168 swap d1 ;rnd prec in upper word of d1
169 add.l L_SCR1(a6),d1 ;merge rmode in low word of d1
170 move.l (a0,d0),FP_SCR1(a6) ;load first word to temp storage
171 move.l 4(a0,d0),FP_SCR1+4(a6) ;load second word
172 move.l 8(a0,d0),FP_SCR1+8(a6) ;load third word
173 clr.l d0 ;clear g,r,s
175 btst.b #sign_bit,LOCAL_EX(a0)
176 sne LOCAL_SGN(a0) ;convert to internal ext. format
178 bsr round ;go round the mantissa
180 bfclr LOCAL_SGN(a0){0:8} ;convert back to IEEE ext format
182 bset.b #sign_bit,LOCAL_EX(a0)