Statistics
| Branch: | Revision:

root / target-sh4 / translate.c @ 2e70f6ef

History | View | Annotate | Download (36 kB)

1 fdf9b3e8 bellard
/*
2 fdf9b3e8 bellard
 *  SH4 translation
3 5fafdf24 ths
 *
4 fdf9b3e8 bellard
 *  Copyright (c) 2005 Samuel Tardieu
5 fdf9b3e8 bellard
 *
6 fdf9b3e8 bellard
 * This library is free software; you can redistribute it and/or
7 fdf9b3e8 bellard
 * modify it under the terms of the GNU Lesser General Public
8 fdf9b3e8 bellard
 * License as published by the Free Software Foundation; either
9 fdf9b3e8 bellard
 * version 2 of the License, or (at your option) any later version.
10 fdf9b3e8 bellard
 *
11 fdf9b3e8 bellard
 * This library is distributed in the hope that it will be useful,
12 fdf9b3e8 bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 fdf9b3e8 bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 fdf9b3e8 bellard
 * Lesser General Public License for more details.
15 fdf9b3e8 bellard
 *
16 fdf9b3e8 bellard
 * You should have received a copy of the GNU Lesser General Public
17 fdf9b3e8 bellard
 * License along with this library; if not, write to the Free Software
18 fdf9b3e8 bellard
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 fdf9b3e8 bellard
 */
20 fdf9b3e8 bellard
#include <stdarg.h>
21 fdf9b3e8 bellard
#include <stdlib.h>
22 fdf9b3e8 bellard
#include <stdio.h>
23 fdf9b3e8 bellard
#include <string.h>
24 fdf9b3e8 bellard
#include <inttypes.h>
25 fdf9b3e8 bellard
#include <assert.h>
26 fdf9b3e8 bellard
27 fdf9b3e8 bellard
#define DEBUG_DISAS
28 fdf9b3e8 bellard
#define SH4_DEBUG_DISAS
29 fdf9b3e8 bellard
//#define SH4_SINGLE_STEP
30 fdf9b3e8 bellard
31 fdf9b3e8 bellard
#include "cpu.h"
32 fdf9b3e8 bellard
#include "exec-all.h"
33 fdf9b3e8 bellard
#include "disas.h"
34 57fec1fe bellard
#include "tcg-op.h"
35 ca10f867 aurel32
#include "qemu-common.h"
36 fdf9b3e8 bellard
37 fdf9b3e8 bellard
typedef struct DisasContext {
38 fdf9b3e8 bellard
    struct TranslationBlock *tb;
39 fdf9b3e8 bellard
    target_ulong pc;
40 fdf9b3e8 bellard
    uint32_t sr;
41 eda9b09b bellard
    uint32_t fpscr;
42 fdf9b3e8 bellard
    uint16_t opcode;
43 fdf9b3e8 bellard
    uint32_t flags;
44 823029f9 ths
    int bstate;
45 fdf9b3e8 bellard
    int memidx;
46 fdf9b3e8 bellard
    uint32_t delayed_pc;
47 fdf9b3e8 bellard
    int singlestep_enabled;
48 fdf9b3e8 bellard
} DisasContext;
49 fdf9b3e8 bellard
50 823029f9 ths
enum {
51 823029f9 ths
    BS_NONE     = 0, /* We go out of the TB without reaching a branch or an
52 823029f9 ths
                      * exception condition
53 823029f9 ths
                      */
54 823029f9 ths
    BS_STOP     = 1, /* We want to stop translation for any reason */
55 823029f9 ths
    BS_BRANCH   = 2, /* We reached a branch condition     */
56 823029f9 ths
    BS_EXCP     = 3, /* We reached an exception condition */
57 823029f9 ths
};
58 823029f9 ths
59 2e70f6ef pbrook
static TCGv cpu_env;
60 2e70f6ef pbrook
61 2e70f6ef pbrook
#include "gen-icount.h"
62 2e70f6ef pbrook
63 2e70f6ef pbrook
void sh4_translate_init()
64 2e70f6ef pbrook
{
65 2e70f6ef pbrook
    static int done_init = 0;
66 2e70f6ef pbrook
    if (done_init)
67 2e70f6ef pbrook
        return;
68 2e70f6ef pbrook
    cpu_env = tcg_global_reg_new(TCG_TYPE_PTR, TCG_AREG0, "env");
69 2e70f6ef pbrook
    done_init = 1;
70 2e70f6ef pbrook
}
71 2e70f6ef pbrook
72 fdf9b3e8 bellard
#ifdef CONFIG_USER_ONLY
73 fdf9b3e8 bellard
74 eda9b09b bellard
#define GEN_OP_LD(width, reg) \
75 eda9b09b bellard
  void gen_op_ld##width##_T0_##reg (DisasContext *ctx) { \
76 eda9b09b bellard
    gen_op_ld##width##_T0_##reg##_raw(); \
77 fdf9b3e8 bellard
  }
78 eda9b09b bellard
#define GEN_OP_ST(width, reg) \
79 eda9b09b bellard
  void gen_op_st##width##_##reg##_T1 (DisasContext *ctx) { \
80 eda9b09b bellard
    gen_op_st##width##_##reg##_T1_raw(); \
81 fdf9b3e8 bellard
  }
82 fdf9b3e8 bellard
83 fdf9b3e8 bellard
#else
84 fdf9b3e8 bellard
85 eda9b09b bellard
#define GEN_OP_LD(width, reg) \
86 eda9b09b bellard
  void gen_op_ld##width##_T0_##reg (DisasContext *ctx) { \
87 eda9b09b bellard
    if (ctx->memidx) gen_op_ld##width##_T0_##reg##_kernel(); \
88 eda9b09b bellard
    else gen_op_ld##width##_T0_##reg##_user();\
89 fdf9b3e8 bellard
  }
90 eda9b09b bellard
#define GEN_OP_ST(width, reg) \
91 eda9b09b bellard
  void gen_op_st##width##_##reg##_T1 (DisasContext *ctx) { \
92 eda9b09b bellard
    if (ctx->memidx) gen_op_st##width##_##reg##_T1_kernel(); \
93 eda9b09b bellard
    else gen_op_st##width##_##reg##_T1_user();\
94 fdf9b3e8 bellard
  }
95 fdf9b3e8 bellard
96 fdf9b3e8 bellard
#endif
97 fdf9b3e8 bellard
98 eda9b09b bellard
GEN_OP_LD(ub, T0)
99 eda9b09b bellard
GEN_OP_LD(b, T0)
100 eda9b09b bellard
GEN_OP_ST(b, T0)
101 eda9b09b bellard
GEN_OP_LD(uw, T0)
102 eda9b09b bellard
GEN_OP_LD(w, T0)
103 eda9b09b bellard
GEN_OP_ST(w, T0)
104 eda9b09b bellard
GEN_OP_LD(l, T0)
105 eda9b09b bellard
GEN_OP_ST(l, T0)
106 eda9b09b bellard
GEN_OP_LD(fl, FT0)
107 eda9b09b bellard
GEN_OP_ST(fl, FT0)
108 eda9b09b bellard
GEN_OP_LD(fq, DT0)
109 eda9b09b bellard
GEN_OP_ST(fq, DT0)
110 fdf9b3e8 bellard
111 fdf9b3e8 bellard
void cpu_dump_state(CPUState * env, FILE * f,
112 fdf9b3e8 bellard
                    int (*cpu_fprintf) (FILE * f, const char *fmt, ...),
113 fdf9b3e8 bellard
                    int flags)
114 fdf9b3e8 bellard
{
115 fdf9b3e8 bellard
    int i;
116 eda9b09b bellard
    cpu_fprintf(f, "pc=0x%08x sr=0x%08x pr=0x%08x fpscr=0x%08x\n",
117 eda9b09b bellard
                env->pc, env->sr, env->pr, env->fpscr);
118 fdf9b3e8 bellard
    for (i = 0; i < 24; i += 4) {
119 fdf9b3e8 bellard
        cpu_fprintf(f, "r%d=0x%08x r%d=0x%08x r%d=0x%08x r%d=0x%08x\n",
120 fdf9b3e8 bellard
                    i, env->gregs[i], i + 1, env->gregs[i + 1],
121 fdf9b3e8 bellard
                    i + 2, env->gregs[i + 2], i + 3, env->gregs[i + 3]);
122 fdf9b3e8 bellard
    }
123 fdf9b3e8 bellard
    if (env->flags & DELAY_SLOT) {
124 fdf9b3e8 bellard
        cpu_fprintf(f, "in delay slot (delayed_pc=0x%08x)\n",
125 fdf9b3e8 bellard
                    env->delayed_pc);
126 fdf9b3e8 bellard
    } else if (env->flags & DELAY_SLOT_CONDITIONAL) {
127 fdf9b3e8 bellard
        cpu_fprintf(f, "in conditional delay slot (delayed_pc=0x%08x)\n",
128 fdf9b3e8 bellard
                    env->delayed_pc);
129 fdf9b3e8 bellard
    }
130 fdf9b3e8 bellard
}
131 fdf9b3e8 bellard
132 fdf9b3e8 bellard
void cpu_sh4_reset(CPUSH4State * env)
133 fdf9b3e8 bellard
{
134 9c2a9ea1 pbrook
#if defined(CONFIG_USER_ONLY)
135 4c909d14 ths
    env->sr = SR_FD;            /* FD - kernel does lazy fpu context switch */
136 9c2a9ea1 pbrook
#else
137 fdf9b3e8 bellard
    env->sr = 0x700000F0;        /* MD, RB, BL, I3-I0 */
138 9c2a9ea1 pbrook
#endif
139 fdf9b3e8 bellard
    env->vbr = 0;
140 fdf9b3e8 bellard
    env->pc = 0xA0000000;
141 ea6cf6be ths
#if defined(CONFIG_USER_ONLY)
142 ea6cf6be ths
    env->fpscr = FPSCR_PR; /* value for userspace according to the kernel */
143 b0b3de89 bellard
    set_float_rounding_mode(float_round_nearest_even, &env->fp_status); /* ?! */
144 ea6cf6be ths
#else
145 ea6cf6be ths
    env->fpscr = 0x00040001; /* CPU reset value according to SH4 manual */
146 b0b3de89 bellard
    set_float_rounding_mode(float_round_to_zero, &env->fp_status);
147 ea6cf6be ths
#endif
148 fdf9b3e8 bellard
    env->mmucr = 0;
149 fdf9b3e8 bellard
}
150 fdf9b3e8 bellard
151 aaed909a bellard
CPUSH4State *cpu_sh4_init(const char *cpu_model)
152 fdf9b3e8 bellard
{
153 fdf9b3e8 bellard
    CPUSH4State *env;
154 fdf9b3e8 bellard
155 fdf9b3e8 bellard
    env = qemu_mallocz(sizeof(CPUSH4State));
156 fdf9b3e8 bellard
    if (!env)
157 fdf9b3e8 bellard
        return NULL;
158 fdf9b3e8 bellard
    cpu_exec_init(env);
159 2e70f6ef pbrook
    sh4_translate_init();
160 fdf9b3e8 bellard
    cpu_sh4_reset(env);
161 fdf9b3e8 bellard
    tlb_flush(env, 1);
162 fdf9b3e8 bellard
    return env;
163 fdf9b3e8 bellard
}
164 fdf9b3e8 bellard
165 fdf9b3e8 bellard
static void gen_goto_tb(DisasContext * ctx, int n, target_ulong dest)
166 fdf9b3e8 bellard
{
167 fdf9b3e8 bellard
    TranslationBlock *tb;
168 fdf9b3e8 bellard
    tb = ctx->tb;
169 fdf9b3e8 bellard
170 fdf9b3e8 bellard
    if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) &&
171 fdf9b3e8 bellard
        !ctx->singlestep_enabled) {
172 fdf9b3e8 bellard
        /* Use a direct jump if in same page and singlestep not enabled */
173 57fec1fe bellard
        tcg_gen_goto_tb(n);
174 57fec1fe bellard
        gen_op_movl_imm_PC(dest);
175 57fec1fe bellard
        tcg_gen_exit_tb((long) tb + n);
176 fdf9b3e8 bellard
    } else {
177 57fec1fe bellard
        gen_op_movl_imm_PC(dest);
178 57fec1fe bellard
        if (ctx->singlestep_enabled)
179 57fec1fe bellard
            gen_op_debug();
180 57fec1fe bellard
        tcg_gen_exit_tb(0);
181 fdf9b3e8 bellard
    }
182 fdf9b3e8 bellard
}
183 fdf9b3e8 bellard
184 fdf9b3e8 bellard
static void gen_jump(DisasContext * ctx)
185 fdf9b3e8 bellard
{
186 fdf9b3e8 bellard
    if (ctx->delayed_pc == (uint32_t) - 1) {
187 fdf9b3e8 bellard
        /* Target is not statically known, it comes necessarily from a
188 fdf9b3e8 bellard
           delayed jump as immediate jump are conditinal jumps */
189 fdf9b3e8 bellard
        gen_op_movl_delayed_pc_PC();
190 fdf9b3e8 bellard
        if (ctx->singlestep_enabled)
191 fdf9b3e8 bellard
            gen_op_debug();
192 57fec1fe bellard
        tcg_gen_exit_tb(0);
193 fdf9b3e8 bellard
    } else {
194 fdf9b3e8 bellard
        gen_goto_tb(ctx, 0, ctx->delayed_pc);
195 fdf9b3e8 bellard
    }
196 fdf9b3e8 bellard
}
197 fdf9b3e8 bellard
198 fdf9b3e8 bellard
/* Immediate conditional jump (bt or bf) */
199 fdf9b3e8 bellard
static void gen_conditional_jump(DisasContext * ctx,
200 fdf9b3e8 bellard
                                 target_ulong ift, target_ulong ifnott)
201 fdf9b3e8 bellard
{
202 fdf9b3e8 bellard
    int l1;
203 fdf9b3e8 bellard
204 fdf9b3e8 bellard
    l1 = gen_new_label();
205 fdf9b3e8 bellard
    gen_op_jT(l1);
206 fdf9b3e8 bellard
    gen_goto_tb(ctx, 0, ifnott);
207 fdf9b3e8 bellard
    gen_set_label(l1);
208 fdf9b3e8 bellard
    gen_goto_tb(ctx, 1, ift);
209 fdf9b3e8 bellard
}
210 fdf9b3e8 bellard
211 fdf9b3e8 bellard
/* Delayed conditional jump (bt or bf) */
212 fdf9b3e8 bellard
static void gen_delayed_conditional_jump(DisasContext * ctx)
213 fdf9b3e8 bellard
{
214 fdf9b3e8 bellard
    int l1;
215 fdf9b3e8 bellard
216 fdf9b3e8 bellard
    l1 = gen_new_label();
217 9c2a9ea1 pbrook
    gen_op_jdelayed(l1);
218 823029f9 ths
    gen_goto_tb(ctx, 1, ctx->pc + 2);
219 fdf9b3e8 bellard
    gen_set_label(l1);
220 9c2a9ea1 pbrook
    gen_jump(ctx);
221 fdf9b3e8 bellard
}
222 fdf9b3e8 bellard
223 fdf9b3e8 bellard
#define B3_0 (ctx->opcode & 0xf)
224 fdf9b3e8 bellard
#define B6_4 ((ctx->opcode >> 4) & 0x7)
225 fdf9b3e8 bellard
#define B7_4 ((ctx->opcode >> 4) & 0xf)
226 fdf9b3e8 bellard
#define B7_0 (ctx->opcode & 0xff)
227 fdf9b3e8 bellard
#define B7_0s ((int32_t) (int8_t) (ctx->opcode & 0xff))
228 fdf9b3e8 bellard
#define B11_0s (ctx->opcode & 0x800 ? 0xfffff000 | (ctx->opcode & 0xfff) : \
229 fdf9b3e8 bellard
  (ctx->opcode & 0xfff))
230 fdf9b3e8 bellard
#define B11_8 ((ctx->opcode >> 8) & 0xf)
231 fdf9b3e8 bellard
#define B15_12 ((ctx->opcode >> 12) & 0xf)
232 fdf9b3e8 bellard
233 fdf9b3e8 bellard
#define REG(x) ((x) < 8 && (ctx->sr & (SR_MD | SR_RB)) == (SR_MD | SR_RB) ? \
234 fdf9b3e8 bellard
                (x) + 16 : (x))
235 fdf9b3e8 bellard
236 fdf9b3e8 bellard
#define ALTREG(x) ((x) < 8 && (ctx->sr & (SR_MD | SR_RB)) != (SR_MD | SR_RB) \
237 fdf9b3e8 bellard
                ? (x) + 16 : (x))
238 fdf9b3e8 bellard
239 eda9b09b bellard
#define FREG(x) (ctx->fpscr & FPSCR_FR ? (x) ^ 0x10 : (x))
240 f09111e0 ths
#define XHACK(x) ((((x) & 1 ) << 4) | ((x) & 0xe))
241 eda9b09b bellard
#define XREG(x) (ctx->fpscr & FPSCR_FR ? XHACK(x) ^ 0x10 : XHACK(x))
242 ea6cf6be ths
#define DREG(x) FREG(x) /* Assumes lsb of (x) is always 0 */
243 eda9b09b bellard
244 fdf9b3e8 bellard
#define CHECK_NOT_DELAY_SLOT \
245 fdf9b3e8 bellard
  if (ctx->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) \
246 823029f9 ths
  {gen_op_raise_slot_illegal_instruction (); ctx->bstate = BS_EXCP; \
247 fdf9b3e8 bellard
   return;}
248 fdf9b3e8 bellard
249 823029f9 ths
void _decode_opc(DisasContext * ctx)
250 fdf9b3e8 bellard
{
251 fdf9b3e8 bellard
#if 0
252 fdf9b3e8 bellard
    fprintf(stderr, "Translating opcode 0x%04x\n", ctx->opcode);
253 fdf9b3e8 bellard
#endif
254 fdf9b3e8 bellard
    switch (ctx->opcode) {
255 fdf9b3e8 bellard
    case 0x0019:                /* div0u */
256 fdf9b3e8 bellard
        gen_op_div0u();
257 fdf9b3e8 bellard
        return;
258 fdf9b3e8 bellard
    case 0x000b:                /* rts */
259 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_rts();
260 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
261 fdf9b3e8 bellard
        ctx->delayed_pc = (uint32_t) - 1;
262 fdf9b3e8 bellard
        return;
263 fdf9b3e8 bellard
    case 0x0028:                /* clrmac */
264 fdf9b3e8 bellard
        gen_op_clrmac();
265 fdf9b3e8 bellard
        return;
266 fdf9b3e8 bellard
    case 0x0048:                /* clrs */
267 fdf9b3e8 bellard
        gen_op_clrs();
268 fdf9b3e8 bellard
        return;
269 fdf9b3e8 bellard
    case 0x0008:                /* clrt */
270 fdf9b3e8 bellard
        gen_op_clrt();
271 fdf9b3e8 bellard
        return;
272 fdf9b3e8 bellard
    case 0x0038:                /* ldtlb */
273 ea2b542a aurel32
#if defined(CONFIG_USER_ONLY)
274 fdf9b3e8 bellard
        assert(0);                /* XXXXX */
275 ea2b542a aurel32
#else
276 ea2b542a aurel32
        gen_op_ldtlb();
277 ea2b542a aurel32
#endif
278 fdf9b3e8 bellard
        return;
279 c5e814b2 ths
    case 0x002b:                /* rte */
280 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_rte();
281 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
282 fdf9b3e8 bellard
        ctx->delayed_pc = (uint32_t) - 1;
283 fdf9b3e8 bellard
        return;
284 fdf9b3e8 bellard
    case 0x0058:                /* sets */
285 fdf9b3e8 bellard
        gen_op_sets();
286 fdf9b3e8 bellard
        return;
287 fdf9b3e8 bellard
    case 0x0018:                /* sett */
288 fdf9b3e8 bellard
        gen_op_sett();
289 fdf9b3e8 bellard
        return;
290 24988dc2 aurel32
    case 0xfbfd:                /* frchg */
291 eda9b09b bellard
        gen_op_frchg();
292 823029f9 ths
        ctx->bstate = BS_STOP;
293 fdf9b3e8 bellard
        return;
294 24988dc2 aurel32
    case 0xf3fd:                /* fschg */
295 eda9b09b bellard
        gen_op_fschg();
296 823029f9 ths
        ctx->bstate = BS_STOP;
297 fdf9b3e8 bellard
        return;
298 fdf9b3e8 bellard
    case 0x0009:                /* nop */
299 fdf9b3e8 bellard
        return;
300 fdf9b3e8 bellard
    case 0x001b:                /* sleep */
301 fdf9b3e8 bellard
        assert(0);                /* XXXXX */
302 fdf9b3e8 bellard
        return;
303 fdf9b3e8 bellard
    }
304 fdf9b3e8 bellard
305 fdf9b3e8 bellard
    switch (ctx->opcode & 0xf000) {
306 fdf9b3e8 bellard
    case 0x1000:                /* mov.l Rm,@(disp,Rn) */
307 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
308 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
309 fdf9b3e8 bellard
        gen_op_addl_imm_T1(B3_0 * 4);
310 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
311 fdf9b3e8 bellard
        return;
312 fdf9b3e8 bellard
    case 0x5000:                /* mov.l @(disp,Rm),Rn */
313 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
314 fdf9b3e8 bellard
        gen_op_addl_imm_T0(B3_0 * 4);
315 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
316 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
317 fdf9b3e8 bellard
        return;
318 24988dc2 aurel32
    case 0xe000:                /* mov #imm,Rn */
319 fdf9b3e8 bellard
        gen_op_movl_imm_rN(B7_0s, REG(B11_8));
320 fdf9b3e8 bellard
        return;
321 fdf9b3e8 bellard
    case 0x9000:                /* mov.w @(disp,PC),Rn */
322 fdf9b3e8 bellard
        gen_op_movl_imm_T0(ctx->pc + 4 + B7_0 * 2);
323 fdf9b3e8 bellard
        gen_op_ldw_T0_T0(ctx);
324 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
325 fdf9b3e8 bellard
        return;
326 fdf9b3e8 bellard
    case 0xd000:                /* mov.l @(disp,PC),Rn */
327 fdf9b3e8 bellard
        gen_op_movl_imm_T0((ctx->pc + 4 + B7_0 * 4) & ~3);
328 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
329 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
330 fdf9b3e8 bellard
        return;
331 24988dc2 aurel32
    case 0x7000:                /* add #imm,Rn */
332 fdf9b3e8 bellard
        gen_op_add_imm_rN(B7_0s, REG(B11_8));
333 fdf9b3e8 bellard
        return;
334 fdf9b3e8 bellard
    case 0xa000:                /* bra disp */
335 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT
336 fdf9b3e8 bellard
            gen_op_bra(ctx->delayed_pc = ctx->pc + 4 + B11_0s * 2);
337 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
338 fdf9b3e8 bellard
        return;
339 fdf9b3e8 bellard
    case 0xb000:                /* bsr disp */
340 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT
341 fdf9b3e8 bellard
            gen_op_bsr(ctx->pc + 4, ctx->delayed_pc =
342 fdf9b3e8 bellard
                       ctx->pc + 4 + B11_0s * 2);
343 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
344 fdf9b3e8 bellard
        return;
345 fdf9b3e8 bellard
    }
346 fdf9b3e8 bellard
347 fdf9b3e8 bellard
    switch (ctx->opcode & 0xf00f) {
348 fdf9b3e8 bellard
    case 0x6003:                /* mov Rm,Rn */
349 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
350 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
351 fdf9b3e8 bellard
        return;
352 fdf9b3e8 bellard
    case 0x2000:                /* mov.b Rm,@Rn */
353 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
354 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
355 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
356 fdf9b3e8 bellard
        return;
357 fdf9b3e8 bellard
    case 0x2001:                /* mov.w Rm,@Rn */
358 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
359 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
360 fdf9b3e8 bellard
        gen_op_stw_T0_T1(ctx);
361 fdf9b3e8 bellard
        return;
362 fdf9b3e8 bellard
    case 0x2002:                /* mov.l Rm,@Rn */
363 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
364 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
365 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
366 fdf9b3e8 bellard
        return;
367 fdf9b3e8 bellard
    case 0x6000:                /* mov.b @Rm,Rn */
368 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
369 fdf9b3e8 bellard
        gen_op_ldb_T0_T0(ctx);
370 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
371 fdf9b3e8 bellard
        return;
372 fdf9b3e8 bellard
    case 0x6001:                /* mov.w @Rm,Rn */
373 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
374 fdf9b3e8 bellard
        gen_op_ldw_T0_T0(ctx);
375 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
376 fdf9b3e8 bellard
        return;
377 fdf9b3e8 bellard
    case 0x6002:                /* mov.l @Rm,Rn */
378 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
379 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
380 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
381 fdf9b3e8 bellard
        return;
382 fdf9b3e8 bellard
    case 0x2004:                /* mov.b Rm,@-Rn */
383 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
384 24988dc2 aurel32
        gen_op_dec1_rN(REG(B11_8));
385 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
386 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
387 fdf9b3e8 bellard
        return;
388 fdf9b3e8 bellard
    case 0x2005:                /* mov.w Rm,@-Rn */
389 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
390 24988dc2 aurel32
        gen_op_dec2_rN(REG(B11_8));
391 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
392 fdf9b3e8 bellard
        gen_op_stw_T0_T1(ctx);
393 fdf9b3e8 bellard
        return;
394 fdf9b3e8 bellard
    case 0x2006:                /* mov.l Rm,@-Rn */
395 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
396 24988dc2 aurel32
        gen_op_dec4_rN(REG(B11_8));
397 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
398 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
399 fdf9b3e8 bellard
        return;
400 eda9b09b bellard
    case 0x6004:                /* mov.b @Rm+,Rn */
401 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
402 fdf9b3e8 bellard
        gen_op_ldb_T0_T0(ctx);
403 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
404 24988dc2 aurel32
        if ( B11_8 != B7_4 )
405 24988dc2 aurel32
                gen_op_inc1_rN(REG(B7_4));
406 fdf9b3e8 bellard
        return;
407 fdf9b3e8 bellard
    case 0x6005:                /* mov.w @Rm+,Rn */
408 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
409 fdf9b3e8 bellard
        gen_op_ldw_T0_T0(ctx);
410 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
411 24988dc2 aurel32
        if ( B11_8 != B7_4 )
412 24988dc2 aurel32
                gen_op_inc2_rN(REG(B7_4));
413 fdf9b3e8 bellard
        return;
414 fdf9b3e8 bellard
    case 0x6006:                /* mov.l @Rm+,Rn */
415 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
416 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
417 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
418 24988dc2 aurel32
        if ( B11_8 != B7_4 )
419 24988dc2 aurel32
                gen_op_inc4_rN(REG(B7_4));
420 fdf9b3e8 bellard
        return;
421 fdf9b3e8 bellard
    case 0x0004:                /* mov.b Rm,@(R0,Rn) */
422 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
423 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
424 fdf9b3e8 bellard
        gen_op_add_rN_T1(REG(0));
425 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
426 fdf9b3e8 bellard
        return;
427 fdf9b3e8 bellard
    case 0x0005:                /* mov.w Rm,@(R0,Rn) */
428 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
429 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
430 fdf9b3e8 bellard
        gen_op_add_rN_T1(REG(0));
431 fdf9b3e8 bellard
        gen_op_stw_T0_T1(ctx);
432 fdf9b3e8 bellard
        return;
433 fdf9b3e8 bellard
    case 0x0006:                /* mov.l Rm,@(R0,Rn) */
434 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
435 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
436 fdf9b3e8 bellard
        gen_op_add_rN_T1(REG(0));
437 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
438 fdf9b3e8 bellard
        return;
439 fdf9b3e8 bellard
    case 0x000c:                /* mov.b @(R0,Rm),Rn */
440 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
441 fdf9b3e8 bellard
        gen_op_add_rN_T0(REG(0));
442 fdf9b3e8 bellard
        gen_op_ldb_T0_T0(ctx);
443 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
444 fdf9b3e8 bellard
        return;
445 fdf9b3e8 bellard
    case 0x000d:                /* mov.w @(R0,Rm),Rn */
446 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
447 fdf9b3e8 bellard
        gen_op_add_rN_T0(REG(0));
448 fdf9b3e8 bellard
        gen_op_ldw_T0_T0(ctx);
449 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
450 fdf9b3e8 bellard
        return;
451 fdf9b3e8 bellard
    case 0x000e:                /* mov.l @(R0,Rm),Rn */
452 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
453 fdf9b3e8 bellard
        gen_op_add_rN_T0(REG(0));
454 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
455 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
456 fdf9b3e8 bellard
        return;
457 fdf9b3e8 bellard
    case 0x6008:                /* swap.b Rm,Rn */
458 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
459 fdf9b3e8 bellard
        gen_op_swapb_T0();
460 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
461 fdf9b3e8 bellard
        return;
462 fdf9b3e8 bellard
    case 0x6009:                /* swap.w Rm,Rn */
463 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
464 fdf9b3e8 bellard
        gen_op_swapw_T0();
465 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
466 fdf9b3e8 bellard
        return;
467 fdf9b3e8 bellard
    case 0x200d:                /* xtrct Rm,Rn */
468 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
469 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
470 fdf9b3e8 bellard
        gen_op_xtrct_T0_T1();
471 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
472 fdf9b3e8 bellard
        return;
473 fdf9b3e8 bellard
    case 0x300c:                /* add Rm,Rn */
474 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
475 fdf9b3e8 bellard
        gen_op_add_T0_rN(REG(B11_8));
476 fdf9b3e8 bellard
        return;
477 fdf9b3e8 bellard
    case 0x300e:                /* addc Rm,Rn */
478 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
479 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
480 fdf9b3e8 bellard
        gen_op_addc_T0_T1();
481 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
482 fdf9b3e8 bellard
        return;
483 fdf9b3e8 bellard
    case 0x300f:                /* addv Rm,Rn */
484 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
485 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
486 fdf9b3e8 bellard
        gen_op_addv_T0_T1();
487 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
488 fdf9b3e8 bellard
        return;
489 fdf9b3e8 bellard
    case 0x2009:                /* and Rm,Rn */
490 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
491 fdf9b3e8 bellard
        gen_op_and_T0_rN(REG(B11_8));
492 fdf9b3e8 bellard
        return;
493 fdf9b3e8 bellard
    case 0x3000:                /* cmp/eq Rm,Rn */
494 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
495 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
496 fdf9b3e8 bellard
        gen_op_cmp_eq_T0_T1();
497 fdf9b3e8 bellard
        return;
498 fdf9b3e8 bellard
    case 0x3003:                /* cmp/ge Rm,Rn */
499 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
500 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
501 fdf9b3e8 bellard
        gen_op_cmp_ge_T0_T1();
502 fdf9b3e8 bellard
        return;
503 fdf9b3e8 bellard
    case 0x3007:                /* cmp/gt Rm,Rn */
504 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
505 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
506 fdf9b3e8 bellard
        gen_op_cmp_gt_T0_T1();
507 fdf9b3e8 bellard
        return;
508 fdf9b3e8 bellard
    case 0x3006:                /* cmp/hi Rm,Rn */
509 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
510 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
511 fdf9b3e8 bellard
        gen_op_cmp_hi_T0_T1();
512 fdf9b3e8 bellard
        return;
513 fdf9b3e8 bellard
    case 0x3002:                /* cmp/hs Rm,Rn */
514 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
515 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
516 fdf9b3e8 bellard
        gen_op_cmp_hs_T0_T1();
517 fdf9b3e8 bellard
        return;
518 fdf9b3e8 bellard
    case 0x200c:                /* cmp/str Rm,Rn */
519 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
520 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
521 fdf9b3e8 bellard
        gen_op_cmp_str_T0_T1();
522 fdf9b3e8 bellard
        return;
523 fdf9b3e8 bellard
    case 0x2007:                /* div0s Rm,Rn */
524 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
525 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
526 fdf9b3e8 bellard
        gen_op_div0s_T0_T1();
527 fdf9b3e8 bellard
        return;
528 fdf9b3e8 bellard
    case 0x3004:                /* div1 Rm,Rn */
529 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
530 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
531 fdf9b3e8 bellard
        gen_op_div1_T0_T1();
532 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
533 fdf9b3e8 bellard
        return;
534 fdf9b3e8 bellard
    case 0x300d:                /* dmuls.l Rm,Rn */
535 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
536 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
537 fdf9b3e8 bellard
        gen_op_dmulsl_T0_T1();
538 fdf9b3e8 bellard
        return;
539 fdf9b3e8 bellard
    case 0x3005:                /* dmulu.l Rm,Rn */
540 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
541 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
542 fdf9b3e8 bellard
        gen_op_dmulul_T0_T1();
543 fdf9b3e8 bellard
        return;
544 fdf9b3e8 bellard
    case 0x600e:                /* exts.b Rm,Rn */
545 fdf9b3e8 bellard
        gen_op_movb_rN_T0(REG(B7_4));
546 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
547 fdf9b3e8 bellard
        return;
548 fdf9b3e8 bellard
    case 0x600f:                /* exts.w Rm,Rn */
549 fdf9b3e8 bellard
        gen_op_movw_rN_T0(REG(B7_4));
550 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
551 fdf9b3e8 bellard
        return;
552 fdf9b3e8 bellard
    case 0x600c:                /* extu.b Rm,Rn */
553 fdf9b3e8 bellard
        gen_op_movub_rN_T0(REG(B7_4));
554 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
555 fdf9b3e8 bellard
        return;
556 fdf9b3e8 bellard
    case 0x600d:                /* extu.w Rm,Rn */
557 fdf9b3e8 bellard
        gen_op_movuw_rN_T0(REG(B7_4));
558 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
559 fdf9b3e8 bellard
        return;
560 24988dc2 aurel32
    case 0x000f:                /* mac.l @Rm+,@Rn+ */
561 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
562 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
563 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
564 24988dc2 aurel32
        gen_op_inc4_rN(REG(B11_8));
565 24988dc2 aurel32
        gen_op_movl_rN_T0(REG(B7_4));
566 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
567 fdf9b3e8 bellard
        gen_op_macl_T0_T1();
568 fdf9b3e8 bellard
        gen_op_inc4_rN(REG(B7_4));
569 fdf9b3e8 bellard
        return;
570 fdf9b3e8 bellard
    case 0x400f:                /* mac.w @Rm+,@Rn+ */
571 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
572 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
573 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
574 24988dc2 aurel32
        gen_op_inc2_rN(REG(B11_8));
575 24988dc2 aurel32
        gen_op_movl_rN_T0(REG(B7_4));
576 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
577 fdf9b3e8 bellard
        gen_op_macw_T0_T1();
578 fdf9b3e8 bellard
        gen_op_inc2_rN(REG(B7_4));
579 fdf9b3e8 bellard
        return;
580 fdf9b3e8 bellard
    case 0x0007:                /* mul.l Rm,Rn */
581 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
582 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
583 fdf9b3e8 bellard
        gen_op_mull_T0_T1();
584 fdf9b3e8 bellard
        return;
585 fdf9b3e8 bellard
    case 0x200f:                /* muls.w Rm,Rn */
586 fdf9b3e8 bellard
        gen_op_movw_rN_T0(REG(B7_4));
587 fdf9b3e8 bellard
        gen_op_movw_rN_T1(REG(B11_8));
588 fdf9b3e8 bellard
        gen_op_mulsw_T0_T1();
589 fdf9b3e8 bellard
        return;
590 fdf9b3e8 bellard
    case 0x200e:                /* mulu.w Rm,Rn */
591 fdf9b3e8 bellard
        gen_op_movuw_rN_T0(REG(B7_4));
592 fdf9b3e8 bellard
        gen_op_movuw_rN_T1(REG(B11_8));
593 fdf9b3e8 bellard
        gen_op_muluw_T0_T1();
594 fdf9b3e8 bellard
        return;
595 fdf9b3e8 bellard
    case 0x600b:                /* neg Rm,Rn */
596 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
597 fdf9b3e8 bellard
        gen_op_neg_T0();
598 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
599 fdf9b3e8 bellard
        return;
600 fdf9b3e8 bellard
    case 0x600a:                /* negc Rm,Rn */
601 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
602 fdf9b3e8 bellard
        gen_op_negc_T0();
603 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
604 fdf9b3e8 bellard
        return;
605 fdf9b3e8 bellard
    case 0x6007:                /* not Rm,Rn */
606 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
607 fdf9b3e8 bellard
        gen_op_not_T0();
608 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(B11_8));
609 fdf9b3e8 bellard
        return;
610 fdf9b3e8 bellard
    case 0x200b:                /* or Rm,Rn */
611 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
612 fdf9b3e8 bellard
        gen_op_or_T0_rN(REG(B11_8));
613 fdf9b3e8 bellard
        return;
614 fdf9b3e8 bellard
    case 0x400c:                /* shad Rm,Rn */
615 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
616 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
617 fdf9b3e8 bellard
        gen_op_shad_T0_T1();
618 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
619 fdf9b3e8 bellard
        return;
620 fdf9b3e8 bellard
    case 0x400d:                /* shld Rm,Rn */
621 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
622 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
623 fdf9b3e8 bellard
        gen_op_shld_T0_T1();
624 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
625 fdf9b3e8 bellard
        return;
626 fdf9b3e8 bellard
    case 0x3008:                /* sub Rm,Rn */
627 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
628 fdf9b3e8 bellard
        gen_op_sub_T0_rN(REG(B11_8));
629 fdf9b3e8 bellard
        return;
630 fdf9b3e8 bellard
    case 0x300a:                /* subc Rm,Rn */
631 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
632 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
633 fdf9b3e8 bellard
        gen_op_subc_T0_T1();
634 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
635 fdf9b3e8 bellard
        return;
636 fdf9b3e8 bellard
    case 0x300b:                /* subv Rm,Rn */
637 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
638 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
639 fdf9b3e8 bellard
        gen_op_subv_T0_T1();
640 fdf9b3e8 bellard
        gen_op_movl_T1_rN(REG(B11_8));
641 fdf9b3e8 bellard
        return;
642 fdf9b3e8 bellard
    case 0x2008:                /* tst Rm,Rn */
643 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
644 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
645 fdf9b3e8 bellard
        gen_op_tst_T0_T1();
646 fdf9b3e8 bellard
        return;
647 fdf9b3e8 bellard
    case 0x200a:                /* xor Rm,Rn */
648 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
649 fdf9b3e8 bellard
        gen_op_xor_T0_rN(REG(B11_8));
650 fdf9b3e8 bellard
        return;
651 e67888a7 ths
    case 0xf00c: /* fmov {F,D,X}Rm,{F,D,X}Rn - FPSCR: Nothing */
652 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
653 24988dc2 aurel32
            gen_op_fmov_drN_DT0(XREG(B7_4));
654 24988dc2 aurel32
            gen_op_fmov_DT0_drN(XREG(B11_8));
655 eda9b09b bellard
        } else {
656 eda9b09b bellard
            gen_op_fmov_frN_FT0(FREG(B7_4));
657 eda9b09b bellard
            gen_op_fmov_FT0_frN(FREG(B11_8));
658 eda9b09b bellard
        }
659 eda9b09b bellard
        return;
660 e67888a7 ths
    case 0xf00a: /* fmov {F,D,X}Rm,@Rn - FPSCR: Nothing */
661 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
662 24988dc2 aurel32
            gen_op_fmov_drN_DT0(XREG(B7_4));
663 eda9b09b bellard
            gen_op_movl_rN_T1(REG(B11_8));
664 eda9b09b bellard
            gen_op_stfq_DT0_T1(ctx);
665 eda9b09b bellard
        } else {
666 eda9b09b bellard
            gen_op_fmov_frN_FT0(FREG(B7_4));
667 eda9b09b bellard
            gen_op_movl_rN_T1(REG(B11_8));
668 eda9b09b bellard
            gen_op_stfl_FT0_T1(ctx);
669 eda9b09b bellard
        }
670 eda9b09b bellard
        return;
671 e67888a7 ths
    case 0xf008: /* fmov @Rm,{F,D,X}Rn - FPSCR: Nothing */
672 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
673 eda9b09b bellard
            gen_op_movl_rN_T0(REG(B7_4));
674 eda9b09b bellard
            gen_op_ldfq_T0_DT0(ctx);
675 24988dc2 aurel32
            gen_op_fmov_DT0_drN(XREG(B11_8));
676 eda9b09b bellard
        } else {
677 eda9b09b bellard
            gen_op_movl_rN_T0(REG(B7_4));
678 eda9b09b bellard
            gen_op_ldfl_T0_FT0(ctx);
679 f09111e0 ths
            gen_op_fmov_FT0_frN(FREG(B11_8));
680 eda9b09b bellard
        }
681 eda9b09b bellard
        return;
682 e67888a7 ths
    case 0xf009: /* fmov @Rm+,{F,D,X}Rn - FPSCR: Nothing */
683 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
684 eda9b09b bellard
            gen_op_movl_rN_T0(REG(B7_4));
685 eda9b09b bellard
            gen_op_ldfq_T0_DT0(ctx);
686 24988dc2 aurel32
            gen_op_fmov_DT0_drN(XREG(B11_8));
687 eda9b09b bellard
            gen_op_inc8_rN(REG(B7_4));
688 eda9b09b bellard
        } else {
689 eda9b09b bellard
            gen_op_movl_rN_T0(REG(B7_4));
690 eda9b09b bellard
            gen_op_ldfl_T0_FT0(ctx);
691 f09111e0 ths
            gen_op_fmov_FT0_frN(FREG(B11_8));
692 eda9b09b bellard
            gen_op_inc4_rN(REG(B7_4));
693 eda9b09b bellard
        }
694 eda9b09b bellard
        return;
695 e67888a7 ths
    case 0xf00b: /* fmov {F,D,X}Rm,@-Rn - FPSCR: Nothing */
696 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
697 eda9b09b bellard
            gen_op_dec8_rN(REG(B11_8));
698 24988dc2 aurel32
            gen_op_fmov_drN_DT0(XREG(B7_4));
699 eda9b09b bellard
            gen_op_movl_rN_T1(REG(B11_8));
700 eda9b09b bellard
            gen_op_stfq_DT0_T1(ctx);
701 eda9b09b bellard
        } else {
702 eda9b09b bellard
            gen_op_dec4_rN(REG(B11_8));
703 eda9b09b bellard
            gen_op_fmov_frN_FT0(FREG(B7_4));
704 eda9b09b bellard
            gen_op_movl_rN_T1(REG(B11_8));
705 eda9b09b bellard
            gen_op_stfl_FT0_T1(ctx);
706 eda9b09b bellard
        }
707 eda9b09b bellard
        return;
708 e67888a7 ths
    case 0xf006: /* fmov @(R0,Rm),{F,D,X}Rm - FPSCR: Nothing */
709 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
710 eda9b09b bellard
            gen_op_movl_rN_T0(REG(B7_4));
711 eda9b09b bellard
            gen_op_add_rN_T0(REG(0));
712 eda9b09b bellard
            gen_op_ldfq_T0_DT0(ctx);
713 24988dc2 aurel32
            gen_op_fmov_DT0_drN(XREG(B11_8));
714 eda9b09b bellard
        } else {
715 eda9b09b bellard
            gen_op_movl_rN_T0(REG(B7_4));
716 eda9b09b bellard
            gen_op_add_rN_T0(REG(0));
717 eda9b09b bellard
            gen_op_ldfl_T0_FT0(ctx);
718 f09111e0 ths
            gen_op_fmov_FT0_frN(FREG(B11_8));
719 eda9b09b bellard
        }
720 eda9b09b bellard
        return;
721 e67888a7 ths
    case 0xf007: /* fmov {F,D,X}Rn,@(R0,Rn) - FPSCR: Nothing */
722 022a22c7 ths
        if (ctx->fpscr & FPSCR_SZ) {
723 24988dc2 aurel32
            gen_op_fmov_drN_DT0(XREG(B7_4));
724 eda9b09b bellard
            gen_op_movl_rN_T1(REG(B11_8));
725 eda9b09b bellard
            gen_op_add_rN_T1(REG(0));
726 eda9b09b bellard
            gen_op_stfq_DT0_T1(ctx);
727 eda9b09b bellard
        } else {
728 eda9b09b bellard
            gen_op_fmov_frN_FT0(FREG(B7_4));
729 eda9b09b bellard
            gen_op_movl_rN_T1(REG(B11_8));
730 eda9b09b bellard
            gen_op_add_rN_T1(REG(0));
731 eda9b09b bellard
            gen_op_stfl_FT0_T1(ctx);
732 eda9b09b bellard
        }
733 eda9b09b bellard
        return;
734 e67888a7 ths
    case 0xf000: /* fadd Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
735 e67888a7 ths
    case 0xf001: /* fsub Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
736 e67888a7 ths
    case 0xf002: /* fmul Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
737 e67888a7 ths
    case 0xf003: /* fdiv Rm,Rn - FPSCR: R[PR,Enable.O/U/I]/W[Cause,Flag] */
738 e67888a7 ths
    case 0xf004: /* fcmp/eq Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
739 e67888a7 ths
    case 0xf005: /* fcmp/gt Rm,Rn - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
740 ea6cf6be ths
        if (ctx->fpscr & FPSCR_PR) {
741 ea6cf6be ths
            if (ctx->opcode & 0x0110)
742 ea6cf6be ths
                break; /* illegal instruction */
743 ea6cf6be ths
            gen_op_fmov_drN_DT1(DREG(B7_4));
744 ea6cf6be ths
            gen_op_fmov_drN_DT0(DREG(B11_8));
745 ea6cf6be ths
        }
746 ea6cf6be ths
        else {
747 ea6cf6be ths
            gen_op_fmov_frN_FT1(FREG(B7_4));
748 ea6cf6be ths
            gen_op_fmov_frN_FT0(FREG(B11_8));
749 ea6cf6be ths
        }
750 ea6cf6be ths
751 ea6cf6be ths
        switch (ctx->opcode & 0xf00f) {
752 ea6cf6be ths
        case 0xf000:                /* fadd Rm,Rn */
753 ea6cf6be ths
            ctx->fpscr & FPSCR_PR ? gen_op_fadd_DT() : gen_op_fadd_FT();
754 ea6cf6be ths
            break;
755 ea6cf6be ths
        case 0xf001:                /* fsub Rm,Rn */
756 ea6cf6be ths
            ctx->fpscr & FPSCR_PR ? gen_op_fsub_DT() : gen_op_fsub_FT();
757 ea6cf6be ths
            break;
758 ea6cf6be ths
        case 0xf002:                /* fmul Rm,Rn */
759 ea6cf6be ths
            ctx->fpscr & FPSCR_PR ? gen_op_fmul_DT() : gen_op_fmul_FT();
760 ea6cf6be ths
            break;
761 ea6cf6be ths
        case 0xf003:                /* fdiv Rm,Rn */
762 ea6cf6be ths
            ctx->fpscr & FPSCR_PR ? gen_op_fdiv_DT() : gen_op_fdiv_FT();
763 ea6cf6be ths
            break;
764 ea6cf6be ths
        case 0xf004:                /* fcmp/eq Rm,Rn */
765 24988dc2 aurel32
            ctx->fpscr & FPSCR_PR ? gen_op_fcmp_eq_DT() : gen_op_fcmp_eq_FT();
766 ea6cf6be ths
            return;
767 ea6cf6be ths
        case 0xf005:                /* fcmp/gt Rm,Rn */
768 24988dc2 aurel32
            ctx->fpscr & FPSCR_PR ? gen_op_fcmp_gt_DT() : gen_op_fcmp_gt_FT();
769 ea6cf6be ths
            return;
770 ea6cf6be ths
        }
771 ea6cf6be ths
772 ea6cf6be ths
        if (ctx->fpscr & FPSCR_PR) {
773 ea6cf6be ths
            gen_op_fmov_DT0_drN(DREG(B11_8));
774 ea6cf6be ths
        }
775 ea6cf6be ths
        else {
776 ea6cf6be ths
            gen_op_fmov_FT0_frN(FREG(B11_8));
777 ea6cf6be ths
        }
778 ea6cf6be ths
        return;
779 fdf9b3e8 bellard
    }
780 fdf9b3e8 bellard
781 fdf9b3e8 bellard
    switch (ctx->opcode & 0xff00) {
782 fdf9b3e8 bellard
    case 0xc900:                /* and #imm,R0 */
783 fdf9b3e8 bellard
        gen_op_and_imm_rN(B7_0, REG(0));
784 fdf9b3e8 bellard
        return;
785 24988dc2 aurel32
    case 0xcd00:                /* and.b #imm,@(R0,GBR) */
786 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
787 fdf9b3e8 bellard
        gen_op_addl_GBR_T0();
788 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
789 24988dc2 aurel32
        gen_op_ldub_T0_T0(ctx);
790 fdf9b3e8 bellard
        gen_op_and_imm_T0(B7_0);
791 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
792 fdf9b3e8 bellard
        return;
793 fdf9b3e8 bellard
    case 0x8b00:                /* bf label */
794 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT
795 fdf9b3e8 bellard
            gen_conditional_jump(ctx, ctx->pc + 2,
796 fdf9b3e8 bellard
                                 ctx->pc + 4 + B7_0s * 2);
797 823029f9 ths
        ctx->bstate = BS_BRANCH;
798 fdf9b3e8 bellard
        return;
799 fdf9b3e8 bellard
    case 0x8f00:                /* bf/s label */
800 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT
801 fdf9b3e8 bellard
            gen_op_bf_s(ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2);
802 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT_CONDITIONAL;
803 fdf9b3e8 bellard
        return;
804 fdf9b3e8 bellard
    case 0x8900:                /* bt label */
805 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT
806 fdf9b3e8 bellard
            gen_conditional_jump(ctx, ctx->pc + 4 + B7_0s * 2,
807 fdf9b3e8 bellard
                                 ctx->pc + 2);
808 823029f9 ths
        ctx->bstate = BS_BRANCH;
809 fdf9b3e8 bellard
        return;
810 fdf9b3e8 bellard
    case 0x8d00:                /* bt/s label */
811 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT
812 fdf9b3e8 bellard
            gen_op_bt_s(ctx->delayed_pc = ctx->pc + 4 + B7_0s * 2);
813 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT_CONDITIONAL;
814 fdf9b3e8 bellard
        return;
815 fdf9b3e8 bellard
    case 0x8800:                /* cmp/eq #imm,R0 */
816 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
817 fdf9b3e8 bellard
        gen_op_cmp_eq_imm_T0(B7_0s);
818 fdf9b3e8 bellard
        return;
819 fdf9b3e8 bellard
    case 0xc400:                /* mov.b @(disp,GBR),R0 */
820 fdf9b3e8 bellard
        gen_op_stc_gbr_T0();
821 fdf9b3e8 bellard
        gen_op_addl_imm_T0(B7_0);
822 fdf9b3e8 bellard
        gen_op_ldb_T0_T0(ctx);
823 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(0));
824 fdf9b3e8 bellard
        return;
825 fdf9b3e8 bellard
    case 0xc500:                /* mov.w @(disp,GBR),R0 */
826 fdf9b3e8 bellard
        gen_op_stc_gbr_T0();
827 24988dc2 aurel32
        gen_op_addl_imm_T0(B7_0 * 2);
828 fdf9b3e8 bellard
        gen_op_ldw_T0_T0(ctx);
829 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(0));
830 fdf9b3e8 bellard
        return;
831 fdf9b3e8 bellard
    case 0xc600:                /* mov.l @(disp,GBR),R0 */
832 fdf9b3e8 bellard
        gen_op_stc_gbr_T0();
833 24988dc2 aurel32
        gen_op_addl_imm_T0(B7_0 * 4);
834 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
835 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(0));
836 fdf9b3e8 bellard
        return;
837 fdf9b3e8 bellard
    case 0xc000:                /* mov.b R0,@(disp,GBR) */
838 fdf9b3e8 bellard
        gen_op_stc_gbr_T0();
839 fdf9b3e8 bellard
        gen_op_addl_imm_T0(B7_0);
840 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
841 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
842 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
843 fdf9b3e8 bellard
        return;
844 fdf9b3e8 bellard
    case 0xc100:                /* mov.w R0,@(disp,GBR) */
845 fdf9b3e8 bellard
        gen_op_stc_gbr_T0();
846 24988dc2 aurel32
        gen_op_addl_imm_T0(B7_0 * 2);
847 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
848 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
849 fdf9b3e8 bellard
        gen_op_stw_T0_T1(ctx);
850 fdf9b3e8 bellard
        return;
851 fdf9b3e8 bellard
    case 0xc200:                /* mov.l R0,@(disp,GBR) */
852 fdf9b3e8 bellard
        gen_op_stc_gbr_T0();
853 24988dc2 aurel32
        gen_op_addl_imm_T0(B7_0 * 4);
854 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
855 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
856 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
857 fdf9b3e8 bellard
        return;
858 fdf9b3e8 bellard
    case 0x8000:                /* mov.b R0,@(disp,Rn) */
859 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
860 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B7_4));
861 fdf9b3e8 bellard
        gen_op_addl_imm_T1(B3_0);
862 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
863 fdf9b3e8 bellard
        return;
864 fdf9b3e8 bellard
    case 0x8100:                /* mov.w R0,@(disp,Rn) */
865 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
866 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B7_4));
867 fdf9b3e8 bellard
        gen_op_addl_imm_T1(B3_0 * 2);
868 fdf9b3e8 bellard
        gen_op_stw_T0_T1(ctx);
869 fdf9b3e8 bellard
        return;
870 fdf9b3e8 bellard
    case 0x8400:                /* mov.b @(disp,Rn),R0 */
871 8c2cc7ce ths
        gen_op_movl_rN_T0(REG(B7_4));
872 8c2cc7ce ths
        gen_op_addl_imm_T0(B3_0);
873 8c2cc7ce ths
        gen_op_ldb_T0_T0(ctx);
874 8c2cc7ce ths
        gen_op_movl_T0_rN(REG(0));
875 fdf9b3e8 bellard
        return;
876 fdf9b3e8 bellard
    case 0x8500:                /* mov.w @(disp,Rn),R0 */
877 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B7_4));
878 fdf9b3e8 bellard
        gen_op_addl_imm_T0(B3_0 * 2);
879 fdf9b3e8 bellard
        gen_op_ldw_T0_T0(ctx);
880 fdf9b3e8 bellard
        gen_op_movl_T0_rN(REG(0));
881 fdf9b3e8 bellard
        return;
882 fdf9b3e8 bellard
    case 0xc700:                /* mova @(disp,PC),R0 */
883 fdf9b3e8 bellard
        gen_op_movl_imm_rN(((ctx->pc & 0xfffffffc) + 4 + B7_0 * 4) & ~3,
884 fdf9b3e8 bellard
                           REG(0));
885 fdf9b3e8 bellard
        return;
886 fdf9b3e8 bellard
    case 0xcb00:                /* or #imm,R0 */
887 fdf9b3e8 bellard
        gen_op_or_imm_rN(B7_0, REG(0));
888 fdf9b3e8 bellard
        return;
889 24988dc2 aurel32
    case 0xcf00:                /* or.b #imm,@(R0,GBR) */
890 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
891 fdf9b3e8 bellard
        gen_op_addl_GBR_T0();
892 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
893 24988dc2 aurel32
        gen_op_ldub_T0_T0(ctx);
894 fdf9b3e8 bellard
        gen_op_or_imm_T0(B7_0);
895 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
896 fdf9b3e8 bellard
        return;
897 fdf9b3e8 bellard
    case 0xc300:                /* trapa #imm */
898 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_movl_imm_PC(ctx->pc);
899 fdf9b3e8 bellard
        gen_op_trapa(B7_0);
900 823029f9 ths
        ctx->bstate = BS_BRANCH;
901 fdf9b3e8 bellard
        return;
902 fdf9b3e8 bellard
    case 0xc800:                /* tst #imm,R0 */
903 fdf9b3e8 bellard
        gen_op_tst_imm_rN(B7_0, REG(0));
904 fdf9b3e8 bellard
        return;
905 24988dc2 aurel32
    case 0xcc00:                /* tst.b #imm,@(R0,GBR) */
906 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
907 fdf9b3e8 bellard
        gen_op_addl_GBR_T0();
908 24988dc2 aurel32
        gen_op_ldub_T0_T0(ctx);
909 fdf9b3e8 bellard
        gen_op_tst_imm_T0(B7_0);
910 fdf9b3e8 bellard
        return;
911 fdf9b3e8 bellard
    case 0xca00:                /* xor #imm,R0 */
912 fdf9b3e8 bellard
        gen_op_xor_imm_rN(B7_0, REG(0));
913 fdf9b3e8 bellard
        return;
914 24988dc2 aurel32
    case 0xce00:                /* xor.b #imm,@(R0,GBR) */
915 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
916 fdf9b3e8 bellard
        gen_op_addl_GBR_T0();
917 fdf9b3e8 bellard
        gen_op_movl_T0_T1();
918 24988dc2 aurel32
        gen_op_ldub_T0_T0(ctx);
919 fdf9b3e8 bellard
        gen_op_xor_imm_T0(B7_0);
920 fdf9b3e8 bellard
        gen_op_stb_T0_T1(ctx);
921 fdf9b3e8 bellard
        return;
922 fdf9b3e8 bellard
    }
923 fdf9b3e8 bellard
924 fdf9b3e8 bellard
    switch (ctx->opcode & 0xf08f) {
925 fdf9b3e8 bellard
    case 0x408e:                /* ldc Rm,Rn_BANK */
926 fdf9b3e8 bellard
        gen_op_movl_rN_rN(REG(B11_8), ALTREG(B6_4));
927 fdf9b3e8 bellard
        return;
928 fdf9b3e8 bellard
    case 0x4087:                /* ldc.l @Rm+,Rn_BANK */
929 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
930 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
931 fdf9b3e8 bellard
        gen_op_movl_T0_rN(ALTREG(B6_4));
932 fdf9b3e8 bellard
        gen_op_inc4_rN(REG(B11_8));
933 fdf9b3e8 bellard
        return;
934 fdf9b3e8 bellard
    case 0x0082:                /* stc Rm_BANK,Rn */
935 fdf9b3e8 bellard
        gen_op_movl_rN_rN(ALTREG(B6_4), REG(B11_8));
936 fdf9b3e8 bellard
        return;
937 fdf9b3e8 bellard
    case 0x4083:                /* stc.l Rm_BANK,@-Rn */
938 fdf9b3e8 bellard
        gen_op_dec4_rN(REG(B11_8));
939 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
940 fdf9b3e8 bellard
        gen_op_movl_rN_T0(ALTREG(B6_4));
941 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
942 fdf9b3e8 bellard
        return;
943 fdf9b3e8 bellard
    }
944 fdf9b3e8 bellard
945 fdf9b3e8 bellard
    switch (ctx->opcode & 0xf0ff) {
946 fdf9b3e8 bellard
    case 0x0023:                /* braf Rn */
947 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_movl_rN_T0(REG(B11_8));
948 fdf9b3e8 bellard
        gen_op_braf_T0(ctx->pc + 4);
949 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
950 fdf9b3e8 bellard
        ctx->delayed_pc = (uint32_t) - 1;
951 fdf9b3e8 bellard
        return;
952 fdf9b3e8 bellard
    case 0x0003:                /* bsrf Rn */
953 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_movl_rN_T0(REG(B11_8));
954 fdf9b3e8 bellard
        gen_op_bsrf_T0(ctx->pc + 4);
955 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
956 fdf9b3e8 bellard
        ctx->delayed_pc = (uint32_t) - 1;
957 fdf9b3e8 bellard
        return;
958 fdf9b3e8 bellard
    case 0x4015:                /* cmp/pl Rn */
959 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
960 fdf9b3e8 bellard
        gen_op_cmp_pl_T0();
961 fdf9b3e8 bellard
        return;
962 fdf9b3e8 bellard
    case 0x4011:                /* cmp/pz Rn */
963 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
964 fdf9b3e8 bellard
        gen_op_cmp_pz_T0();
965 fdf9b3e8 bellard
        return;
966 fdf9b3e8 bellard
    case 0x4010:                /* dt Rn */
967 fdf9b3e8 bellard
        gen_op_dt_rN(REG(B11_8));
968 fdf9b3e8 bellard
        return;
969 fdf9b3e8 bellard
    case 0x402b:                /* jmp @Rn */
970 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_movl_rN_T0(REG(B11_8));
971 fdf9b3e8 bellard
        gen_op_jmp_T0();
972 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
973 fdf9b3e8 bellard
        ctx->delayed_pc = (uint32_t) - 1;
974 fdf9b3e8 bellard
        return;
975 fdf9b3e8 bellard
    case 0x400b:                /* jsr @Rn */
976 fdf9b3e8 bellard
        CHECK_NOT_DELAY_SLOT gen_op_movl_rN_T0(REG(B11_8));
977 fdf9b3e8 bellard
        gen_op_jsr_T0(ctx->pc + 4);
978 fdf9b3e8 bellard
        ctx->flags |= DELAY_SLOT;
979 fdf9b3e8 bellard
        ctx->delayed_pc = (uint32_t) - 1;
980 fdf9b3e8 bellard
        return;
981 fdf9b3e8 bellard
#define LDST(reg,ldnum,ldpnum,ldop,stnum,stpnum,stop,extrald)        \
982 fdf9b3e8 bellard
  case ldnum:                                                        \
983 fdf9b3e8 bellard
    gen_op_movl_rN_T0 (REG(B11_8));                                \
984 fdf9b3e8 bellard
    gen_op_##ldop##_T0_##reg ();                                \
985 fdf9b3e8 bellard
    extrald                                                        \
986 fdf9b3e8 bellard
    return;                                                        \
987 fdf9b3e8 bellard
  case ldpnum:                                                        \
988 fdf9b3e8 bellard
    gen_op_movl_rN_T0 (REG(B11_8));                                \
989 fdf9b3e8 bellard
    gen_op_ldl_T0_T0 (ctx);                                        \
990 fdf9b3e8 bellard
    gen_op_inc4_rN (REG(B11_8));                                \
991 fdf9b3e8 bellard
    gen_op_##ldop##_T0_##reg ();                                \
992 fdf9b3e8 bellard
    extrald                                                        \
993 fdf9b3e8 bellard
    return;                                                        \
994 fdf9b3e8 bellard
  case stnum:                                                        \
995 fdf9b3e8 bellard
    gen_op_##stop##_##reg##_T0 ();                                        \
996 fdf9b3e8 bellard
    gen_op_movl_T0_rN (REG(B11_8));                                \
997 fdf9b3e8 bellard
    return;                                                        \
998 fdf9b3e8 bellard
  case stpnum:                                                        \
999 fdf9b3e8 bellard
    gen_op_##stop##_##reg##_T0 ();                                \
1000 fdf9b3e8 bellard
    gen_op_dec4_rN (REG(B11_8));                                \
1001 fdf9b3e8 bellard
    gen_op_movl_rN_T1 (REG(B11_8));                                \
1002 fdf9b3e8 bellard
    gen_op_stl_T0_T1 (ctx);                                        \
1003 fdf9b3e8 bellard
    return;
1004 823029f9 ths
        LDST(sr, 0x400e, 0x4007, ldc, 0x0002, 0x4003, stc, ctx->bstate =
1005 823029f9 ths
             BS_STOP;)
1006 eda9b09b bellard
        LDST(gbr, 0x401e, 0x4017, ldc, 0x0012, 0x4013, stc,)
1007 eda9b09b bellard
        LDST(vbr, 0x402e, 0x4027, ldc, 0x0022, 0x4023, stc,)
1008 eda9b09b bellard
        LDST(ssr, 0x403e, 0x4037, ldc, 0x0032, 0x4033, stc,)
1009 eda9b09b bellard
        LDST(spc, 0x404e, 0x4047, ldc, 0x0042, 0x4043, stc,)
1010 eda9b09b bellard
        LDST(dbr, 0x40fa, 0x40f6, ldc, 0x00fa, 0x40f2, stc,)
1011 eda9b09b bellard
        LDST(mach, 0x400a, 0x4006, lds, 0x000a, 0x4002, sts,)
1012 eda9b09b bellard
        LDST(macl, 0x401a, 0x4016, lds, 0x001a, 0x4012, sts,)
1013 eda9b09b bellard
        LDST(pr, 0x402a, 0x4026, lds, 0x002a, 0x4022, sts,)
1014 8bf5a804 ths
        LDST(fpul, 0x405a, 0x4056, lds, 0x005a, 0x4052, sts,)
1015 823029f9 ths
        LDST(fpscr, 0x406a, 0x4066, lds, 0x006a, 0x4062, sts, ctx->bstate =
1016 823029f9 ths
             BS_STOP;)
1017 fdf9b3e8 bellard
    case 0x00c3:                /* movca.l R0,@Rm */
1018 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(0));
1019 fdf9b3e8 bellard
        gen_op_movl_rN_T1(REG(B11_8));
1020 fdf9b3e8 bellard
        gen_op_stl_T0_T1(ctx);
1021 fdf9b3e8 bellard
        return;
1022 fdf9b3e8 bellard
    case 0x0029:                /* movt Rn */
1023 fdf9b3e8 bellard
        gen_op_movt_rN(REG(B11_8));
1024 fdf9b3e8 bellard
        return;
1025 fdf9b3e8 bellard
    case 0x0093:                /* ocbi @Rn */
1026 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
1027 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
1028 fdf9b3e8 bellard
        return;
1029 24988dc2 aurel32
    case 0x00a3:                /* ocbp @Rn */
1030 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
1031 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
1032 fdf9b3e8 bellard
        return;
1033 fdf9b3e8 bellard
    case 0x00b3:                /* ocbwb @Rn */
1034 fdf9b3e8 bellard
        gen_op_movl_rN_T0(REG(B11_8));
1035 fdf9b3e8 bellard
        gen_op_ldl_T0_T0(ctx);
1036 fdf9b3e8 bellard
        return;
1037 fdf9b3e8 bellard
    case 0x0083:                /* pref @Rn */
1038 fdf9b3e8 bellard
        return;
1039 fdf9b3e8 bellard
    case 0x4024:                /* rotcl Rn */
1040 fdf9b3e8 bellard
        gen_op_rotcl_Rn(REG(B11_8));
1041 fdf9b3e8 bellard
        return;
1042 fdf9b3e8 bellard
    case 0x4025:                /* rotcr Rn */
1043 fdf9b3e8 bellard
        gen_op_rotcr_Rn(REG(B11_8));
1044 fdf9b3e8 bellard
        return;
1045 fdf9b3e8 bellard
    case 0x4004:                /* rotl Rn */
1046 fdf9b3e8 bellard
        gen_op_rotl_Rn(REG(B11_8));
1047 fdf9b3e8 bellard
        return;
1048 fdf9b3e8 bellard
    case 0x4005:                /* rotr Rn */
1049 fdf9b3e8 bellard
        gen_op_rotr_Rn(REG(B11_8));
1050 fdf9b3e8 bellard
        return;
1051 fdf9b3e8 bellard
    case 0x4000:                /* shll Rn */
1052 fdf9b3e8 bellard
    case 0x4020:                /* shal Rn */
1053 fdf9b3e8 bellard
        gen_op_shal_Rn(REG(B11_8));
1054 fdf9b3e8 bellard
        return;
1055 fdf9b3e8 bellard
    case 0x4021:                /* shar Rn */
1056 fdf9b3e8 bellard
        gen_op_shar_Rn(REG(B11_8));
1057 fdf9b3e8 bellard
        return;
1058 fdf9b3e8 bellard
    case 0x4001:                /* shlr Rn */
1059 fdf9b3e8 bellard
        gen_op_shlr_Rn(REG(B11_8));
1060 fdf9b3e8 bellard
        return;
1061 fdf9b3e8 bellard
    case 0x4008:                /* shll2 Rn */
1062 fdf9b3e8 bellard
        gen_op_shll2_Rn(REG(B11_8));
1063 fdf9b3e8 bellard
        return;
1064 fdf9b3e8 bellard
    case 0x4018:                /* shll8 Rn */
1065 fdf9b3e8 bellard
        gen_op_shll8_Rn(REG(B11_8));
1066 fdf9b3e8 bellard
        return;
1067 fdf9b3e8 bellard
    case 0x4028:                /* shll16 Rn */
1068 fdf9b3e8 bellard
        gen_op_shll16_Rn(REG(B11_8));
1069 fdf9b3e8 bellard
        return;
1070 fdf9b3e8 bellard
    case 0x4009:                /* shlr2 Rn */
1071 fdf9b3e8 bellard
        gen_op_shlr2_Rn(REG(B11_8));
1072 fdf9b3e8 bellard
        return;
1073 fdf9b3e8 bellard
    case 0x4019:                /* shlr8 Rn */
1074 fdf9b3e8 bellard
        gen_op_shlr8_Rn(REG(B11_8));
1075 fdf9b3e8 bellard
        return;
1076 fdf9b3e8 bellard
    case 0x4029:                /* shlr16 Rn */
1077 fdf9b3e8 bellard
        gen_op_shlr16_Rn(REG(B11_8));
1078 fdf9b3e8 bellard
        return;
1079 fdf9b3e8 bellard
    case 0x401b:                /* tas.b @Rn */
1080 fdf9b3e8 bellard
        gen_op_tasb_rN(REG(B11_8));
1081 fdf9b3e8 bellard
        return;
1082 e67888a7 ths
    case 0xf00d: /* fsts FPUL,FRn - FPSCR: Nothing */
1083 eda9b09b bellard
        gen_op_movl_fpul_FT0();
1084 eda9b09b bellard
        gen_op_fmov_FT0_frN(FREG(B11_8));
1085 eda9b09b bellard
        return;
1086 e67888a7 ths
    case 0xf01d: /* flds FRm,FPUL - FPSCR: Nothing */
1087 eda9b09b bellard
        gen_op_fmov_frN_FT0(FREG(B11_8));
1088 eda9b09b bellard
        gen_op_movl_FT0_fpul();
1089 eda9b09b bellard
        return;
1090 e67888a7 ths
    case 0xf02d: /* float FPUL,FRn/DRn - FPSCR: R[PR,Enable.I]/W[Cause,Flag] */
1091 ea6cf6be ths
        if (ctx->fpscr & FPSCR_PR) {
1092 ea6cf6be ths
            if (ctx->opcode & 0x0100)
1093 ea6cf6be ths
                break; /* illegal instruction */
1094 ea6cf6be ths
            gen_op_float_DT();
1095 ea6cf6be ths
            gen_op_fmov_DT0_drN(DREG(B11_8));
1096 ea6cf6be ths
        }
1097 ea6cf6be ths
        else {
1098 ea6cf6be ths
            gen_op_float_FT();
1099 ea6cf6be ths
            gen_op_fmov_FT0_frN(FREG(B11_8));
1100 ea6cf6be ths
        }
1101 ea6cf6be ths
        return;
1102 e67888a7 ths
    case 0xf03d: /* ftrc FRm/DRm,FPUL - FPSCR: R[PR,Enable.V]/W[Cause,Flag] */
1103 ea6cf6be ths
        if (ctx->fpscr & FPSCR_PR) {
1104 ea6cf6be ths
            if (ctx->opcode & 0x0100)
1105 ea6cf6be ths
                break; /* illegal instruction */
1106 ea6cf6be ths
            gen_op_fmov_drN_DT0(DREG(B11_8));
1107 ea6cf6be ths
            gen_op_ftrc_DT();
1108 ea6cf6be ths
        }
1109 ea6cf6be ths
        else {
1110 ea6cf6be ths
            gen_op_fmov_frN_FT0(FREG(B11_8));
1111 ea6cf6be ths
            gen_op_ftrc_FT();
1112 ea6cf6be ths
        }
1113 ea6cf6be ths
        return;
1114 24988dc2 aurel32
    case 0xf04d: /* fneg FRn/DRn - FPSCR: Nothing */
1115 24988dc2 aurel32
        gen_op_fneg_frN(FREG(B11_8));
1116 24988dc2 aurel32
        return;
1117 24988dc2 aurel32
    case 0xf05d: /* fabs FRn/DRn */
1118 24988dc2 aurel32
        if (ctx->fpscr & FPSCR_PR) {
1119 24988dc2 aurel32
            if (ctx->opcode & 0x0100)
1120 24988dc2 aurel32
                break; /* illegal instruction */
1121 24988dc2 aurel32
            gen_op_fmov_drN_DT0(DREG(B11_8));
1122 24988dc2 aurel32
            gen_op_fabs_DT();
1123 24988dc2 aurel32
            gen_op_fmov_DT0_drN(DREG(B11_8));
1124 24988dc2 aurel32
        } else {
1125 24988dc2 aurel32
            gen_op_fmov_frN_FT0(FREG(B11_8));
1126 24988dc2 aurel32
            gen_op_fabs_FT();
1127 24988dc2 aurel32
            gen_op_fmov_FT0_frN(FREG(B11_8));
1128 24988dc2 aurel32
        }
1129 24988dc2 aurel32
        return;
1130 24988dc2 aurel32
    case 0xf06d: /* fsqrt FRn */
1131 24988dc2 aurel32
        if (ctx->fpscr & FPSCR_PR) {
1132 24988dc2 aurel32
            if (ctx->opcode & 0x0100)
1133 24988dc2 aurel32
                break; /* illegal instruction */
1134 24988dc2 aurel32
            gen_op_fmov_drN_DT0(FREG(B11_8));
1135 24988dc2 aurel32
            gen_op_fsqrt_DT();
1136 24988dc2 aurel32
            gen_op_fmov_DT0_drN(FREG(B11_8));
1137 24988dc2 aurel32
        } else {
1138 24988dc2 aurel32
            gen_op_fmov_frN_FT0(FREG(B11_8));
1139 24988dc2 aurel32
            gen_op_fsqrt_FT();
1140 24988dc2 aurel32
            gen_op_fmov_FT0_frN(FREG(B11_8));
1141 24988dc2 aurel32
        }
1142 24988dc2 aurel32
        return;
1143 24988dc2 aurel32
    case 0xf07d: /* fsrra FRn */
1144 24988dc2 aurel32
        break;
1145 e67888a7 ths
    case 0xf08d: /* fldi0 FRn - FPSCR: R[PR] */
1146 ea6cf6be ths
        if (!(ctx->fpscr & FPSCR_PR)) {
1147 ea6cf6be ths
            gen_op_movl_imm_T0(0);
1148 ea6cf6be ths
            gen_op_fmov_T0_frN(FREG(B11_8));
1149 ea6cf6be ths
            return;
1150 ea6cf6be ths
        }
1151 ea6cf6be ths
        break;
1152 e67888a7 ths
    case 0xf09d: /* fldi1 FRn - FPSCR: R[PR] */
1153 ea6cf6be ths
        if (!(ctx->fpscr & FPSCR_PR)) {
1154 ea6cf6be ths
            gen_op_movl_imm_T0(0x3f800000);
1155 ea6cf6be ths
            gen_op_fmov_T0_frN(FREG(B11_8));
1156 ea6cf6be ths
            return;
1157 ea6cf6be ths
        }
1158 ea6cf6be ths
        break;
1159 24988dc2 aurel32
    case 0xf0ad: /* fcnvsd FPUL,DRn */
1160 24988dc2 aurel32
        gen_op_movl_fpul_FT0();
1161 24988dc2 aurel32
        gen_op_fcnvsd_FT_DT();
1162 24988dc2 aurel32
        gen_op_fmov_DT0_drN(DREG(B11_8));
1163 24988dc2 aurel32
        return;
1164 24988dc2 aurel32
    case 0xf0bd: /* fcnvds DRn,FPUL */
1165 24988dc2 aurel32
        gen_op_fmov_drN_DT0(DREG(B11_8));
1166 24988dc2 aurel32
        gen_op_fcnvds_DT_FT();
1167 24988dc2 aurel32
        gen_op_movl_FT0_fpul();
1168 24988dc2 aurel32
        return;
1169 fdf9b3e8 bellard
    }
1170 fdf9b3e8 bellard
1171 fdf9b3e8 bellard
    fprintf(stderr, "unknown instruction 0x%04x at pc 0x%08x\n",
1172 fdf9b3e8 bellard
            ctx->opcode, ctx->pc);
1173 fdf9b3e8 bellard
    gen_op_raise_illegal_instruction();
1174 823029f9 ths
    ctx->bstate = BS_EXCP;
1175 823029f9 ths
}
1176 823029f9 ths
1177 823029f9 ths
void decode_opc(DisasContext * ctx)
1178 823029f9 ths
{
1179 823029f9 ths
    uint32_t old_flags = ctx->flags;
1180 823029f9 ths
1181 823029f9 ths
    _decode_opc(ctx);
1182 823029f9 ths
1183 823029f9 ths
    if (old_flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
1184 823029f9 ths
        if (ctx->flags & DELAY_SLOT_CLEARME) {
1185 823029f9 ths
            gen_op_store_flags(0);
1186 823029f9 ths
        }
1187 823029f9 ths
        ctx->flags = 0;
1188 823029f9 ths
        ctx->bstate = BS_BRANCH;
1189 823029f9 ths
        if (old_flags & DELAY_SLOT_CONDITIONAL) {
1190 823029f9 ths
            gen_delayed_conditional_jump(ctx);
1191 823029f9 ths
        } else if (old_flags & DELAY_SLOT) {
1192 823029f9 ths
            gen_jump(ctx);
1193 823029f9 ths
        }
1194 823029f9 ths
1195 823029f9 ths
    }
1196 fdf9b3e8 bellard
}
1197 fdf9b3e8 bellard
1198 820e00f2 ths
static inline int
1199 820e00f2 ths
gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb,
1200 820e00f2 ths
                               int search_pc)
1201 fdf9b3e8 bellard
{
1202 fdf9b3e8 bellard
    DisasContext ctx;
1203 fdf9b3e8 bellard
    target_ulong pc_start;
1204 fdf9b3e8 bellard
    static uint16_t *gen_opc_end;
1205 355fb23d pbrook
    int i, ii;
1206 2e70f6ef pbrook
    int num_insns;
1207 2e70f6ef pbrook
    int max_insns;
1208 fdf9b3e8 bellard
1209 fdf9b3e8 bellard
    pc_start = tb->pc;
1210 fdf9b3e8 bellard
    gen_opc_end = gen_opc_buf + OPC_MAX_SIZE;
1211 fdf9b3e8 bellard
    ctx.pc = pc_start;
1212 823029f9 ths
    ctx.flags = (uint32_t)tb->flags;
1213 823029f9 ths
    ctx.bstate = BS_NONE;
1214 fdf9b3e8 bellard
    ctx.sr = env->sr;
1215 eda9b09b bellard
    ctx.fpscr = env->fpscr;
1216 fdf9b3e8 bellard
    ctx.memidx = (env->sr & SR_MD) ? 1 : 0;
1217 9854bc46 pbrook
    /* We don't know if the delayed pc came from a dynamic or static branch,
1218 9854bc46 pbrook
       so assume it is a dynamic branch.  */
1219 823029f9 ths
    ctx.delayed_pc = -1; /* use delayed pc from env pointer */
1220 fdf9b3e8 bellard
    ctx.tb = tb;
1221 fdf9b3e8 bellard
    ctx.singlestep_enabled = env->singlestep_enabled;
1222 fdf9b3e8 bellard
1223 fdf9b3e8 bellard
#ifdef DEBUG_DISAS
1224 fdf9b3e8 bellard
    if (loglevel & CPU_LOG_TB_CPU) {
1225 fdf9b3e8 bellard
        fprintf(logfile,
1226 fdf9b3e8 bellard
                "------------------------------------------------\n");
1227 fdf9b3e8 bellard
        cpu_dump_state(env, logfile, fprintf, 0);
1228 fdf9b3e8 bellard
    }
1229 fdf9b3e8 bellard
#endif
1230 fdf9b3e8 bellard
1231 355fb23d pbrook
    ii = -1;
1232 2e70f6ef pbrook
    num_insns = 0;
1233 2e70f6ef pbrook
    max_insns = tb->cflags & CF_COUNT_MASK;
1234 2e70f6ef pbrook
    if (max_insns == 0)
1235 2e70f6ef pbrook
        max_insns = CF_COUNT_MASK;
1236 2e70f6ef pbrook
    gen_icount_start();
1237 823029f9 ths
    while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) {
1238 fdf9b3e8 bellard
        if (env->nb_breakpoints > 0) {
1239 fdf9b3e8 bellard
            for (i = 0; i < env->nb_breakpoints; i++) {
1240 fdf9b3e8 bellard
                if (ctx.pc == env->breakpoints[i]) {
1241 fdf9b3e8 bellard
                    /* We have hit a breakpoint - make sure PC is up-to-date */
1242 fdf9b3e8 bellard
                    gen_op_movl_imm_PC(ctx.pc);
1243 fdf9b3e8 bellard
                    gen_op_debug();
1244 823029f9 ths
                    ctx.bstate = BS_EXCP;
1245 fdf9b3e8 bellard
                    break;
1246 fdf9b3e8 bellard
                }
1247 fdf9b3e8 bellard
            }
1248 fdf9b3e8 bellard
        }
1249 355fb23d pbrook
        if (search_pc) {
1250 355fb23d pbrook
            i = gen_opc_ptr - gen_opc_buf;
1251 355fb23d pbrook
            if (ii < i) {
1252 355fb23d pbrook
                ii++;
1253 355fb23d pbrook
                while (ii < i)
1254 355fb23d pbrook
                    gen_opc_instr_start[ii++] = 0;
1255 355fb23d pbrook
            }
1256 355fb23d pbrook
            gen_opc_pc[ii] = ctx.pc;
1257 823029f9 ths
            gen_opc_hflags[ii] = ctx.flags;
1258 355fb23d pbrook
            gen_opc_instr_start[ii] = 1;
1259 2e70f6ef pbrook
            gen_opc_icount[ii] = num_insns;
1260 355fb23d pbrook
        }
1261 2e70f6ef pbrook
        if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
1262 2e70f6ef pbrook
            gen_io_start();
1263 fdf9b3e8 bellard
#if 0
1264 fdf9b3e8 bellard
        fprintf(stderr, "Loading opcode at address 0x%08x\n", ctx.pc);
1265 fdf9b3e8 bellard
        fflush(stderr);
1266 fdf9b3e8 bellard
#endif
1267 fdf9b3e8 bellard
        ctx.opcode = lduw_code(ctx.pc);
1268 fdf9b3e8 bellard
        decode_opc(&ctx);
1269 2e70f6ef pbrook
        num_insns++;
1270 fdf9b3e8 bellard
        ctx.pc += 2;
1271 fdf9b3e8 bellard
        if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
1272 fdf9b3e8 bellard
            break;
1273 fdf9b3e8 bellard
        if (env->singlestep_enabled)
1274 fdf9b3e8 bellard
            break;
1275 2e70f6ef pbrook
        if (num_insns >= max_insns)
1276 2e70f6ef pbrook
            break;
1277 fdf9b3e8 bellard
#ifdef SH4_SINGLE_STEP
1278 fdf9b3e8 bellard
        break;
1279 fdf9b3e8 bellard
#endif
1280 fdf9b3e8 bellard
    }
1281 2e70f6ef pbrook
    if (tb->cflags & CF_LAST_IO)
1282 2e70f6ef pbrook
        gen_io_end();
1283 fdf9b3e8 bellard
    if (env->singlestep_enabled) {
1284 823029f9 ths
        gen_op_debug();
1285 823029f9 ths
    } else {
1286 823029f9 ths
        switch (ctx.bstate) {
1287 823029f9 ths
        case BS_STOP:
1288 823029f9 ths
            /* gen_op_interrupt_restart(); */
1289 823029f9 ths
            /* fall through */
1290 823029f9 ths
        case BS_NONE:
1291 823029f9 ths
            if (ctx.flags) {
1292 823029f9 ths
                gen_op_store_flags(ctx.flags | DELAY_SLOT_CLEARME);
1293 823029f9 ths
            }
1294 823029f9 ths
            gen_goto_tb(&ctx, 0, ctx.pc);
1295 823029f9 ths
            break;
1296 823029f9 ths
        case BS_EXCP:
1297 823029f9 ths
            /* gen_op_interrupt_restart(); */
1298 57fec1fe bellard
            tcg_gen_exit_tb(0);
1299 823029f9 ths
            break;
1300 823029f9 ths
        case BS_BRANCH:
1301 823029f9 ths
        default:
1302 823029f9 ths
            break;
1303 823029f9 ths
        }
1304 fdf9b3e8 bellard
    }
1305 823029f9 ths
1306 2e70f6ef pbrook
    gen_icount_end(tb, num_insns);
1307 fdf9b3e8 bellard
    *gen_opc_ptr = INDEX_op_end;
1308 355fb23d pbrook
    if (search_pc) {
1309 355fb23d pbrook
        i = gen_opc_ptr - gen_opc_buf;
1310 355fb23d pbrook
        ii++;
1311 355fb23d pbrook
        while (ii <= i)
1312 355fb23d pbrook
            gen_opc_instr_start[ii++] = 0;
1313 355fb23d pbrook
    } else {
1314 355fb23d pbrook
        tb->size = ctx.pc - pc_start;
1315 2e70f6ef pbrook
        tb->icount = num_insns;
1316 355fb23d pbrook
    }
1317 fdf9b3e8 bellard
1318 fdf9b3e8 bellard
#ifdef DEBUG_DISAS
1319 fdf9b3e8 bellard
#ifdef SH4_DEBUG_DISAS
1320 fdf9b3e8 bellard
    if (loglevel & CPU_LOG_TB_IN_ASM)
1321 fdf9b3e8 bellard
        fprintf(logfile, "\n");
1322 fdf9b3e8 bellard
#endif
1323 fdf9b3e8 bellard
    if (loglevel & CPU_LOG_TB_IN_ASM) {
1324 fdf9b3e8 bellard
        fprintf(logfile, "IN:\n");        /* , lookup_symbol(pc_start)); */
1325 fdf9b3e8 bellard
        target_disas(logfile, pc_start, ctx.pc - pc_start, 0);
1326 fdf9b3e8 bellard
        fprintf(logfile, "\n");
1327 fdf9b3e8 bellard
    }
1328 fdf9b3e8 bellard
#endif
1329 fdf9b3e8 bellard
    return 0;
1330 fdf9b3e8 bellard
}
1331 fdf9b3e8 bellard
1332 fdf9b3e8 bellard
int gen_intermediate_code(CPUState * env, struct TranslationBlock *tb)
1333 fdf9b3e8 bellard
{
1334 fdf9b3e8 bellard
    return gen_intermediate_code_internal(env, tb, 0);
1335 fdf9b3e8 bellard
}
1336 fdf9b3e8 bellard
1337 fdf9b3e8 bellard
int gen_intermediate_code_pc(CPUState * env, struct TranslationBlock *tb)
1338 fdf9b3e8 bellard
{
1339 fdf9b3e8 bellard
    return gen_intermediate_code_internal(env, tb, 1);
1340 fdf9b3e8 bellard
}
1341 d2856f1a aurel32
1342 d2856f1a aurel32
void gen_pc_load(CPUState *env, TranslationBlock *tb,
1343 d2856f1a aurel32
                unsigned long searched_pc, int pc_pos, void *puc)
1344 d2856f1a aurel32
{
1345 d2856f1a aurel32
    env->pc = gen_opc_pc[pc_pos];
1346 d2856f1a aurel32
    env->flags = gen_opc_hflags[pc_pos];
1347 d2856f1a aurel32
}