Revision e1f3808e target-m68k/op_helper.c

b/target-m68k/op_helper.c
18 18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 19
 */
20 20
#include "exec.h"
21
#include "helpers.h"
21 22

  
22 23
#if defined(CONFIG_USER_ONLY)
23 24

  
......
161 162
}
162 163

  
163 164
#endif
165

  
166
static void raise_exception(int tt)
167
{
168
    env->exception_index = tt;
169
    cpu_loop_exit();
170
}
171

  
172
void HELPER(raise_exception)(uint32_t tt)
173
{
174
    raise_exception(tt);
175
}
176

  
177
void HELPER(divu)(CPUState *env, uint32_t word)
178
{
179
    uint32_t num;
180
    uint32_t den;
181
    uint32_t quot;
182
    uint32_t rem;
183
    uint32_t flags;
184

  
185
    num = env->div1;
186
    den = env->div2;
187
    /* ??? This needs to make sure the throwing location is accurate.  */
188
    if (den == 0)
189
        raise_exception(EXCP_DIV0);
190
    quot = num / den;
191
    rem = num % den;
192
    flags = 0;
193
    /* Avoid using a PARAM1 of zero.  This breaks dyngen because it uses
194
       the address of a symbol, and gcc knows symbols can't have address
195
       zero.  */
196
    if (word && quot > 0xffff)
197
        flags |= CCF_V;
198
    if (quot == 0)
199
        flags |= CCF_Z;
200
    else if ((int32_t)quot < 0)
201
        flags |= CCF_N;
202
    env->div1 = quot;
203
    env->div2 = rem;
204
    env->cc_dest = flags;
205
}
206

  
207
void HELPER(divs)(CPUState *env, uint32_t word)
208
{
209
    int32_t num;
210
    int32_t den;
211
    int32_t quot;
212
    int32_t rem;
213
    int32_t flags;
214

  
215
    num = env->div1;
216
    den = env->div2;
217
    if (den == 0)
218
        raise_exception(EXCP_DIV0);
219
    quot = num / den;
220
    rem = num % den;
221
    flags = 0;
222
    if (word && quot != (int16_t)quot)
223
        flags |= CCF_V;
224
    if (quot == 0)
225
        flags |= CCF_Z;
226
    else if (quot < 0)
227
        flags |= CCF_N;
228
    env->div1 = quot;
229
    env->div2 = rem;
230
    env->cc_dest = flags;
231
}
232

  

Also available in: Unified diff