2006-10-22 02:18:54 +02:00
|
|
|
/*
|
|
|
|
* m68k translation
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2007-05-23 21:58:11 +02:00
|
|
|
* Copyright (c) 2005-2007 CodeSourcery
|
2006-10-22 02:18:54 +02:00
|
|
|
* Written by Paul Brook
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2019-01-29 14:43:58 +01:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2006-10-22 02:18:54 +02:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2019-01-29 14:43:58 +01:00
|
|
|
* Lesser General Public License for more details.
|
2006-10-22 02:18:54 +02:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-07-16 22:47:01 +02:00
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2006-10-22 02:18:54 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:23 +01:00
|
|
|
#include "qemu/osdep.h"
|
2006-10-22 02:18:54 +02:00
|
|
|
#include "cpu.h"
|
2012-10-24 11:12:21 +02:00
|
|
|
#include "disas/disas.h"
|
2016-03-15 13:18:37 +01:00
|
|
|
#include "exec/exec-all.h"
|
2020-01-01 12:23:00 +01:00
|
|
|
#include "tcg/tcg-op.h"
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/log.h"
|
2019-04-17 21:18:02 +02:00
|
|
|
#include "qemu/qemu-print.h"
|
2017-07-14 10:21:37 +02:00
|
|
|
#include "exec/translator.h"
|
2008-05-25 00:29:16 +02:00
|
|
|
|
2014-04-08 07:31:41 +02:00
|
|
|
#include "exec/helper-proto.h"
|
|
|
|
#include "exec/helper-gen.h"
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-07 14:55:28 +01:00
|
|
|
#include "exec/log.h"
|
2018-01-19 19:24:22 +01:00
|
|
|
#include "fpu/softfloat.h"
|
|
|
|
|
2023-03-31 19:37:04 +02:00
|
|
|
#define HELPER_H "helper.h"
|
|
|
|
#include "exec/helper-info.c.inc"
|
|
|
|
#undef HELPER_H
|
2014-05-30 14:12:25 +02:00
|
|
|
|
2007-05-23 21:58:11 +02:00
|
|
|
//#define DEBUG_DISPATCH 1
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
#define DEFO32(name, offset) static TCGv QREG_##name;
|
2008-11-17 15:43:54 +01:00
|
|
|
#define DEFO64(name, offset) static TCGv_i64 QREG_##name;
|
2022-10-26 01:50:04 +02:00
|
|
|
#include "qregs.h.inc"
|
2008-05-25 00:29:16 +02:00
|
|
|
#undef DEFO32
|
|
|
|
#undef DEFO64
|
|
|
|
|
2013-01-17 18:51:17 +01:00
|
|
|
static TCGv_i32 cpu_halted;
|
2013-08-26 08:31:06 +02:00
|
|
|
static TCGv_i32 cpu_exception_index;
|
2013-01-17 18:51:17 +01:00
|
|
|
|
2017-06-20 22:51:18 +02:00
|
|
|
static char cpu_reg_names[2 * 8 * 3 + 5 * 4];
|
2008-05-25 00:29:16 +02:00
|
|
|
static TCGv cpu_dregs[8];
|
|
|
|
static TCGv cpu_aregs[8];
|
2008-11-17 15:43:54 +01:00
|
|
|
static TCGv_i64 cpu_macc[4];
|
2008-05-25 00:29:16 +02:00
|
|
|
|
2016-11-03 21:50:01 +01:00
|
|
|
#define REG(insn, pos) (((insn) >> (pos)) & 7)
|
2015-08-09 01:23:35 +02:00
|
|
|
#define DREG(insn, pos) cpu_dregs[REG(insn, pos)]
|
2016-11-03 21:50:01 +01:00
|
|
|
#define AREG(insn, pos) get_areg(s, REG(insn, pos))
|
|
|
|
#define MACREG(acc) cpu_macc[acc]
|
|
|
|
#define QREG_SP get_areg(s, 7)
|
2008-05-25 00:29:16 +02:00
|
|
|
|
|
|
|
static TCGv NULL_QREG;
|
2017-10-20 05:27:27 +02:00
|
|
|
#define IS_NULL_QREG(t) (t == NULL_QREG)
|
2008-05-25 00:29:16 +02:00
|
|
|
/* Used to distinguish stores from bad addressing modes. */
|
|
|
|
static TCGv store_dummy;
|
|
|
|
|
|
|
|
void m68k_tcg_init(void)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
int i;
|
|
|
|
|
2013-09-18 21:53:09 +02:00
|
|
|
#define DEFO32(name, offset) \
|
2023-09-14 01:37:36 +02:00
|
|
|
QREG_##name = tcg_global_mem_new_i32(tcg_env, \
|
2013-09-18 21:53:09 +02:00
|
|
|
offsetof(CPUM68KState, offset), #name);
|
|
|
|
#define DEFO64(name, offset) \
|
2023-09-14 01:37:36 +02:00
|
|
|
QREG_##name = tcg_global_mem_new_i64(tcg_env, \
|
2013-09-18 21:53:09 +02:00
|
|
|
offsetof(CPUM68KState, offset), #name);
|
2022-10-26 01:50:04 +02:00
|
|
|
#include "qregs.h.inc"
|
2008-05-25 00:29:16 +02:00
|
|
|
#undef DEFO32
|
|
|
|
#undef DEFO64
|
|
|
|
|
2023-09-14 01:37:36 +02:00
|
|
|
cpu_halted = tcg_global_mem_new_i32(tcg_env,
|
2013-01-17 18:51:17 +01:00
|
|
|
-offsetof(M68kCPU, env) +
|
|
|
|
offsetof(CPUState, halted), "HALTED");
|
2023-09-14 01:37:36 +02:00
|
|
|
cpu_exception_index = tcg_global_mem_new_i32(tcg_env,
|
2013-08-26 08:31:06 +02:00
|
|
|
-offsetof(M68kCPU, env) +
|
|
|
|
offsetof(CPUState, exception_index),
|
|
|
|
"EXCEPTION");
|
2013-01-17 18:51:17 +01:00
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
p = cpu_reg_names;
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
sprintf(p, "D%d", i);
|
2023-09-14 01:37:36 +02:00
|
|
|
cpu_dregs[i] = tcg_global_mem_new(tcg_env,
|
2008-05-25 00:29:16 +02:00
|
|
|
offsetof(CPUM68KState, dregs[i]), p);
|
|
|
|
p += 3;
|
|
|
|
sprintf(p, "A%d", i);
|
2023-09-14 01:37:36 +02:00
|
|
|
cpu_aregs[i] = tcg_global_mem_new(tcg_env,
|
2008-05-25 00:29:16 +02:00
|
|
|
offsetof(CPUM68KState, aregs[i]), p);
|
|
|
|
p += 3;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
sprintf(p, "ACC%d", i);
|
2023-09-14 01:37:36 +02:00
|
|
|
cpu_macc[i] = tcg_global_mem_new_i64(tcg_env,
|
2008-05-25 00:29:16 +02:00
|
|
|
offsetof(CPUM68KState, macc[i]), p);
|
|
|
|
p += 5;
|
|
|
|
}
|
|
|
|
|
2023-09-14 01:37:36 +02:00
|
|
|
NULL_QREG = tcg_global_mem_new(tcg_env, -4, "NULL");
|
|
|
|
store_dummy = tcg_global_mem_new(tcg_env, -8, "NULL");
|
2008-05-25 00:29:16 +02:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
/* internal defines */
|
|
|
|
typedef struct DisasContext {
|
2018-05-12 07:02:47 +02:00
|
|
|
DisasContextBase base;
|
2007-05-26 23:16:48 +02:00
|
|
|
CPUM68KState *env;
|
2006-10-22 02:18:54 +02:00
|
|
|
target_ulong pc;
|
2022-06-02 03:33:52 +02:00
|
|
|
target_ulong pc_prev;
|
2015-08-09 01:44:24 +02:00
|
|
|
CCOp cc_op; /* Current CC operation */
|
2015-08-14 16:59:20 +02:00
|
|
|
int cc_op_synced;
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i64 mactmp;
|
|
|
|
int done_mac;
|
2016-11-03 21:50:01 +01:00
|
|
|
int writeback_mask;
|
|
|
|
TCGv writeback[8];
|
2021-05-19 16:29:17 +02:00
|
|
|
bool ss_active;
|
2006-10-22 02:18:54 +02:00
|
|
|
} DisasContext;
|
|
|
|
|
2016-11-03 21:50:01 +01:00
|
|
|
static TCGv get_areg(DisasContext *s, unsigned regno)
|
|
|
|
{
|
|
|
|
if (s->writeback_mask & (1 << regno)) {
|
|
|
|
return s->writeback[regno];
|
|
|
|
} else {
|
|
|
|
return cpu_aregs[regno];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void delay_set_areg(DisasContext *s, unsigned regno,
|
|
|
|
TCGv val, bool give_temp)
|
|
|
|
{
|
|
|
|
if (s->writeback_mask & (1 << regno)) {
|
|
|
|
if (give_temp) {
|
|
|
|
s->writeback[regno] = val;
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i32(s->writeback[regno], val);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
s->writeback_mask |= 1 << regno;
|
|
|
|
if (give_temp) {
|
|
|
|
s->writeback[regno] = val;
|
|
|
|
} else {
|
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
s->writeback[regno] = tmp;
|
|
|
|
tcg_gen_mov_i32(tmp, val);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void do_writebacks(DisasContext *s)
|
|
|
|
{
|
|
|
|
unsigned mask = s->writeback_mask;
|
|
|
|
if (mask) {
|
|
|
|
s->writeback_mask = 0;
|
|
|
|
do {
|
|
|
|
unsigned regno = ctz32(mask);
|
|
|
|
tcg_gen_mov_i32(cpu_aregs[regno], s->writeback[regno]);
|
|
|
|
mask &= mask - 1;
|
|
|
|
} while (mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-14 10:21:37 +02:00
|
|
|
/* is_jmp field values */
|
|
|
|
#define DISAS_JUMP DISAS_TARGET_0 /* only pc was modified dynamically */
|
2018-05-12 07:02:46 +02:00
|
|
|
#define DISAS_EXIT DISAS_TARGET_1 /* cpu state was modified dynamically */
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2007-05-23 21:58:11 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
|
|
|
#define IS_USER(s) 1
|
|
|
|
#else
|
2018-05-12 07:02:47 +02:00
|
|
|
#define IS_USER(s) (!(s->base.tb->flags & TB_FLAGS_MSR_S))
|
|
|
|
#define SFC_INDEX(s) ((s->base.tb->flags & TB_FLAGS_SFC_S) ? \
|
2018-01-18 20:38:44 +01:00
|
|
|
MMU_KERNEL_IDX : MMU_USER_IDX)
|
2018-05-12 07:02:47 +02:00
|
|
|
#define DFC_INDEX(s) ((s->base.tb->flags & TB_FLAGS_DFC_S) ? \
|
2018-01-18 20:38:44 +01:00
|
|
|
MMU_KERNEL_IDX : MMU_USER_IDX)
|
2007-05-23 21:58:11 +02:00
|
|
|
#endif
|
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
typedef void (*disas_proc)(CPUM68KState *env, DisasContext *s, uint16_t insn);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2007-05-23 21:58:11 +02:00
|
|
|
#ifdef DEBUG_DISPATCH
|
2012-09-08 12:48:20 +02:00
|
|
|
#define DISAS_INSN(name) \
|
|
|
|
static void real_disas_##name(CPUM68KState *env, DisasContext *s, \
|
|
|
|
uint16_t insn); \
|
|
|
|
static void disas_##name(CPUM68KState *env, DisasContext *s, \
|
|
|
|
uint16_t insn) \
|
|
|
|
{ \
|
|
|
|
qemu_log("Dispatch " #name "\n"); \
|
2015-12-06 19:01:47 +01:00
|
|
|
real_disas_##name(env, s, insn); \
|
2012-09-08 12:48:20 +02:00
|
|
|
} \
|
|
|
|
static void real_disas_##name(CPUM68KState *env, DisasContext *s, \
|
|
|
|
uint16_t insn)
|
2007-05-23 21:58:11 +02:00
|
|
|
#else
|
2012-09-08 12:48:20 +02:00
|
|
|
#define DISAS_INSN(name) \
|
|
|
|
static void disas_##name(CPUM68KState *env, DisasContext *s, \
|
|
|
|
uint16_t insn)
|
2007-05-23 21:58:11 +02:00
|
|
|
#endif
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-08-09 01:44:24 +02:00
|
|
|
static const uint8_t cc_op_live[CC_OP_NB] = {
|
2017-12-21 17:05:58 +01:00
|
|
|
[CC_OP_DYNAMIC] = CCF_C | CCF_V | CCF_Z | CCF_N | CCF_X,
|
2015-08-14 16:59:20 +02:00
|
|
|
[CC_OP_FLAGS] = CCF_C | CCF_V | CCF_Z | CCF_N | CCF_X,
|
2016-01-16 17:23:50 +01:00
|
|
|
[CC_OP_ADDB ... CC_OP_ADDL] = CCF_X | CCF_N | CCF_V,
|
|
|
|
[CC_OP_SUBB ... CC_OP_SUBL] = CCF_X | CCF_N | CCF_V,
|
|
|
|
[CC_OP_CMPB ... CC_OP_CMPL] = CCF_X | CCF_N | CCF_V,
|
2015-08-14 16:59:20 +02:00
|
|
|
[CC_OP_LOGIC] = CCF_X | CCF_N
|
2015-08-09 01:44:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void set_cc_op(DisasContext *s, CCOp op)
|
|
|
|
{
|
2015-08-14 16:59:20 +02:00
|
|
|
CCOp old_op = s->cc_op;
|
2015-08-09 01:44:24 +02:00
|
|
|
int dead;
|
|
|
|
|
2015-08-14 16:59:20 +02:00
|
|
|
if (old_op == op) {
|
2015-08-09 01:44:24 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
s->cc_op = op;
|
|
|
|
s->cc_op_synced = 0;
|
2015-08-09 01:44:24 +02:00
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Discard CC computation that will no longer be used.
|
|
|
|
* Note that X and N are never dead.
|
|
|
|
*/
|
2015-08-14 16:59:20 +02:00
|
|
|
dead = cc_op_live[old_op] & ~cc_op_live[op];
|
|
|
|
if (dead & CCF_C) {
|
|
|
|
tcg_gen_discard_i32(QREG_CC_C);
|
2015-08-09 01:44:24 +02:00
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
if (dead & CCF_Z) {
|
|
|
|
tcg_gen_discard_i32(QREG_CC_Z);
|
2015-08-09 01:44:24 +02:00
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
if (dead & CCF_V) {
|
|
|
|
tcg_gen_discard_i32(QREG_CC_V);
|
2015-08-09 01:44:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the CPU env CC_OP state. */
|
2015-08-14 16:59:20 +02:00
|
|
|
static void update_cc_op(DisasContext *s)
|
2015-08-09 01:44:24 +02:00
|
|
|
{
|
2015-08-14 16:59:20 +02:00
|
|
|
if (!s->cc_op_synced) {
|
|
|
|
s->cc_op_synced = 1;
|
2015-08-09 01:44:24 +02:00
|
|
|
tcg_gen_movi_i32(QREG_CC_OP, s->cc_op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-20 22:51:18 +02:00
|
|
|
/* Generate a jump to an immediate address. */
|
|
|
|
static void gen_jmp_im(DisasContext *s, uint32_t dest)
|
|
|
|
{
|
|
|
|
update_cc_op(s);
|
|
|
|
tcg_gen_movi_i32(QREG_PC, dest);
|
2018-05-12 07:02:47 +02:00
|
|
|
s->base.is_jmp = DISAS_JUMP;
|
2017-06-20 22:51:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a jump to the address in qreg DEST. */
|
|
|
|
static void gen_jmp(DisasContext *s, TCGv dest)
|
|
|
|
{
|
|
|
|
update_cc_op(s);
|
|
|
|
tcg_gen_mov_i32(QREG_PC, dest);
|
2018-05-12 07:02:47 +02:00
|
|
|
s->base.is_jmp = DISAS_JUMP;
|
2017-06-20 22:51:18 +02:00
|
|
|
}
|
|
|
|
|
2020-01-16 17:54:54 +01:00
|
|
|
static void gen_raise_exception(int nr)
|
2017-06-20 22:51:18 +02:00
|
|
|
{
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_raise_exception(tcg_env, tcg_constant_i32(nr));
|
2020-01-16 17:54:54 +01:00
|
|
|
}
|
|
|
|
|
2022-06-02 03:33:52 +02:00
|
|
|
static void gen_raise_exception_format2(DisasContext *s, int nr,
|
|
|
|
target_ulong this_pc)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Pass the address of the insn to the exception handler,
|
|
|
|
* for recording in the Format $2 (6-word) stack frame.
|
|
|
|
* Re-use mmu.ar for the purpose, since that's only valid
|
|
|
|
* after tlb_fill.
|
|
|
|
*/
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_st_i32(tcg_constant_i32(this_pc), tcg_env,
|
2022-06-02 03:33:52 +02:00
|
|
|
offsetof(CPUM68KState, mmu.ar));
|
|
|
|
gen_raise_exception(nr);
|
|
|
|
s->base.is_jmp = DISAS_NORETURN;
|
|
|
|
}
|
|
|
|
|
2020-01-16 17:54:54 +01:00
|
|
|
static void gen_exception(DisasContext *s, uint32_t dest, int nr)
|
|
|
|
{
|
|
|
|
update_cc_op(s);
|
|
|
|
tcg_gen_movi_i32(QREG_PC, dest);
|
|
|
|
|
|
|
|
gen_raise_exception(nr);
|
2017-06-20 22:51:18 +02:00
|
|
|
|
2018-05-12 07:02:47 +02:00
|
|
|
s->base.is_jmp = DISAS_NORETURN;
|
2017-06-20 22:51:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void gen_addr_fault(DisasContext *s)
|
|
|
|
{
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ADDRESS);
|
2017-06-20 22:51:18 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Generate a load from the specified address. Narrow values are
|
|
|
|
* sign extended to full register width.
|
|
|
|
*/
|
2018-01-18 20:38:43 +01:00
|
|
|
static inline TCGv gen_load(DisasContext *s, int opsize, TCGv addr,
|
|
|
|
int sign, int index)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2023-05-02 15:57:36 +02:00
|
|
|
TCGv tmp = tcg_temp_new_i32();
|
|
|
|
|
|
|
|
switch (opsize) {
|
2006-10-22 02:18:54 +02:00
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
|
|
|
case OS_LONG:
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_tl(tmp, addr, index,
|
|
|
|
opsize | (sign ? MO_SIGN : 0) | MO_TE);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-12 14:24:49 +01:00
|
|
|
g_assert_not_reached();
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate a store. */
|
2018-01-18 20:38:43 +01:00
|
|
|
static inline void gen_store(DisasContext *s, int opsize, TCGv addr, TCGv val,
|
|
|
|
int index)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2023-05-02 15:57:36 +02:00
|
|
|
switch (opsize) {
|
2006-10-22 02:18:54 +02:00
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
|
|
|
case OS_LONG:
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_tl(val, addr, index, opsize | MO_TE);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-12 14:24:49 +01:00
|
|
|
g_assert_not_reached();
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
typedef enum {
|
|
|
|
EA_STORE,
|
|
|
|
EA_LOADU,
|
|
|
|
EA_LOADS
|
|
|
|
} ea_what;
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Generate an unsigned load if VAL is 0 a signed load if val is -1,
|
|
|
|
* otherwise generate a store.
|
|
|
|
*/
|
2008-05-25 00:29:16 +02:00
|
|
|
static TCGv gen_ldst(DisasContext *s, int opsize, TCGv addr, TCGv val,
|
2018-01-18 20:38:43 +01:00
|
|
|
ea_what what, int index)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
if (what == EA_STORE) {
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, opsize, addr, val, index);
|
2008-05-25 00:29:16 +02:00
|
|
|
return store_dummy;
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2023-02-25 06:09:19 +01:00
|
|
|
return gen_load(s, opsize, addr, what == EA_LOADS, index);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
/* Read a 16-bit immediate constant */
|
|
|
|
static inline uint16_t read_im16(CPUM68KState *env, DisasContext *s)
|
|
|
|
{
|
|
|
|
uint16_t im;
|
2021-08-10 00:32:59 +02:00
|
|
|
im = translator_lduw(env, &s->base, s->pc);
|
2015-06-24 02:28:59 +02:00
|
|
|
s->pc += 2;
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read an 8-bit immediate constant */
|
|
|
|
static inline uint8_t read_im8(CPUM68KState *env, DisasContext *s)
|
|
|
|
{
|
|
|
|
return read_im16(env, s);
|
|
|
|
}
|
|
|
|
|
2007-05-26 23:16:48 +02:00
|
|
|
/* Read a 32-bit immediate constant. */
|
2012-09-08 12:48:20 +02:00
|
|
|
static inline uint32_t read_im32(CPUM68KState *env, DisasContext *s)
|
2007-05-26 23:16:48 +02:00
|
|
|
{
|
|
|
|
uint32_t im;
|
2015-06-24 02:28:59 +02:00
|
|
|
im = read_im16(env, s) << 16;
|
|
|
|
im |= 0xffff & read_im16(env, s);
|
2007-05-26 23:16:48 +02:00
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2017-06-20 22:51:18 +02:00
|
|
|
/* Read a 64-bit immediate constant. */
|
|
|
|
static inline uint64_t read_im64(CPUM68KState *env, DisasContext *s)
|
|
|
|
{
|
|
|
|
uint64_t im;
|
|
|
|
im = (uint64_t)read_im32(env, s) << 32;
|
|
|
|
im |= (uint64_t)read_im32(env, s);
|
|
|
|
return im;
|
|
|
|
}
|
|
|
|
|
2007-05-26 23:16:48 +02:00
|
|
|
/* Calculate and address index. */
|
2016-11-03 21:50:01 +01:00
|
|
|
static TCGv gen_addr_index(DisasContext *s, uint16_t ext, TCGv tmp)
|
2007-05-26 23:16:48 +02:00
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv add;
|
2007-05-26 23:16:48 +02:00
|
|
|
int scale;
|
|
|
|
|
|
|
|
add = (ext & 0x8000) ? AREG(ext, 12) : DREG(ext, 12);
|
|
|
|
if ((ext & 0x800) == 0) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext16s_i32(tmp, add);
|
2007-05-26 23:16:48 +02:00
|
|
|
add = tmp;
|
|
|
|
}
|
|
|
|
scale = (ext >> 9) & 3;
|
|
|
|
if (scale != 0) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_shli_i32(tmp, add, scale);
|
2007-05-26 23:16:48 +02:00
|
|
|
add = tmp;
|
|
|
|
}
|
|
|
|
return add;
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
2020-10-09 08:44:43 +02:00
|
|
|
* Handle a base + index + displacement effective address.
|
2019-06-07 01:41:25 +02:00
|
|
|
* A NULL_QREG base means pc-relative.
|
|
|
|
*/
|
2015-06-24 02:51:49 +02:00
|
|
|
static TCGv gen_lea_indexed(CPUM68KState *env, DisasContext *s, TCGv base)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
|
|
|
uint32_t offset;
|
|
|
|
uint16_t ext;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv add;
|
|
|
|
TCGv tmp;
|
2007-05-26 23:16:48 +02:00
|
|
|
uint32_t bd, od;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
offset = s->pc;
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2007-05-26 23:16:48 +02:00
|
|
|
|
|
|
|
if ((ext & 0x800) == 0 && !m68k_feature(s->env, M68K_FEATURE_WORD_INDEX))
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2007-05-26 23:16:48 +02:00
|
|
|
|
2022-09-17 13:25:12 +02:00
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_M68K) &&
|
2015-06-24 02:35:06 +02:00
|
|
|
!m68k_feature(s->env, M68K_FEATURE_SCALED_INDEX)) {
|
|
|
|
ext &= ~(3 << 9);
|
|
|
|
}
|
|
|
|
|
2007-05-26 23:16:48 +02:00
|
|
|
if (ext & 0x100) {
|
|
|
|
/* full extension word format */
|
|
|
|
if (!m68k_feature(s->env, M68K_FEATURE_EXT_FULL))
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2007-05-26 23:16:48 +02:00
|
|
|
|
|
|
|
if ((ext & 0x30) > 0x10) {
|
|
|
|
/* base displacement */
|
|
|
|
if ((ext & 0x30) == 0x20) {
|
2015-06-24 02:28:59 +02:00
|
|
|
bd = (int16_t)read_im16(env, s);
|
2007-05-26 23:16:48 +02:00
|
|
|
} else {
|
2012-09-08 12:48:20 +02:00
|
|
|
bd = read_im32(env, s);
|
2007-05-26 23:16:48 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bd = 0;
|
|
|
|
}
|
2023-02-25 06:09:19 +01:00
|
|
|
tmp = tcg_temp_new();
|
2007-05-26 23:16:48 +02:00
|
|
|
if ((ext & 0x44) == 0) {
|
|
|
|
/* pre-index */
|
2016-11-03 21:50:01 +01:00
|
|
|
add = gen_addr_index(s, ext, tmp);
|
2007-05-26 23:16:48 +02:00
|
|
|
} else {
|
2008-05-25 00:29:16 +02:00
|
|
|
add = NULL_QREG;
|
2007-05-26 23:16:48 +02:00
|
|
|
}
|
|
|
|
if ((ext & 0x80) == 0) {
|
|
|
|
/* base not suppressed */
|
2008-05-25 00:29:16 +02:00
|
|
|
if (IS_NULL_QREG(base)) {
|
2023-02-26 02:39:06 +01:00
|
|
|
base = tcg_constant_i32(offset + bd);
|
2007-05-26 23:16:48 +02:00
|
|
|
bd = 0;
|
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
if (!IS_NULL_QREG(add)) {
|
|
|
|
tcg_gen_add_i32(tmp, add, base);
|
2007-05-26 23:16:48 +02:00
|
|
|
add = tmp;
|
|
|
|
} else {
|
|
|
|
add = base;
|
|
|
|
}
|
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
if (!IS_NULL_QREG(add)) {
|
2007-05-26 23:16:48 +02:00
|
|
|
if (bd != 0) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(tmp, add, bd);
|
2007-05-26 23:16:48 +02:00
|
|
|
add = tmp;
|
|
|
|
}
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
add = tcg_constant_i32(bd);
|
2007-05-26 23:16:48 +02:00
|
|
|
}
|
|
|
|
if ((ext & 3) != 0) {
|
|
|
|
/* memory indirect */
|
2023-02-25 06:09:19 +01:00
|
|
|
base = gen_load(s, OS_LONG, add, 0, IS_USER(s));
|
2007-05-26 23:16:48 +02:00
|
|
|
if ((ext & 0x44) == 4) {
|
2016-11-03 21:50:01 +01:00
|
|
|
add = gen_addr_index(s, ext, tmp);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_add_i32(tmp, add, base);
|
2007-05-26 23:16:48 +02:00
|
|
|
add = tmp;
|
|
|
|
} else {
|
|
|
|
add = base;
|
|
|
|
}
|
|
|
|
if ((ext & 3) > 1) {
|
|
|
|
/* outer displacement */
|
|
|
|
if ((ext & 3) == 2) {
|
2015-06-24 02:28:59 +02:00
|
|
|
od = (int16_t)read_im16(env, s);
|
2007-05-26 23:16:48 +02:00
|
|
|
} else {
|
2012-09-08 12:48:20 +02:00
|
|
|
od = read_im32(env, s);
|
2007-05-26 23:16:48 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
od = 0;
|
|
|
|
}
|
|
|
|
if (od != 0) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(tmp, add, od);
|
2007-05-26 23:16:48 +02:00
|
|
|
add = tmp;
|
|
|
|
}
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2007-05-26 23:16:48 +02:00
|
|
|
/* brief extension word format */
|
2023-02-25 06:09:19 +01:00
|
|
|
tmp = tcg_temp_new();
|
2016-11-03 21:50:01 +01:00
|
|
|
add = gen_addr_index(s, ext, tmp);
|
2008-05-25 00:29:16 +02:00
|
|
|
if (!IS_NULL_QREG(base)) {
|
|
|
|
tcg_gen_add_i32(tmp, add, base);
|
2007-05-26 23:16:48 +02:00
|
|
|
if ((int8_t)ext)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(tmp, tmp, (int8_t)ext);
|
2007-05-26 23:16:48 +02:00
|
|
|
} else {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(tmp, add, offset + (int8_t)ext);
|
2007-05-26 23:16:48 +02:00
|
|
|
}
|
|
|
|
add = tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2007-05-26 23:16:48 +02:00
|
|
|
return add;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-16 17:23:50 +01:00
|
|
|
/* Sign or zero extend a value. */
|
|
|
|
|
|
|
|
static inline void gen_ext(TCGv res, TCGv val, int opsize, int sign)
|
|
|
|
{
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
|
|
|
case OS_LONG:
|
2023-10-19 20:20:12 +02:00
|
|
|
tcg_gen_ext_i32(res, val, opsize | (sign ? MO_SIGN : 0));
|
2016-01-16 17:23:50 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
/* Evaluate all the CC flags. */
|
2015-08-09 01:44:24 +02:00
|
|
|
|
2015-08-14 16:59:20 +02:00
|
|
|
static void gen_flush_flags(DisasContext *s)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2015-08-14 16:59:24 +02:00
|
|
|
TCGv t0, t1;
|
2015-08-14 16:59:20 +02:00
|
|
|
|
|
|
|
switch (s->cc_op) {
|
|
|
|
case CC_OP_FLAGS:
|
2006-10-22 02:18:54 +02:00
|
|
|
return;
|
2015-08-14 16:59:24 +02:00
|
|
|
|
2016-01-16 17:23:50 +01:00
|
|
|
case CC_OP_ADDB:
|
|
|
|
case CC_OP_ADDW:
|
|
|
|
case CC_OP_ADDL:
|
2015-08-14 16:59:24 +02:00
|
|
|
tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
/* Compute signed overflow for addition. */
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_sub_i32(t0, QREG_CC_N, QREG_CC_V);
|
2016-01-16 17:23:50 +01:00
|
|
|
gen_ext(t0, t0, s->cc_op - CC_OP_ADDB, 1);
|
2015-08-14 16:59:24 +02:00
|
|
|
tcg_gen_xor_i32(t1, QREG_CC_N, QREG_CC_V);
|
|
|
|
tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, t0);
|
|
|
|
tcg_gen_andc_i32(QREG_CC_V, t1, QREG_CC_V);
|
|
|
|
break;
|
|
|
|
|
2016-01-16 17:23:50 +01:00
|
|
|
case CC_OP_SUBB:
|
|
|
|
case CC_OP_SUBW:
|
|
|
|
case CC_OP_SUBL:
|
2015-08-14 16:59:24 +02:00
|
|
|
tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
/* Compute signed overflow for subtraction. */
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_add_i32(t0, QREG_CC_N, QREG_CC_V);
|
2016-01-16 17:23:50 +01:00
|
|
|
gen_ext(t0, t0, s->cc_op - CC_OP_SUBB, 1);
|
2017-06-14 22:39:05 +02:00
|
|
|
tcg_gen_xor_i32(t1, QREG_CC_N, t0);
|
2015-08-14 16:59:24 +02:00
|
|
|
tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, t0);
|
|
|
|
tcg_gen_and_i32(QREG_CC_V, QREG_CC_V, t1);
|
|
|
|
break;
|
|
|
|
|
2016-01-16 17:23:50 +01:00
|
|
|
case CC_OP_CMPB:
|
|
|
|
case CC_OP_CMPW:
|
|
|
|
case CC_OP_CMPL:
|
2015-08-14 16:59:24 +02:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_C, QREG_CC_N, QREG_CC_V);
|
|
|
|
tcg_gen_sub_i32(QREG_CC_Z, QREG_CC_N, QREG_CC_V);
|
2016-01-16 17:23:50 +01:00
|
|
|
gen_ext(QREG_CC_Z, QREG_CC_Z, s->cc_op - CC_OP_CMPB, 1);
|
2015-08-14 16:59:24 +02:00
|
|
|
/* Compute signed overflow for subtraction. */
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(t0, QREG_CC_Z, QREG_CC_N);
|
|
|
|
tcg_gen_xor_i32(QREG_CC_V, QREG_CC_V, QREG_CC_N);
|
|
|
|
tcg_gen_and_i32(QREG_CC_V, QREG_CC_V, t0);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_N, QREG_CC_Z);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CC_OP_LOGIC:
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_C, 0);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0);
|
|
|
|
break;
|
|
|
|
|
2015-08-14 16:59:20 +02:00
|
|
|
case CC_OP_DYNAMIC:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_flush_flags(tcg_env, QREG_CC_OP);
|
2017-01-13 19:36:30 +01:00
|
|
|
s->cc_op_synced = 1;
|
2015-08-14 16:59:20 +02:00
|
|
|
break;
|
2015-08-14 16:59:24 +02:00
|
|
|
|
2015-08-14 16:59:20 +02:00
|
|
|
default:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_flush_flags(tcg_env, tcg_constant_i32(s->cc_op));
|
2017-01-13 19:36:30 +01:00
|
|
|
s->cc_op_synced = 1;
|
2015-08-14 16:59:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Note that flush_flags also assigned to env->cc_op. */
|
|
|
|
s->cc_op = CC_OP_FLAGS;
|
|
|
|
}
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
static inline TCGv gen_extend(DisasContext *s, TCGv val, int opsize, int sign)
|
2015-08-14 16:59:20 +02:00
|
|
|
{
|
|
|
|
TCGv tmp;
|
|
|
|
|
|
|
|
if (opsize == OS_LONG) {
|
|
|
|
tmp = val;
|
|
|
|
} else {
|
2023-02-25 06:09:19 +01:00
|
|
|
tmp = tcg_temp_new();
|
2015-08-14 16:59:20 +02:00
|
|
|
gen_ext(tmp, val, opsize, sign);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
2015-08-09 02:41:40 +02:00
|
|
|
|
|
|
|
static void gen_logic_cc(DisasContext *s, TCGv val, int opsize)
|
2008-05-25 00:29:16 +02:00
|
|
|
{
|
2015-08-14 16:59:20 +02:00
|
|
|
gen_ext(QREG_CC_N, val, opsize, 1);
|
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
2008-05-25 00:29:16 +02:00
|
|
|
}
|
|
|
|
|
2016-01-17 14:34:09 +01:00
|
|
|
static void gen_update_cc_cmp(DisasContext *s, TCGv dest, TCGv src, int opsize)
|
|
|
|
{
|
|
|
|
tcg_gen_mov_i32(QREG_CC_N, dest);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_V, src);
|
|
|
|
set_cc_op(s, CC_OP_CMPB + opsize);
|
|
|
|
}
|
|
|
|
|
2016-01-16 17:23:50 +01:00
|
|
|
static void gen_update_cc_add(TCGv dest, TCGv src, int opsize)
|
2008-05-25 00:29:16 +02:00
|
|
|
{
|
2016-01-16 17:23:50 +01:00
|
|
|
gen_ext(QREG_CC_N, dest, opsize, 1);
|
2015-08-14 16:59:20 +02:00
|
|
|
tcg_gen_mov_i32(QREG_CC_V, src);
|
2008-05-25 00:29:16 +02:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
static inline int opsize_bytes(int opsize)
|
|
|
|
{
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE: return 1;
|
|
|
|
case OS_WORD: return 2;
|
|
|
|
case OS_LONG: return 4;
|
|
|
|
case OS_SINGLE: return 4;
|
|
|
|
case OS_DOUBLE: return 8;
|
2015-08-09 01:12:46 +02:00
|
|
|
case OS_EXTENDED: return 12;
|
|
|
|
case OS_PACKED: return 12;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int insn_opsize(int insn)
|
|
|
|
{
|
|
|
|
switch ((insn >> 6) & 3) {
|
|
|
|
case 0: return OS_BYTE;
|
|
|
|
case 1: return OS_WORD;
|
|
|
|
case 2: return OS_LONG;
|
2006-10-22 02:18:54 +02:00
|
|
|
default:
|
2014-03-12 14:24:49 +01:00
|
|
|
g_assert_not_reached();
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 01:16:29 +02:00
|
|
|
static inline int ext_opsize(int ext, int pos)
|
|
|
|
{
|
|
|
|
switch ((ext >> pos) & 7) {
|
|
|
|
case 0: return OS_LONG;
|
|
|
|
case 1: return OS_SINGLE;
|
|
|
|
case 2: return OS_EXTENDED;
|
|
|
|
case 3: return OS_PACKED;
|
|
|
|
case 4: return OS_WORD;
|
|
|
|
case 5: return OS_DOUBLE;
|
|
|
|
case 6: return OS_BYTE;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Assign value to a register. If the width is less than the register width
|
|
|
|
* only the low part of the register is set.
|
|
|
|
*/
|
2008-05-25 00:29:16 +02:00
|
|
|
static void gen_partset_reg(int opsize, TCGv reg, TCGv val)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
2023-08-06 02:36:02 +02:00
|
|
|
tcg_gen_deposit_i32(reg, reg, val, 0, 8);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case OS_WORD:
|
2023-08-06 02:36:02 +02:00
|
|
|
tcg_gen_deposit_i32(reg, reg, val, 0, 16);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case OS_LONG:
|
|
|
|
case OS_SINGLE:
|
2008-11-17 15:43:54 +01:00
|
|
|
tcg_gen_mov_i32(reg, val);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-12 14:24:49 +01:00
|
|
|
g_assert_not_reached();
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Generate code for an "effective address". Does not adjust the base
|
|
|
|
* register for autoincrement addressing modes.
|
|
|
|
*/
|
2016-11-03 21:50:02 +01:00
|
|
|
static TCGv gen_lea_mode(CPUM68KState *env, DisasContext *s,
|
|
|
|
int mode, int reg0, int opsize)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
uint16_t ext;
|
|
|
|
uint32_t offset;
|
|
|
|
|
2016-11-03 21:50:02 +01:00
|
|
|
switch (mode) {
|
2006-10-22 02:18:54 +02:00
|
|
|
case 0: /* Data register direct. */
|
|
|
|
case 1: /* Address register direct. */
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 3: /* Indirect postincrement. */
|
2016-11-09 14:46:11 +01:00
|
|
|
if (opsize == OS_UNSIZED) {
|
|
|
|
return NULL_QREG;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
case 2: /* Indirect register */
|
2016-11-03 21:50:02 +01:00
|
|
|
return get_areg(s, reg0);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 4: /* Indirect predecrememnt. */
|
2016-11-09 14:46:11 +01:00
|
|
|
if (opsize == OS_UNSIZED) {
|
|
|
|
return NULL_QREG;
|
|
|
|
}
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = get_areg(s, reg0);
|
2023-02-25 06:09:19 +01:00
|
|
|
tmp = tcg_temp_new();
|
2017-01-13 19:36:33 +01:00
|
|
|
if (reg0 == 7 && opsize == OS_BYTE &&
|
2022-09-17 13:25:12 +02:00
|
|
|
m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2017-01-13 19:36:33 +01:00
|
|
|
tcg_gen_subi_i32(tmp, reg, 2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_subi_i32(tmp, reg, opsize_bytes(opsize));
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
return tmp;
|
|
|
|
case 5: /* Indirect displacement. */
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = get_areg(s, reg0);
|
2023-02-25 06:09:19 +01:00
|
|
|
tmp = tcg_temp_new();
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(tmp, reg, (int16_t)ext);
|
2006-10-22 02:18:54 +02:00
|
|
|
return tmp;
|
|
|
|
case 6: /* Indirect index + displacement. */
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = get_areg(s, reg0);
|
2015-06-24 02:51:49 +02:00
|
|
|
return gen_lea_indexed(env, s, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 7: /* Other */
|
2016-11-03 21:50:02 +01:00
|
|
|
switch (reg0) {
|
2006-10-22 02:18:54 +02:00
|
|
|
case 0: /* Absolute short. */
|
2015-06-24 02:28:59 +02:00
|
|
|
offset = (int16_t)read_im16(env, s);
|
2023-02-26 02:39:06 +01:00
|
|
|
return tcg_constant_i32(offset);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 1: /* Absolute long. */
|
2012-09-08 12:48:20 +02:00
|
|
|
offset = read_im32(env, s);
|
2023-02-26 02:39:06 +01:00
|
|
|
return tcg_constant_i32(offset);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 2: /* pc displacement */
|
|
|
|
offset = s->pc;
|
2015-06-24 02:28:59 +02:00
|
|
|
offset += (int16_t)read_im16(env, s);
|
2023-02-26 02:39:06 +01:00
|
|
|
return tcg_constant_i32(offset);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 3: /* pc index+displacement. */
|
2015-06-24 02:51:49 +02:00
|
|
|
return gen_lea_indexed(env, s, NULL_QREG);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 4: /* Immediate. */
|
|
|
|
default:
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Should never happen. */
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-11-03 21:50:02 +01:00
|
|
|
static TCGv gen_lea(CPUM68KState *env, DisasContext *s, uint16_t insn,
|
|
|
|
int opsize)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2016-11-03 21:50:02 +01:00
|
|
|
int mode = extract32(insn, 3, 3);
|
|
|
|
int reg0 = REG(insn, 0);
|
|
|
|
return gen_lea_mode(env, s, mode, reg0, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Generate code to load/store a value from/into an EA. If WHAT > 0 this is
|
|
|
|
* a write otherwise it is a read (0 == sign extend, -1 == zero extend).
|
|
|
|
* ADDRP is non-null for readwrite operands.
|
|
|
|
*/
|
2016-11-03 21:50:02 +01:00
|
|
|
static TCGv gen_ea_mode(CPUM68KState *env, DisasContext *s, int mode, int reg0,
|
2018-01-18 20:38:43 +01:00
|
|
|
int opsize, TCGv val, TCGv *addrp, ea_what what,
|
|
|
|
int index)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2016-11-03 21:50:02 +01:00
|
|
|
TCGv reg, tmp, result;
|
|
|
|
int32_t offset;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-11-03 21:50:02 +01:00
|
|
|
switch (mode) {
|
2006-10-22 02:18:54 +02:00
|
|
|
case 0: /* Data register direct. */
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = cpu_dregs[reg0];
|
2008-05-25 00:29:16 +02:00
|
|
|
if (what == EA_STORE) {
|
2006-10-22 02:18:54 +02:00
|
|
|
gen_partset_reg(opsize, reg, val);
|
2008-05-25 00:29:16 +02:00
|
|
|
return store_dummy;
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2018-03-19 12:35:43 +01:00
|
|
|
return gen_extend(s, reg, opsize, what == EA_LOADS);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
case 1: /* Address register direct. */
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = get_areg(s, reg0);
|
2008-05-25 00:29:16 +02:00
|
|
|
if (what == EA_STORE) {
|
|
|
|
tcg_gen_mov_i32(reg, val);
|
|
|
|
return store_dummy;
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2018-03-19 12:35:43 +01:00
|
|
|
return gen_extend(s, reg, opsize, what == EA_LOADS);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
case 2: /* Indirect register */
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = get_areg(s, reg0);
|
2018-01-18 20:38:43 +01:00
|
|
|
return gen_ldst(s, opsize, reg, val, what, index);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 3: /* Indirect postincrement. */
|
2016-11-03 21:50:02 +01:00
|
|
|
reg = get_areg(s, reg0);
|
2018-01-18 20:38:43 +01:00
|
|
|
result = gen_ldst(s, opsize, reg, val, what, index);
|
2016-11-03 21:50:01 +01:00
|
|
|
if (what == EA_STORE || !addrp) {
|
2023-09-04 18:12:17 +02:00
|
|
|
tmp = tcg_temp_new();
|
2017-01-13 19:36:33 +01:00
|
|
|
if (reg0 == 7 && opsize == OS_BYTE &&
|
2022-09-17 13:25:12 +02:00
|
|
|
m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2017-01-13 19:36:33 +01:00
|
|
|
tcg_gen_addi_i32(tmp, reg, 2);
|
|
|
|
} else {
|
|
|
|
tcg_gen_addi_i32(tmp, reg, opsize_bytes(opsize));
|
|
|
|
}
|
2016-11-03 21:50:02 +01:00
|
|
|
delay_set_areg(s, reg0, tmp, true);
|
2016-11-03 21:50:01 +01:00
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
return result;
|
|
|
|
case 4: /* Indirect predecrememnt. */
|
2016-11-03 21:50:02 +01:00
|
|
|
if (addrp && what == EA_STORE) {
|
|
|
|
tmp = *addrp;
|
|
|
|
} else {
|
|
|
|
tmp = gen_lea_mode(env, s, mode, reg0, opsize);
|
|
|
|
if (IS_NULL_QREG(tmp)) {
|
|
|
|
return tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-11-03 21:50:02 +01:00
|
|
|
if (addrp) {
|
|
|
|
*addrp = tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
2018-01-18 20:38:43 +01:00
|
|
|
result = gen_ldst(s, opsize, tmp, val, what, index);
|
2016-11-03 21:50:02 +01:00
|
|
|
if (what == EA_STORE || !addrp) {
|
|
|
|
delay_set_areg(s, reg0, tmp, false);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
return result;
|
|
|
|
case 5: /* Indirect displacement. */
|
|
|
|
case 6: /* Indirect index + displacement. */
|
2016-11-03 21:50:02 +01:00
|
|
|
do_indirect:
|
|
|
|
if (addrp && what == EA_STORE) {
|
|
|
|
tmp = *addrp;
|
|
|
|
} else {
|
|
|
|
tmp = gen_lea_mode(env, s, mode, reg0, opsize);
|
|
|
|
if (IS_NULL_QREG(tmp)) {
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
if (addrp) {
|
|
|
|
*addrp = tmp;
|
|
|
|
}
|
|
|
|
}
|
2018-01-18 20:38:43 +01:00
|
|
|
return gen_ldst(s, opsize, tmp, val, what, index);
|
2006-10-22 02:18:54 +02:00
|
|
|
case 7: /* Other */
|
2016-11-03 21:50:02 +01:00
|
|
|
switch (reg0) {
|
2006-10-22 02:18:54 +02:00
|
|
|
case 0: /* Absolute short. */
|
|
|
|
case 1: /* Absolute long. */
|
|
|
|
case 2: /* pc displacement */
|
|
|
|
case 3: /* pc index+displacement. */
|
2016-11-03 21:50:02 +01:00
|
|
|
goto do_indirect;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 4: /* Immediate. */
|
|
|
|
/* Sign extend values for consistency. */
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
2012-09-02 09:27:38 +02:00
|
|
|
if (what == EA_LOADS) {
|
2015-06-24 02:28:59 +02:00
|
|
|
offset = (int8_t)read_im8(env, s);
|
2012-09-02 09:27:38 +02:00
|
|
|
} else {
|
2015-06-24 02:28:59 +02:00
|
|
|
offset = read_im8(env, s);
|
2012-09-02 09:27:38 +02:00
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case OS_WORD:
|
2012-09-02 09:27:38 +02:00
|
|
|
if (what == EA_LOADS) {
|
2015-06-24 02:28:59 +02:00
|
|
|
offset = (int16_t)read_im16(env, s);
|
2012-09-02 09:27:38 +02:00
|
|
|
} else {
|
2015-06-24 02:28:59 +02:00
|
|
|
offset = read_im16(env, s);
|
2012-09-02 09:27:38 +02:00
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case OS_LONG:
|
2012-09-08 12:48:20 +02:00
|
|
|
offset = read_im32(env, s);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-03-12 14:24:49 +01:00
|
|
|
g_assert_not_reached();
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2023-02-26 01:12:24 +01:00
|
|
|
return tcg_constant_i32(offset);
|
2006-10-22 02:18:54 +02:00
|
|
|
default:
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Should never happen. */
|
2008-05-25 00:29:16 +02:00
|
|
|
return NULL_QREG;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-11-03 21:50:02 +01:00
|
|
|
static TCGv gen_ea(CPUM68KState *env, DisasContext *s, uint16_t insn,
|
2018-01-18 20:38:43 +01:00
|
|
|
int opsize, TCGv val, TCGv *addrp, ea_what what, int index)
|
2016-11-03 21:50:02 +01:00
|
|
|
{
|
|
|
|
int mode = extract32(insn, 3, 3);
|
|
|
|
int reg0 = REG(insn, 0);
|
2018-01-18 20:38:43 +01:00
|
|
|
return gen_ea_mode(env, s, mode, reg0, opsize, val, addrp, what, index);
|
2016-11-03 21:50:02 +01:00
|
|
|
}
|
|
|
|
|
2017-06-20 22:51:18 +02:00
|
|
|
static TCGv_ptr gen_fp_ptr(int freg)
|
|
|
|
{
|
|
|
|
TCGv_ptr fp = tcg_temp_new_ptr();
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_addi_ptr(fp, tcg_env, offsetof(CPUM68KState, fregs[freg]));
|
2017-06-20 22:51:18 +02:00
|
|
|
return fp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static TCGv_ptr gen_fp_result_ptr(void)
|
|
|
|
{
|
|
|
|
TCGv_ptr fp = tcg_temp_new_ptr();
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_addi_ptr(fp, tcg_env, offsetof(CPUM68KState, fp_result));
|
2017-06-20 22:51:18 +02:00
|
|
|
return fp;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fp_move(TCGv_ptr dest, TCGv_ptr src)
|
|
|
|
{
|
|
|
|
TCGv t32;
|
|
|
|
TCGv_i64 t64;
|
|
|
|
|
|
|
|
t32 = tcg_temp_new();
|
|
|
|
tcg_gen_ld16u_i32(t32, src, offsetof(FPReg, l.upper));
|
|
|
|
tcg_gen_st16_i32(t32, dest, offsetof(FPReg, l.upper));
|
|
|
|
|
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_ld_i64(t64, src, offsetof(FPReg, l.lower));
|
|
|
|
tcg_gen_st_i64(t64, dest, offsetof(FPReg, l.lower));
|
|
|
|
}
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
static void gen_load_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp,
|
|
|
|
int index)
|
2017-06-20 22:51:18 +02:00
|
|
|
{
|
|
|
|
TCGv tmp;
|
|
|
|
TCGv_i64 t64;
|
|
|
|
|
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
2023-05-08 16:07:47 +02:00
|
|
|
case OS_LONG:
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_tl(tmp, addr, index, opsize | MO_SIGN | MO_TE);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_exts32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_SINGLE:
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_tl(tmp, addr, index, MO_TEUL);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_extf32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_DOUBLE:
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t64, addr, index, MO_TEUQ);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_extf64(tcg_env, fp, t64);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_EXTENDED:
|
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_i32(tmp, addr, index, MO_TEUL);
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_shri_i32(tmp, tmp, 16);
|
|
|
|
tcg_gen_st16_i32(tmp, fp, offsetof(FPReg, l.upper));
|
|
|
|
tcg_gen_addi_i32(tmp, addr, 4);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t64, tmp, index, MO_TEUQ);
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower));
|
|
|
|
break;
|
|
|
|
case OS_PACKED:
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* unimplemented data type on 68040/ColdFire
|
2017-06-20 22:51:18 +02:00
|
|
|
* FIXME if needed for another FPU
|
|
|
|
*/
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
static void gen_store_fp(DisasContext *s, int opsize, TCGv addr, TCGv_ptr fp,
|
|
|
|
int index)
|
2017-06-20 22:51:18 +02:00
|
|
|
{
|
|
|
|
TCGv tmp;
|
|
|
|
TCGv_i64 t64;
|
|
|
|
|
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
|
|
|
case OS_LONG:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_reds32(tmp, tcg_env, fp);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_tl(tmp, addr, index, opsize | MO_TE);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_SINGLE:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_redf32(tmp, tcg_env, fp);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_tl(tmp, addr, index, MO_TEUL);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_DOUBLE:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_redf64(t64, tcg_env, fp);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_i64(t64, addr, index, MO_TEUQ);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_EXTENDED:
|
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
tcg_gen_ld16u_i32(tmp, fp, offsetof(FPReg, l.upper));
|
|
|
|
tcg_gen_shli_i32(tmp, tmp, 16);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_i32(tmp, addr, index, MO_TEUL);
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_addi_i32(tmp, addr, 4);
|
|
|
|
tcg_gen_ld_i64(t64, fp, offsetof(FPReg, l.lower));
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_i64(t64, tmp, index, MO_TEUQ);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_PACKED:
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* unimplemented data type on 68040/ColdFire
|
2017-06-20 22:51:18 +02:00
|
|
|
* FIXME if needed for another FPU
|
|
|
|
*/
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_ldst_fp(DisasContext *s, int opsize, TCGv addr,
|
2018-01-18 20:38:43 +01:00
|
|
|
TCGv_ptr fp, ea_what what, int index)
|
2017-06-20 22:51:18 +02:00
|
|
|
{
|
|
|
|
if (what == EA_STORE) {
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store_fp(s, opsize, addr, fp, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
} else {
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_load_fp(s, opsize, addr, fp, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gen_ea_mode_fp(CPUM68KState *env, DisasContext *s, int mode,
|
2018-01-18 20:38:43 +01:00
|
|
|
int reg0, int opsize, TCGv_ptr fp, ea_what what,
|
|
|
|
int index)
|
2017-06-20 22:51:18 +02:00
|
|
|
{
|
|
|
|
TCGv reg, addr, tmp;
|
|
|
|
TCGv_i64 t64;
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0: /* Data register direct. */
|
|
|
|
reg = cpu_dregs[reg0];
|
|
|
|
if (what == EA_STORE) {
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
|
|
|
case OS_LONG:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_reds32(reg, tcg_env, fp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_SINGLE:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_redf32(reg, tcg_env, fp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
|
|
|
case OS_WORD:
|
|
|
|
case OS_LONG:
|
2023-10-19 20:20:12 +02:00
|
|
|
tcg_gen_ext_i32(tmp, reg, opsize | MO_SIGN);
|
|
|
|
gen_helper_exts32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_SINGLE:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_extf32(tcg_env, fp, reg);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case 1: /* Address register direct. */
|
|
|
|
return -1;
|
|
|
|
case 2: /* Indirect register */
|
|
|
|
addr = get_areg(s, reg0);
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_ldst_fp(s, opsize, addr, fp, what, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
return 0;
|
|
|
|
case 3: /* Indirect postincrement. */
|
|
|
|
addr = cpu_aregs[reg0];
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_ldst_fp(s, opsize, addr, fp, what, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_addi_i32(addr, addr, opsize_bytes(opsize));
|
|
|
|
return 0;
|
|
|
|
case 4: /* Indirect predecrememnt. */
|
|
|
|
addr = gen_lea_mode(env, s, mode, reg0, opsize);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_ldst_fp(s, opsize, addr, fp, what, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_mov_i32(cpu_aregs[reg0], addr);
|
|
|
|
return 0;
|
|
|
|
case 5: /* Indirect displacement. */
|
|
|
|
case 6: /* Indirect index + displacement. */
|
|
|
|
do_indirect:
|
|
|
|
addr = gen_lea_mode(env, s, mode, reg0, opsize);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
return -1;
|
|
|
|
}
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_ldst_fp(s, opsize, addr, fp, what, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
return 0;
|
|
|
|
case 7: /* Other */
|
|
|
|
switch (reg0) {
|
|
|
|
case 0: /* Absolute short. */
|
|
|
|
case 1: /* Absolute long. */
|
|
|
|
case 2: /* pc displacement */
|
|
|
|
case 3: /* pc index+displacement. */
|
|
|
|
goto do_indirect;
|
|
|
|
case 4: /* Immediate. */
|
|
|
|
if (what == EA_STORE) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
2023-02-26 02:39:06 +01:00
|
|
|
tmp = tcg_constant_i32((int8_t)read_im8(env, s));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_exts32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_WORD:
|
2023-02-26 02:39:06 +01:00
|
|
|
tmp = tcg_constant_i32((int16_t)read_im16(env, s));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_exts32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_LONG:
|
2023-02-26 02:39:06 +01:00
|
|
|
tmp = tcg_constant_i32(read_im32(env, s));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_exts32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_SINGLE:
|
2023-02-26 02:39:06 +01:00
|
|
|
tmp = tcg_constant_i32(read_im32(env, s));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_extf32(tcg_env, fp, tmp);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_DOUBLE:
|
2023-02-26 02:39:06 +01:00
|
|
|
t64 = tcg_constant_i64(read_im64(env, s));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_extf64(tcg_env, fp, t64);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
case OS_EXTENDED:
|
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_CF_FPU)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-02-26 02:39:06 +01:00
|
|
|
tmp = tcg_constant_i32(read_im32(env, s) >> 16);
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_st16_i32(tmp, fp, offsetof(FPReg, l.upper));
|
2023-02-26 02:39:06 +01:00
|
|
|
t64 = tcg_constant_i64(read_im64(env, s));
|
2017-06-20 22:51:18 +02:00
|
|
|
tcg_gen_st_i64(t64, fp, offsetof(FPReg, l.lower));
|
|
|
|
break;
|
|
|
|
case OS_PACKED:
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* unimplemented data type on 68040/ColdFire
|
2017-06-20 22:51:18 +02:00
|
|
|
* FIXME if needed for another FPU
|
|
|
|
*/
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_FP_UNIMP);
|
2017-06-20 22:51:18 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int gen_ea_fp(CPUM68KState *env, DisasContext *s, uint16_t insn,
|
2018-01-18 20:38:43 +01:00
|
|
|
int opsize, TCGv_ptr fp, ea_what what, int index)
|
2017-06-20 22:51:18 +02:00
|
|
|
{
|
|
|
|
int mode = extract32(insn, 3, 3);
|
|
|
|
int reg0 = REG(insn, 0);
|
2018-01-18 20:38:43 +01:00
|
|
|
return gen_ea_mode_fp(env, s, mode, reg0, opsize, fp, what, index);
|
2017-06-20 22:51:18 +02:00
|
|
|
}
|
|
|
|
|
2015-08-14 16:59:21 +02:00
|
|
|
typedef struct {
|
|
|
|
TCGCond tcond;
|
|
|
|
TCGv v1;
|
|
|
|
TCGv v2;
|
|
|
|
} DisasCompare;
|
|
|
|
|
|
|
|
static void gen_cc_cond(DisasCompare *c, DisasContext *s, int cond)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2015-08-14 16:59:20 +02:00
|
|
|
TCGv tmp, tmp2;
|
|
|
|
TCGCond tcond;
|
2015-08-14 16:59:23 +02:00
|
|
|
CCOp op = s->cc_op;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-08-14 16:59:23 +02:00
|
|
|
/* The CC_OP_CMP form can handle most normal comparisons directly. */
|
2016-01-16 17:23:50 +01:00
|
|
|
if (op == CC_OP_CMPB || op == CC_OP_CMPW || op == CC_OP_CMPL) {
|
2015-08-14 16:59:23 +02:00
|
|
|
c->v1 = QREG_CC_N;
|
|
|
|
c->v2 = QREG_CC_V;
|
|
|
|
switch (cond) {
|
|
|
|
case 2: /* HI */
|
|
|
|
case 3: /* LS */
|
|
|
|
tcond = TCG_COND_LEU;
|
|
|
|
goto done;
|
|
|
|
case 4: /* CC */
|
|
|
|
case 5: /* CS */
|
|
|
|
tcond = TCG_COND_LTU;
|
|
|
|
goto done;
|
|
|
|
case 6: /* NE */
|
|
|
|
case 7: /* EQ */
|
|
|
|
tcond = TCG_COND_EQ;
|
|
|
|
goto done;
|
|
|
|
case 10: /* PL */
|
|
|
|
case 11: /* MI */
|
2023-02-26 02:39:06 +01:00
|
|
|
c->v2 = tcg_constant_i32(0);
|
2015-08-14 16:59:23 +02:00
|
|
|
c->v1 = tmp = tcg_temp_new();
|
|
|
|
tcg_gen_sub_i32(tmp, QREG_CC_N, QREG_CC_V);
|
2016-01-16 17:23:50 +01:00
|
|
|
gen_ext(tmp, tmp, op - CC_OP_CMPB, 1);
|
2015-08-14 16:59:23 +02:00
|
|
|
/* fallthru */
|
|
|
|
case 12: /* GE */
|
|
|
|
case 13: /* LT */
|
|
|
|
tcond = TCG_COND_LT;
|
|
|
|
goto done;
|
|
|
|
case 14: /* GT */
|
|
|
|
case 15: /* LE */
|
|
|
|
tcond = TCG_COND_LE;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
2015-08-14 16:59:21 +02:00
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
c->v2 = tcg_constant_i32(0);
|
2015-08-14 16:59:21 +02:00
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
switch (cond) {
|
|
|
|
case 0: /* T */
|
|
|
|
case 1: /* F */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = c->v2;
|
|
|
|
tcond = TCG_COND_NEVER;
|
2015-08-14 16:59:23 +02:00
|
|
|
goto done;
|
|
|
|
case 14: /* GT (!(Z || (N ^ V))) */
|
|
|
|
case 15: /* LE (Z || (N ^ V)) */
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Logic operations clear V, which simplifies LE to (Z || N),
|
|
|
|
* and since Z and N are co-located, this becomes a normal
|
|
|
|
* comparison vs N.
|
|
|
|
*/
|
2015-08-14 16:59:23 +02:00
|
|
|
if (op == CC_OP_LOGIC) {
|
|
|
|
c->v1 = QREG_CC_N;
|
|
|
|
tcond = TCG_COND_LE;
|
|
|
|
goto done;
|
|
|
|
}
|
2015-08-14 16:59:21 +02:00
|
|
|
break;
|
2015-08-14 16:59:23 +02:00
|
|
|
case 12: /* GE (!(N ^ V)) */
|
|
|
|
case 13: /* LT (N ^ V) */
|
|
|
|
/* Logic operations clear V, which simplifies this to N. */
|
|
|
|
if (op != CC_OP_LOGIC) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
case 10: /* PL (!N) */
|
|
|
|
case 11: /* MI (N) */
|
|
|
|
/* Several cases represent N normally. */
|
2016-01-16 17:23:50 +01:00
|
|
|
if (op == CC_OP_ADDB || op == CC_OP_ADDW || op == CC_OP_ADDL ||
|
|
|
|
op == CC_OP_SUBB || op == CC_OP_SUBW || op == CC_OP_SUBL ||
|
|
|
|
op == CC_OP_LOGIC) {
|
2015-08-14 16:59:23 +02:00
|
|
|
c->v1 = QREG_CC_N;
|
|
|
|
tcond = TCG_COND_LT;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 6: /* NE (!Z) */
|
|
|
|
case 7: /* EQ (Z) */
|
|
|
|
/* Some cases fold Z into N. */
|
2016-01-16 17:23:50 +01:00
|
|
|
if (op == CC_OP_ADDB || op == CC_OP_ADDW || op == CC_OP_ADDL ||
|
|
|
|
op == CC_OP_SUBB || op == CC_OP_SUBW || op == CC_OP_SUBL ||
|
|
|
|
op == CC_OP_LOGIC) {
|
2015-08-14 16:59:23 +02:00
|
|
|
tcond = TCG_COND_EQ;
|
|
|
|
c->v1 = QREG_CC_N;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4: /* CC (!C) */
|
|
|
|
case 5: /* CS (C) */
|
|
|
|
/* Some cases fold C into X. */
|
2016-01-16 17:23:50 +01:00
|
|
|
if (op == CC_OP_ADDB || op == CC_OP_ADDW || op == CC_OP_ADDL ||
|
2017-07-27 04:42:15 +02:00
|
|
|
op == CC_OP_SUBB || op == CC_OP_SUBW || op == CC_OP_SUBL) {
|
2015-08-14 16:59:23 +02:00
|
|
|
tcond = TCG_COND_NE;
|
|
|
|
c->v1 = QREG_CC_X;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
case 8: /* VC (!V) */
|
|
|
|
case 9: /* VS (V) */
|
|
|
|
/* Logic operations clear V and C. */
|
|
|
|
if (op == CC_OP_LOGIC) {
|
|
|
|
tcond = TCG_COND_NEVER;
|
|
|
|
c->v1 = c->v2;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise, flush flag state to CC_OP_FLAGS. */
|
|
|
|
gen_flush_flags(s);
|
|
|
|
|
|
|
|
switch (cond) {
|
|
|
|
case 0: /* T */
|
|
|
|
case 1: /* F */
|
|
|
|
default:
|
|
|
|
/* Invalid, or handled above. */
|
|
|
|
abort();
|
2015-08-14 16:59:20 +02:00
|
|
|
case 2: /* HI (!C && !Z) -> !(C || Z)*/
|
2006-10-22 02:18:54 +02:00
|
|
|
case 3: /* LS (C || Z) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = tmp = tcg_temp_new();
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_EQ, tmp, QREG_CC_Z, c->v2);
|
2015-08-14 16:59:20 +02:00
|
|
|
tcg_gen_or_i32(tmp, tmp, QREG_CC_C);
|
2015-08-14 16:59:21 +02:00
|
|
|
tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 4: /* CC (!C) */
|
|
|
|
case 5: /* CS (C) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = QREG_CC_C;
|
|
|
|
tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 6: /* NE (!Z) */
|
|
|
|
case 7: /* EQ (Z) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = QREG_CC_Z;
|
|
|
|
tcond = TCG_COND_EQ;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 8: /* VC (!V) */
|
|
|
|
case 9: /* VS (V) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = QREG_CC_V;
|
|
|
|
tcond = TCG_COND_LT;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 10: /* PL (!N) */
|
|
|
|
case 11: /* MI (N) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = QREG_CC_N;
|
|
|
|
tcond = TCG_COND_LT;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 12: /* GE (!(N ^ V)) */
|
|
|
|
case 13: /* LT (N ^ V) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = tmp = tcg_temp_new();
|
2015-08-14 16:59:20 +02:00
|
|
|
tcg_gen_xor_i32(tmp, QREG_CC_N, QREG_CC_V);
|
2015-08-14 16:59:21 +02:00
|
|
|
tcond = TCG_COND_LT;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 14: /* GT (!(Z || (N ^ V))) */
|
|
|
|
case 15: /* LE (Z || (N ^ V)) */
|
2015-08-14 16:59:21 +02:00
|
|
|
c->v1 = tmp = tcg_temp_new();
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(TCG_COND_EQ, tmp, QREG_CC_Z, c->v2);
|
2015-08-14 16:59:20 +02:00
|
|
|
tmp2 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(tmp2, QREG_CC_N, QREG_CC_V);
|
|
|
|
tcg_gen_or_i32(tmp, tmp, tmp2);
|
2015-08-14 16:59:21 +02:00
|
|
|
tcond = TCG_COND_LT;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2015-08-14 16:59:23 +02:00
|
|
|
|
|
|
|
done:
|
2015-08-14 16:59:21 +02:00
|
|
|
if ((cond & 1) == 0) {
|
|
|
|
tcond = tcg_invert_cond(tcond);
|
|
|
|
}
|
|
|
|
c->tcond = tcond;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_jmpcc(DisasContext *s, int cond, TCGLabel *l1)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
|
|
|
|
gen_cc_cond(&c, s, cond);
|
|
|
|
update_cc_op(s);
|
|
|
|
tcg_gen_brcond_i32(c.tcond, c.v1, c.v2, l1);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2007-05-23 21:58:11 +02:00
|
|
|
/* Force a TB lookup after an instruction that changes the CPU state. */
|
2018-05-12 07:02:46 +02:00
|
|
|
static void gen_exit_tb(DisasContext *s)
|
2007-05-23 21:58:11 +02:00
|
|
|
{
|
2015-08-09 01:44:24 +02:00
|
|
|
update_cc_op(s);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_movi_i32(QREG_PC, s->pc);
|
2018-05-12 07:02:47 +02:00
|
|
|
s->base.is_jmp = DISAS_EXIT;
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
#define SRC_EA(env, result, opsize, op_sign, addrp) do { \
|
|
|
|
result = gen_ea(env, s, insn, opsize, NULL_QREG, addrp, \
|
2018-01-18 20:38:43 +01:00
|
|
|
op_sign ? EA_LOADS : EA_LOADU, IS_USER(s)); \
|
2012-09-08 12:48:20 +02:00
|
|
|
if (IS_NULL_QREG(result)) { \
|
|
|
|
gen_addr_fault(s); \
|
|
|
|
return; \
|
|
|
|
} \
|
2007-05-27 00:11:13 +02:00
|
|
|
} while (0)
|
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
#define DEST_EA(env, insn, opsize, val, addrp) do { \
|
2018-01-18 20:38:43 +01:00
|
|
|
TCGv ea_result = gen_ea(env, s, insn, opsize, val, addrp, \
|
|
|
|
EA_STORE, IS_USER(s)); \
|
2012-09-08 12:48:20 +02:00
|
|
|
if (IS_NULL_QREG(ea_result)) { \
|
|
|
|
gen_addr_fault(s); \
|
|
|
|
return; \
|
|
|
|
} \
|
2007-05-27 00:11:13 +02:00
|
|
|
} while (0)
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
/* Generate a jump to an immediate address. */
|
2022-06-02 03:33:52 +02:00
|
|
|
static void gen_jmp_tb(DisasContext *s, int n, target_ulong dest,
|
|
|
|
target_ulong src)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2021-07-19 09:27:53 +02:00
|
|
|
if (unlikely(s->ss_active)) {
|
2021-05-19 16:29:15 +02:00
|
|
|
update_cc_op(s);
|
|
|
|
tcg_gen_movi_i32(QREG_PC, dest);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_raise_exception_format2(s, EXCP_TRACE, src);
|
2021-06-21 01:18:47 +02:00
|
|
|
} else if (translator_use_goto_tb(&s->base, dest)) {
|
2008-02-01 11:50:11 +01:00
|
|
|
tcg_gen_goto_tb(n);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_movi_i32(QREG_PC, dest);
|
2018-05-12 07:02:47 +02:00
|
|
|
tcg_gen_exit_tb(s->base.tb, n);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_jmp_im(s, dest);
|
2018-05-31 03:06:23 +02:00
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2018-05-12 07:02:47 +02:00
|
|
|
s->base.is_jmp = DISAS_NORETURN;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-10 23:53:20 +01:00
|
|
|
DISAS_INSN(scc)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
int cond;
|
|
|
|
TCGv tmp;
|
|
|
|
|
|
|
|
cond = (insn >> 8) & 0xf;
|
|
|
|
gen_cc_cond(&c, s, cond);
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(c.tcond, tmp, c.v1, c.v2);
|
2016-01-10 23:53:20 +01:00
|
|
|
|
|
|
|
DEST_EA(env, insn, OS_BYTE, tmp, NULL);
|
|
|
|
}
|
|
|
|
|
2016-01-10 23:53:20 +01:00
|
|
|
DISAS_INSN(dbcc)
|
|
|
|
{
|
|
|
|
TCGLabel *l1;
|
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
|
|
|
int16_t offset;
|
|
|
|
uint32_t base;
|
|
|
|
|
|
|
|
reg = DREG(insn, 0);
|
|
|
|
base = s->pc;
|
|
|
|
offset = (int16_t)read_im16(env, s);
|
|
|
|
l1 = gen_new_label();
|
|
|
|
gen_jmpcc(s, (insn >> 8) & 0xf, l1);
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
tcg_gen_ext16s_i32(tmp, reg);
|
|
|
|
tcg_gen_addi_i32(tmp, tmp, -1);
|
|
|
|
gen_partset_reg(OS_WORD, reg, tmp);
|
|
|
|
tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, -1, l1);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 1, base + offset, s->base.pc_next);
|
2016-01-10 23:53:20 +01:00
|
|
|
gen_set_label(l1);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 0, s->pc, s->base.pc_next);
|
2016-01-10 23:53:20 +01:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(undef_mac)
|
|
|
|
{
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_LINEA);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(undef_fpu)
|
|
|
|
{
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_LINEF);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(undef)
|
|
|
|
{
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* ??? This is both instructions that are as yet unimplemented
|
|
|
|
* for the 680x0 series, as well as those that are implemented
|
|
|
|
* but actually illegal for CPU32 or pre-68020.
|
|
|
|
*/
|
2018-06-08 14:15:33 +02:00
|
|
|
qemu_log_mask(LOG_UNIMP, "Illegal instruction: %04x @ %08x\n",
|
2018-05-12 07:02:47 +02:00
|
|
|
insn, s->base.pc_next);
|
2018-10-30 17:55:54 +01:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(mulw)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
|
|
|
TCGv src;
|
2006-10-22 02:18:54 +02:00
|
|
|
int sign;
|
|
|
|
|
|
|
|
sign = (insn & 0x100) != 0;
|
|
|
|
reg = DREG(insn, 9);
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
if (sign)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext16s_i32(tmp, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext16u_i32(tmp, reg);
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src, OS_WORD, sign, NULL);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mul_i32(tmp, tmp, src);
|
|
|
|
tcg_gen_mov_i32(reg, tmp);
|
2016-11-24 09:31:32 +01:00
|
|
|
gen_logic_cc(s, tmp, OS_LONG);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(divw)
|
|
|
|
{
|
|
|
|
int sign;
|
2016-10-28 20:42:23 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv destr;
|
2022-06-02 03:33:51 +02:00
|
|
|
TCGv ilen;
|
2016-10-28 20:42:23 +02:00
|
|
|
|
|
|
|
/* divX.w <EA>,Dn 32/16 -> 16r:16q */
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
sign = (insn & 0x100) != 0;
|
2016-10-28 20:42:23 +02:00
|
|
|
|
|
|
|
/* dest.l / src.w */
|
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src, OS_WORD, sign, NULL);
|
2022-06-02 03:33:51 +02:00
|
|
|
destr = tcg_constant_i32(REG(insn, 9));
|
|
|
|
ilen = tcg_constant_i32(s->pc - s->base.pc_next);
|
2006-10-22 02:18:54 +02:00
|
|
|
if (sign) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_divsw(tcg_env, destr, src, ilen);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_divuw(tcg_env, destr, src, ilen);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2015-08-09 01:44:24 +02:00
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(divl)
|
|
|
|
{
|
2022-06-02 03:33:51 +02:00
|
|
|
TCGv num, reg, den, ilen;
|
2016-10-28 20:42:23 +02:00
|
|
|
int sign;
|
2006-10-22 02:18:54 +02:00
|
|
|
uint16_t ext;
|
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2016-10-28 20:42:23 +02:00
|
|
|
|
|
|
|
sign = (ext & 0x0800) != 0;
|
|
|
|
|
|
|
|
if (ext & 0x400) {
|
|
|
|
if (!m68k_feature(s->env, M68K_FEATURE_QUAD_MULDIV)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2016-10-28 20:42:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* divX.l <EA>, Dr:Dq 64/32 -> 32r:32q */
|
|
|
|
|
|
|
|
SRC_EA(env, den, OS_LONG, 0, NULL);
|
2022-06-02 03:33:51 +02:00
|
|
|
num = tcg_constant_i32(REG(ext, 12));
|
|
|
|
reg = tcg_constant_i32(REG(ext, 0));
|
|
|
|
ilen = tcg_constant_i32(s->pc - s->base.pc_next);
|
2016-10-28 20:42:23 +02:00
|
|
|
if (sign) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_divsll(tcg_env, num, reg, den, ilen);
|
2016-10-28 20:42:23 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_divull(tcg_env, num, reg, den, ilen);
|
2016-10-28 20:42:23 +02:00
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2006-10-22 02:18:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-10-28 20:42:23 +02:00
|
|
|
|
|
|
|
/* divX.l <EA>, Dq 32/32 -> 32q */
|
|
|
|
/* divXl.l <EA>, Dr:Dq 32/32 -> 32r:32q */
|
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, den, OS_LONG, 0, NULL);
|
2022-06-02 03:33:51 +02:00
|
|
|
num = tcg_constant_i32(REG(ext, 12));
|
|
|
|
reg = tcg_constant_i32(REG(ext, 0));
|
|
|
|
ilen = tcg_constant_i32(s->pc - s->base.pc_next);
|
2016-10-28 20:42:23 +02:00
|
|
|
if (sign) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_divsl(tcg_env, num, reg, den, ilen);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_divul(tcg_env, num, reg, den, ilen);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-10-28 20:42:23 +02:00
|
|
|
|
2015-08-09 01:44:24 +02:00
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-05-07 22:28:57 +02:00
|
|
|
static void bcd_add(TCGv dest, TCGv src)
|
|
|
|
{
|
|
|
|
TCGv t0, t1;
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* dest10 = dest10 + src10 + X
|
2016-05-07 22:28:57 +02:00
|
|
|
*
|
|
|
|
* t1 = src
|
|
|
|
* t2 = t1 + 0x066
|
|
|
|
* t3 = t2 + dest + X
|
|
|
|
* t4 = t2 ^ dest
|
|
|
|
* t5 = t3 ^ t4
|
|
|
|
* t6 = ~t5 & 0x110
|
|
|
|
* t7 = (t6 >> 2) | (t6 >> 3)
|
|
|
|
* return t3 - t7
|
|
|
|
*/
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* t1 = (src + 0x066) + dest + X
|
2020-10-09 08:44:43 +02:00
|
|
|
* = result with some possible exceeding 0x6
|
2016-05-07 22:28:57 +02:00
|
|
|
*/
|
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_addi_i32(t0, src, 0x066);
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_add_i32(t1, t0, dest);
|
|
|
|
tcg_gen_add_i32(t1, t1, QREG_CC_X);
|
|
|
|
|
2020-10-09 08:44:43 +02:00
|
|
|
/* we will remove exceeding 0x6 where there is no carry */
|
2016-05-07 22:28:57 +02:00
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* t0 = (src + 0x0066) ^ dest
|
2016-05-07 22:28:57 +02:00
|
|
|
* = t1 without carries
|
|
|
|
*/
|
|
|
|
|
|
|
|
tcg_gen_xor_i32(t0, t0, dest);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* extract the carries
|
2016-05-07 22:28:57 +02:00
|
|
|
* t0 = t0 ^ t1
|
|
|
|
* = only the carries
|
|
|
|
*/
|
|
|
|
|
|
|
|
tcg_gen_xor_i32(t0, t0, t1);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* generate 0x1 where there is no carry
|
2016-05-07 22:28:57 +02:00
|
|
|
* and for each 0x10, generate a 0x6
|
|
|
|
*/
|
|
|
|
|
|
|
|
tcg_gen_shri_i32(t0, t0, 3);
|
|
|
|
tcg_gen_not_i32(t0, t0);
|
|
|
|
tcg_gen_andi_i32(t0, t0, 0x22);
|
|
|
|
tcg_gen_add_i32(dest, t0, t0);
|
|
|
|
tcg_gen_add_i32(dest, dest, t0);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
2020-10-09 08:44:43 +02:00
|
|
|
* remove the exceeding 0x6
|
2016-05-07 22:28:57 +02:00
|
|
|
* for digits that have not generated a carry
|
|
|
|
*/
|
|
|
|
|
|
|
|
tcg_gen_sub_i32(dest, t1, dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcd_sub(TCGv dest, TCGv src)
|
|
|
|
{
|
|
|
|
TCGv t0, t1, t2;
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* dest10 = dest10 - src10 - X
|
2016-05-07 22:28:57 +02:00
|
|
|
* = bcd_add(dest + 1 - X, 0x199 - src)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* t0 = 0x066 + (0x199 - src) */
|
|
|
|
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_subfi_i32(t0, 0x1ff, src);
|
|
|
|
|
|
|
|
/* t1 = t0 + dest + 1 - X*/
|
|
|
|
|
|
|
|
t1 = tcg_temp_new();
|
|
|
|
tcg_gen_add_i32(t1, t0, dest);
|
|
|
|
tcg_gen_addi_i32(t1, t1, 1);
|
|
|
|
tcg_gen_sub_i32(t1, t1, QREG_CC_X);
|
|
|
|
|
|
|
|
/* t2 = t0 ^ dest */
|
|
|
|
|
|
|
|
t2 = tcg_temp_new();
|
|
|
|
tcg_gen_xor_i32(t2, t0, dest);
|
|
|
|
|
|
|
|
/* t0 = t1 ^ t2 */
|
|
|
|
|
|
|
|
tcg_gen_xor_i32(t0, t1, t2);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* t2 = ~t0 & 0x110
|
2016-05-07 22:28:57 +02:00
|
|
|
* t0 = (t2 >> 2) | (t2 >> 3)
|
|
|
|
*
|
|
|
|
* to fit on 8bit operands, changed in:
|
|
|
|
*
|
|
|
|
* t2 = ~(t0 >> 3) & 0x22
|
|
|
|
* t0 = t2 + t2
|
|
|
|
* t0 = t0 + t2
|
|
|
|
*/
|
|
|
|
|
|
|
|
tcg_gen_shri_i32(t2, t0, 3);
|
|
|
|
tcg_gen_not_i32(t2, t2);
|
|
|
|
tcg_gen_andi_i32(t2, t2, 0x22);
|
|
|
|
tcg_gen_add_i32(t0, t2, t2);
|
|
|
|
tcg_gen_add_i32(t0, t0, t2);
|
|
|
|
|
|
|
|
/* return t1 - t0 */
|
|
|
|
|
|
|
|
tcg_gen_sub_i32(dest, t1, t0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bcd_flags(TCGv val)
|
|
|
|
{
|
|
|
|
tcg_gen_andi_i32(QREG_CC_C, val, 0x0ff);
|
|
|
|
tcg_gen_or_i32(QREG_CC_Z, QREG_CC_Z, QREG_CC_C);
|
|
|
|
|
2017-07-18 06:55:34 +02:00
|
|
|
tcg_gen_extract_i32(QREG_CC_C, val, 8, 1);
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
tcg_gen_mov_i32(QREG_CC_X, QREG_CC_C);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(abcd_reg)
|
|
|
|
{
|
|
|
|
TCGv src;
|
|
|
|
TCGv dest;
|
|
|
|
|
|
|
|
gen_flush_flags(s); /* !Z is sticky */
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
src = gen_extend(s, DREG(insn, 0), OS_BYTE, 0);
|
|
|
|
dest = gen_extend(s, DREG(insn, 9), OS_BYTE, 0);
|
2016-05-07 22:28:57 +02:00
|
|
|
bcd_add(dest, src);
|
|
|
|
gen_partset_reg(OS_BYTE, DREG(insn, 9), dest);
|
|
|
|
|
|
|
|
bcd_flags(dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(abcd_mem)
|
|
|
|
{
|
|
|
|
TCGv src, dest, addr;
|
|
|
|
|
|
|
|
gen_flush_flags(s); /* !Z is sticky */
|
|
|
|
|
|
|
|
/* Indirect pre-decrement load (mode 4) */
|
|
|
|
|
|
|
|
src = gen_ea_mode(env, s, 4, REG(insn, 0), OS_BYTE,
|
2018-01-18 20:38:43 +01:00
|
|
|
NULL_QREG, NULL, EA_LOADU, IS_USER(s));
|
2016-05-07 22:28:57 +02:00
|
|
|
dest = gen_ea_mode(env, s, 4, REG(insn, 9), OS_BYTE,
|
2018-01-18 20:38:43 +01:00
|
|
|
NULL_QREG, &addr, EA_LOADU, IS_USER(s));
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
bcd_add(dest, src);
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_ea_mode(env, s, 4, REG(insn, 9), OS_BYTE, dest, &addr,
|
|
|
|
EA_STORE, IS_USER(s));
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
bcd_flags(dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(sbcd_reg)
|
|
|
|
{
|
|
|
|
TCGv src, dest;
|
|
|
|
|
|
|
|
gen_flush_flags(s); /* !Z is sticky */
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
src = gen_extend(s, DREG(insn, 0), OS_BYTE, 0);
|
|
|
|
dest = gen_extend(s, DREG(insn, 9), OS_BYTE, 0);
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
bcd_sub(dest, src);
|
|
|
|
|
|
|
|
gen_partset_reg(OS_BYTE, DREG(insn, 9), dest);
|
|
|
|
|
|
|
|
bcd_flags(dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(sbcd_mem)
|
|
|
|
{
|
|
|
|
TCGv src, dest, addr;
|
|
|
|
|
|
|
|
gen_flush_flags(s); /* !Z is sticky */
|
|
|
|
|
|
|
|
/* Indirect pre-decrement load (mode 4) */
|
|
|
|
|
|
|
|
src = gen_ea_mode(env, s, 4, REG(insn, 0), OS_BYTE,
|
2018-01-18 20:38:43 +01:00
|
|
|
NULL_QREG, NULL, EA_LOADU, IS_USER(s));
|
2016-05-07 22:28:57 +02:00
|
|
|
dest = gen_ea_mode(env, s, 4, REG(insn, 9), OS_BYTE,
|
2018-01-18 20:38:43 +01:00
|
|
|
NULL_QREG, &addr, EA_LOADU, IS_USER(s));
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
bcd_sub(dest, src);
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_ea_mode(env, s, 4, REG(insn, 9), OS_BYTE, dest, &addr,
|
|
|
|
EA_STORE, IS_USER(s));
|
2016-05-07 22:28:57 +02:00
|
|
|
|
|
|
|
bcd_flags(dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(nbcd)
|
|
|
|
{
|
|
|
|
TCGv src, dest;
|
|
|
|
TCGv addr;
|
|
|
|
|
|
|
|
gen_flush_flags(s); /* !Z is sticky */
|
|
|
|
|
|
|
|
SRC_EA(env, src, OS_BYTE, 0, &addr);
|
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
dest = tcg_temp_new();
|
|
|
|
tcg_gen_movi_i32(dest, 0);
|
2016-05-07 22:28:57 +02:00
|
|
|
bcd_sub(dest, src);
|
|
|
|
|
|
|
|
DEST_EA(env, insn, OS_BYTE, dest, &addr);
|
|
|
|
|
|
|
|
bcd_flags(dest);
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(addsub)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv src;
|
|
|
|
TCGv tmp;
|
|
|
|
TCGv addr;
|
2006-10-22 02:18:54 +02:00
|
|
|
int add;
|
2016-01-17 00:57:01 +01:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
add = (insn & 0x4000) != 0;
|
2016-01-17 00:57:01 +01:00
|
|
|
opsize = insn_opsize(insn);
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 9), opsize, 1);
|
2008-11-17 15:43:54 +01:00
|
|
|
dest = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
if (insn & 0x100) {
|
2016-01-17 00:57:01 +01:00
|
|
|
SRC_EA(env, tmp, opsize, 1, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
src = reg;
|
|
|
|
} else {
|
|
|
|
tmp = reg;
|
2016-01-17 00:57:01 +01:00
|
|
|
SRC_EA(env, src, opsize, 1, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
if (add) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_add_i32(dest, tmp, src);
|
2015-08-14 16:59:19 +02:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_X, dest, src);
|
2016-01-17 00:57:01 +01:00
|
|
|
set_cc_op(s, CC_OP_ADDB + opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2015-08-14 16:59:19 +02:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_X, tmp, src);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_sub_i32(dest, tmp, src);
|
2016-01-17 00:57:01 +01:00
|
|
|
set_cc_op(s, CC_OP_SUBB + opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-01-17 00:57:01 +01:00
|
|
|
gen_update_cc_add(dest, src, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
if (insn & 0x100) {
|
2016-01-17 00:57:01 +01:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-01-17 00:57:01 +01:00
|
|
|
gen_partset_reg(opsize, DREG(insn, 9), dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reverse the order of the bits in REG. */
|
|
|
|
DISAS_INSN(bitrev)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = DREG(insn, 0);
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_helper_bitrev(reg, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(bitop_reg)
|
|
|
|
{
|
|
|
|
int opsize;
|
|
|
|
int op;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src1;
|
|
|
|
TCGv src2;
|
|
|
|
TCGv tmp;
|
|
|
|
TCGv addr;
|
|
|
|
TCGv dest;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
if ((insn & 0x38) != 0)
|
|
|
|
opsize = OS_BYTE;
|
|
|
|
else
|
|
|
|
opsize = OS_LONG;
|
|
|
|
op = (insn >> 6) & 3;
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src1, opsize, 0, op ? &addr: NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-17 12:51:45 +01:00
|
|
|
gen_flush_flags(s);
|
|
|
|
src2 = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
if (opsize == OS_BYTE)
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_andi_i32(src2, DREG(insn, 9), 7);
|
2006-10-22 02:18:54 +02:00
|
|
|
else
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_andi_i32(src2, DREG(insn, 9), 31);
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
tmp = tcg_temp_new();
|
|
|
|
tcg_gen_shl_i32(tmp, tcg_constant_i32(1), src2);
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_and_i32(QREG_CC_Z, src1, tmp);
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2016-01-17 12:51:45 +01:00
|
|
|
dest = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
switch (op) {
|
|
|
|
case 1: /* bchg */
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_xor_i32(dest, src1, tmp);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 2: /* bclr */
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_andc_i32(dest, src1, tmp);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 3: /* bset */
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_or_i32(dest, src1, tmp);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
default: /* btst */
|
|
|
|
break;
|
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
if (op) {
|
2012-09-08 12:48:20 +02:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2015-08-14 16:59:20 +02:00
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(sats)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = DREG(insn, 0);
|
|
|
|
gen_flush_flags(s);
|
2015-08-14 16:59:20 +02:00
|
|
|
gen_helper_sats(reg, reg, QREG_CC_V);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, reg, OS_LONG);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
static void gen_push(DisasContext *s, TCGv val)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_subi_i32(tmp, QREG_SP, 4);
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, OS_LONG, tmp, val, IS_USER(s));
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(QREG_SP, tmp);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:07 +01:00
|
|
|
static TCGv mreg(int reg)
|
|
|
|
{
|
|
|
|
if (reg < 8) {
|
|
|
|
/* Dx */
|
|
|
|
return cpu_dregs[reg];
|
|
|
|
}
|
|
|
|
/* Ax */
|
|
|
|
return cpu_aregs[reg & 7];
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(movem)
|
|
|
|
{
|
2016-11-09 14:46:07 +01:00
|
|
|
TCGv addr, incr, tmp, r[16];
|
|
|
|
int is_load = (insn & 0x0400) != 0;
|
|
|
|
int opsize = (insn & 0x40) != 0 ? OS_LONG : OS_WORD;
|
|
|
|
uint16_t mask = read_im16(env, s);
|
|
|
|
int mode = extract32(insn, 3, 3);
|
|
|
|
int reg0 = REG(insn, 0);
|
2006-10-22 02:18:54 +02:00
|
|
|
int i;
|
|
|
|
|
2016-11-09 14:46:07 +01:00
|
|
|
tmp = cpu_aregs[reg0];
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0: /* data register direct */
|
|
|
|
case 1: /* addr register direct */
|
|
|
|
do_addr_fault:
|
2007-05-27 00:11:13 +02:00
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
2016-11-09 14:46:07 +01:00
|
|
|
|
|
|
|
case 2: /* indirect */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: /* indirect post-increment */
|
|
|
|
if (!is_load) {
|
|
|
|
/* post-increment is not allowed */
|
|
|
|
goto do_addr_fault;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: /* indirect pre-decrement */
|
|
|
|
if (is_load) {
|
|
|
|
/* pre-decrement is not allowed */
|
|
|
|
goto do_addr_fault;
|
|
|
|
}
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* We want a bare copy of the address reg, without any pre-decrement
|
|
|
|
* adjustment, as gen_lea would provide.
|
|
|
|
*/
|
2016-11-09 14:46:07 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
tmp = gen_lea_mode(env, s, mode, reg0, opsize);
|
|
|
|
if (IS_NULL_QREG(tmp)) {
|
|
|
|
goto do_addr_fault;
|
|
|
|
}
|
|
|
|
break;
|
2007-05-27 00:11:13 +02:00
|
|
|
}
|
2016-11-09 14:46:07 +01:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
addr = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(addr, tmp);
|
2023-02-26 02:39:06 +01:00
|
|
|
incr = tcg_constant_i32(opsize_bytes(opsize));
|
2016-11-09 14:46:07 +01:00
|
|
|
|
|
|
|
if (is_load) {
|
|
|
|
/* memory to register */
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
if (mask & (1 << i)) {
|
2018-01-18 20:38:43 +01:00
|
|
|
r[i] = gen_load(s, opsize, addr, 1, IS_USER(s));
|
2016-11-09 14:46:07 +01:00
|
|
|
tcg_gen_add_i32(addr, addr, incr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
if (mask & (1 << i)) {
|
|
|
|
tcg_gen_mov_i32(mreg(i), r[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mode == 3) {
|
|
|
|
/* post-increment: movem (An)+,X */
|
|
|
|
tcg_gen_mov_i32(cpu_aregs[reg0], addr);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* register to memory */
|
|
|
|
if (mode == 4) {
|
|
|
|
/* pre-decrement: movem X,-(An) */
|
|
|
|
for (i = 15; i >= 0; i--) {
|
|
|
|
if ((mask << i) & 0x8000) {
|
|
|
|
tcg_gen_sub_i32(addr, addr, incr);
|
|
|
|
if (reg0 + 8 == i &&
|
|
|
|
m68k_feature(s->env, M68K_FEATURE_EXT_FULL)) {
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* M68020+: if the addressing register is the
|
2016-11-09 14:46:07 +01:00
|
|
|
* register moved to memory, the value written
|
|
|
|
* is the initial value decremented by the size of
|
|
|
|
* the operation, regardless of how many actual
|
|
|
|
* stores have been performed until this point.
|
|
|
|
* M68000/M68010: the value is the initial value.
|
|
|
|
*/
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
tcg_gen_sub_i32(tmp, cpu_aregs[reg0], incr);
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, opsize, addr, tmp, IS_USER(s));
|
2016-11-09 14:46:07 +01:00
|
|
|
} else {
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, opsize, addr, mreg(i), IS_USER(s));
|
2016-11-09 14:46:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tcg_gen_mov_i32(cpu_aregs[reg0], addr);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
if (mask & (1 << i)) {
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, opsize, addr, mreg(i), IS_USER(s));
|
2016-11-09 14:46:07 +01:00
|
|
|
tcg_gen_add_i32(addr, addr, incr);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-06 13:44:31 +01:00
|
|
|
DISAS_INSN(movep)
|
|
|
|
{
|
|
|
|
uint8_t i;
|
|
|
|
int16_t displ;
|
|
|
|
TCGv reg;
|
|
|
|
TCGv addr;
|
|
|
|
TCGv abuf;
|
|
|
|
TCGv dbuf;
|
|
|
|
|
|
|
|
displ = read_im16(env, s);
|
|
|
|
|
|
|
|
addr = AREG(insn, 0);
|
|
|
|
reg = DREG(insn, 9);
|
|
|
|
|
|
|
|
abuf = tcg_temp_new();
|
|
|
|
tcg_gen_addi_i32(abuf, addr, displ);
|
|
|
|
dbuf = tcg_temp_new();
|
|
|
|
|
|
|
|
if (insn & 0x40) {
|
|
|
|
i = 4;
|
|
|
|
} else {
|
|
|
|
i = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (insn & 0x80) {
|
|
|
|
for ( ; i > 0 ; i--) {
|
|
|
|
tcg_gen_shri_i32(dbuf, reg, (i - 1) * 8);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_i32(dbuf, abuf, IS_USER(s), MO_UB);
|
2018-02-06 13:44:31 +01:00
|
|
|
if (i > 1) {
|
|
|
|
tcg_gen_addi_i32(abuf, abuf, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( ; i > 0 ; i--) {
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_tl(dbuf, abuf, IS_USER(s), MO_UB);
|
2018-02-06 13:44:31 +01:00
|
|
|
tcg_gen_deposit_i32(reg, reg, dbuf, (i - 1) * 8, 8);
|
|
|
|
if (i > 1) {
|
|
|
|
tcg_gen_addi_i32(abuf, abuf, 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(bitop_im)
|
|
|
|
{
|
|
|
|
int opsize;
|
|
|
|
int op;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src1;
|
2006-10-22 02:18:54 +02:00
|
|
|
uint32_t mask;
|
|
|
|
int bitnum;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
|
|
|
TCGv addr;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
if ((insn & 0x38) != 0)
|
|
|
|
opsize = OS_BYTE;
|
|
|
|
else
|
|
|
|
opsize = OS_LONG;
|
|
|
|
op = (insn >> 6) & 3;
|
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
bitnum = read_im16(env, s);
|
2022-09-17 13:25:12 +02:00
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2017-01-13 19:36:29 +01:00
|
|
|
if (bitnum & 0xfe00) {
|
|
|
|
disas_undef(env, s, insn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bitnum & 0xff00) {
|
|
|
|
disas_undef(env, s, insn);
|
|
|
|
return;
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src1, opsize, 0, op ? &addr: NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-17 12:51:45 +01:00
|
|
|
gen_flush_flags(s);
|
2006-10-22 02:18:54 +02:00
|
|
|
if (opsize == OS_BYTE)
|
|
|
|
bitnum &= 7;
|
|
|
|
else
|
|
|
|
bitnum &= 31;
|
|
|
|
mask = 1 << bitnum;
|
|
|
|
|
2016-01-17 12:51:45 +01:00
|
|
|
tcg_gen_andi_i32(QREG_CC_Z, src1, mask);
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
if (op) {
|
2015-08-14 16:59:20 +02:00
|
|
|
tmp = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
switch (op) {
|
|
|
|
case 1: /* bchg */
|
|
|
|
tcg_gen_xori_i32(tmp, src1, mask);
|
|
|
|
break;
|
|
|
|
case 2: /* bclr */
|
|
|
|
tcg_gen_andi_i32(tmp, src1, ~mask);
|
|
|
|
break;
|
|
|
|
case 3: /* bset */
|
|
|
|
tcg_gen_ori_i32(tmp, src1, mask);
|
|
|
|
break;
|
|
|
|
default: /* btst */
|
|
|
|
break;
|
|
|
|
}
|
2012-09-08 12:48:20 +02:00
|
|
|
DEST_EA(env, insn, opsize, tmp, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2018-01-04 02:29:09 +01:00
|
|
|
static TCGv gen_get_ccr(DisasContext *s)
|
|
|
|
{
|
|
|
|
TCGv dest;
|
|
|
|
|
|
|
|
update_cc_op(s);
|
|
|
|
dest = tcg_temp_new();
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_get_ccr(dest, tcg_env);
|
2018-01-04 02:29:09 +01:00
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
static TCGv gen_get_sr(DisasContext *s)
|
|
|
|
{
|
|
|
|
TCGv ccr;
|
|
|
|
TCGv sr;
|
|
|
|
|
|
|
|
ccr = gen_get_ccr(s);
|
|
|
|
sr = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(sr, QREG_SR, 0xffe0);
|
|
|
|
tcg_gen_or_i32(sr, sr, ccr);
|
|
|
|
return sr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_set_sr_im(DisasContext *s, uint16_t val, int ccr_only)
|
|
|
|
{
|
|
|
|
if (ccr_only) {
|
|
|
|
tcg_gen_movi_i32(QREG_CC_C, val & CCF_C ? 1 : 0);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, val & CCF_V ? -1 : 0);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_Z, val & CCF_Z ? 0 : 1);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_N, val & CCF_N ? -1 : 0);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_X, val & CCF_X ? 1 : 0);
|
|
|
|
} else {
|
2022-09-13 16:28:18 +02:00
|
|
|
/* Must writeback before changing security state. */
|
|
|
|
do_writebacks(s);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_sr(tcg_env, tcg_constant_i32(val));
|
2018-01-04 02:29:09 +01:00
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
2018-01-04 02:29:10 +01:00
|
|
|
static void gen_set_sr(DisasContext *s, TCGv val, int ccr_only)
|
2018-01-04 02:29:09 +01:00
|
|
|
{
|
2018-01-04 02:29:10 +01:00
|
|
|
if (ccr_only) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_ccr(tcg_env, val);
|
2018-01-04 02:29:10 +01:00
|
|
|
} else {
|
2022-09-13 16:28:18 +02:00
|
|
|
/* Must writeback before changing security state. */
|
|
|
|
do_writebacks(s);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_sr(tcg_env, val);
|
2018-01-04 02:29:10 +01:00
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_move_to_sr(CPUM68KState *env, DisasContext *s, uint16_t insn,
|
|
|
|
bool ccr_only)
|
|
|
|
{
|
|
|
|
if ((insn & 0x3f) == 0x3c) {
|
2018-01-04 02:29:09 +01:00
|
|
|
uint16_t val;
|
|
|
|
val = read_im16(env, s);
|
|
|
|
gen_set_sr_im(s, val, ccr_only);
|
|
|
|
} else {
|
2018-01-04 02:29:10 +01:00
|
|
|
TCGv src;
|
|
|
|
SRC_EA(env, src, OS_WORD, 0, NULL);
|
|
|
|
gen_set_sr(s, src, ccr_only);
|
2018-01-04 02:29:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(arith_im)
|
|
|
|
{
|
|
|
|
int op;
|
2016-01-17 00:59:27 +01:00
|
|
|
TCGv im;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src1;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv addr;
|
2016-01-17 00:59:27 +01:00
|
|
|
int opsize;
|
2018-01-04 02:29:11 +01:00
|
|
|
bool with_SR = ((insn & 0x3f) == 0x3c);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
op = (insn >> 9) & 7;
|
2016-01-17 00:59:27 +01:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
2023-02-26 02:39:06 +01:00
|
|
|
im = tcg_constant_i32((int8_t)read_im8(env, s));
|
2016-01-17 00:59:27 +01:00
|
|
|
break;
|
|
|
|
case OS_WORD:
|
2023-02-26 02:39:06 +01:00
|
|
|
im = tcg_constant_i32((int16_t)read_im16(env, s));
|
2016-01-17 00:59:27 +01:00
|
|
|
break;
|
|
|
|
case OS_LONG:
|
2023-02-26 02:39:06 +01:00
|
|
|
im = tcg_constant_i32(read_im32(env, s));
|
2016-01-17 00:59:27 +01:00
|
|
|
break;
|
|
|
|
default:
|
2018-05-08 20:55:20 +02:00
|
|
|
g_assert_not_reached();
|
2016-01-17 00:59:27 +01:00
|
|
|
}
|
2018-01-04 02:29:11 +01:00
|
|
|
|
|
|
|
if (with_SR) {
|
|
|
|
/* SR/CCR can only be used with andi/eori/ori */
|
|
|
|
if (op == 2 || op == 3 || op == 6) {
|
|
|
|
disas_undef(env, s, insn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch (opsize) {
|
|
|
|
case OS_BYTE:
|
|
|
|
src1 = gen_get_ccr(s);
|
|
|
|
break;
|
|
|
|
case OS_WORD:
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
src1 = gen_get_sr(s);
|
|
|
|
break;
|
2018-05-08 20:55:20 +02:00
|
|
|
default:
|
|
|
|
/* OS_LONG; others already g_assert_not_reached. */
|
2018-01-04 02:29:11 +01:00
|
|
|
disas_undef(env, s, insn);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SRC_EA(env, src1, opsize, 1, (op == 6) ? NULL : &addr);
|
|
|
|
}
|
2008-11-17 15:43:54 +01:00
|
|
|
dest = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
switch (op) {
|
|
|
|
case 0: /* ori */
|
2016-01-17 00:59:27 +01:00
|
|
|
tcg_gen_or_i32(dest, src1, im);
|
2018-01-04 02:29:11 +01:00
|
|
|
if (with_SR) {
|
|
|
|
gen_set_sr(s, dest, opsize == OS_BYTE);
|
2022-09-17 13:25:15 +02:00
|
|
|
gen_exit_tb(s);
|
2018-01-04 02:29:11 +01:00
|
|
|
} else {
|
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
|
|
|
gen_logic_cc(s, dest, opsize);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 1: /* andi */
|
2016-01-17 00:59:27 +01:00
|
|
|
tcg_gen_and_i32(dest, src1, im);
|
2018-01-04 02:29:11 +01:00
|
|
|
if (with_SR) {
|
|
|
|
gen_set_sr(s, dest, opsize == OS_BYTE);
|
2022-09-17 13:25:15 +02:00
|
|
|
gen_exit_tb(s);
|
2018-01-04 02:29:11 +01:00
|
|
|
} else {
|
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
|
|
|
gen_logic_cc(s, dest, opsize);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 2: /* subi */
|
2016-01-17 00:59:27 +01:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_X, src1, im);
|
|
|
|
tcg_gen_sub_i32(dest, src1, im);
|
|
|
|
gen_update_cc_add(dest, im, opsize);
|
|
|
|
set_cc_op(s, CC_OP_SUBB + opsize);
|
2018-01-04 02:29:11 +01:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 3: /* addi */
|
2016-01-17 00:59:27 +01:00
|
|
|
tcg_gen_add_i32(dest, src1, im);
|
|
|
|
gen_update_cc_add(dest, im, opsize);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_X, dest, im);
|
|
|
|
set_cc_op(s, CC_OP_ADDB + opsize);
|
2018-01-04 02:29:11 +01:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 5: /* eori */
|
2016-01-17 00:59:27 +01:00
|
|
|
tcg_gen_xor_i32(dest, src1, im);
|
2018-01-04 02:29:11 +01:00
|
|
|
if (with_SR) {
|
|
|
|
gen_set_sr(s, dest, opsize == OS_BYTE);
|
2022-09-17 13:25:15 +02:00
|
|
|
gen_exit_tb(s);
|
2018-01-04 02:29:11 +01:00
|
|
|
} else {
|
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
|
|
|
gen_logic_cc(s, dest, opsize);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 6: /* cmpi */
|
2016-01-17 00:59:27 +01:00
|
|
|
gen_update_cc_cmp(s, src1, im, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-11 01:33:26 +01:00
|
|
|
DISAS_INSN(cas)
|
|
|
|
{
|
|
|
|
int opsize;
|
|
|
|
TCGv addr;
|
|
|
|
uint16_t ext;
|
|
|
|
TCGv load;
|
|
|
|
TCGv cmp;
|
2019-08-23 20:10:58 +02:00
|
|
|
MemOp opc;
|
2016-01-11 01:33:26 +01:00
|
|
|
|
|
|
|
switch ((insn >> 9) & 3) {
|
|
|
|
case 1:
|
|
|
|
opsize = OS_BYTE;
|
|
|
|
opc = MO_SB;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
opsize = OS_WORD;
|
|
|
|
opc = MO_TESW;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
opsize = OS_LONG;
|
|
|
|
opc = MO_TESL;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
|
|
|
|
/* cas Dc,Du,<EA> */
|
|
|
|
|
|
|
|
addr = gen_lea(env, s, insn, opsize);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
cmp = gen_extend(s, DREG(ext, 0), opsize, 1);
|
2016-01-11 01:33:26 +01:00
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* if <EA> == Dc then
|
2016-01-11 01:33:26 +01:00
|
|
|
* <EA> = Du
|
|
|
|
* Dc = <EA> (because <EA> == Dc)
|
|
|
|
* else
|
|
|
|
* Dc = <EA>
|
|
|
|
*/
|
|
|
|
|
|
|
|
load = tcg_temp_new();
|
|
|
|
tcg_gen_atomic_cmpxchg_i32(load, addr, cmp, DREG(ext, 6),
|
|
|
|
IS_USER(s), opc);
|
|
|
|
/* update flags before setting cmp to load */
|
|
|
|
gen_update_cc_cmp(s, load, cmp, opsize);
|
|
|
|
gen_partset_reg(opsize, DREG(ext, 0), load);
|
|
|
|
|
2017-01-13 19:36:31 +01:00
|
|
|
switch (extract32(insn, 3, 3)) {
|
|
|
|
case 3: /* Indirect postincrement. */
|
|
|
|
tcg_gen_addi_i32(AREG(insn, 0), addr, opsize_bytes(opsize));
|
|
|
|
break;
|
|
|
|
case 4: /* Indirect predecrememnt. */
|
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), addr);
|
|
|
|
break;
|
|
|
|
}
|
2016-01-11 01:33:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(cas2w)
|
|
|
|
{
|
|
|
|
uint16_t ext1, ext2;
|
|
|
|
TCGv addr1, addr2;
|
|
|
|
|
|
|
|
/* cas2 Dc1:Dc2,Du1:Du2,(Rn1):(Rn2) */
|
|
|
|
|
|
|
|
ext1 = read_im16(env, s);
|
|
|
|
|
|
|
|
if (ext1 & 0x8000) {
|
|
|
|
/* Address Register */
|
|
|
|
addr1 = AREG(ext1, 12);
|
|
|
|
} else {
|
|
|
|
/* Data Register */
|
|
|
|
addr1 = DREG(ext1, 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
ext2 = read_im16(env, s);
|
|
|
|
if (ext2 & 0x8000) {
|
|
|
|
/* Address Register */
|
|
|
|
addr2 = AREG(ext2, 12);
|
|
|
|
} else {
|
|
|
|
/* Data Register */
|
|
|
|
addr2 = DREG(ext2, 12);
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* if (R1) == Dc1 && (R2) == Dc2 then
|
2016-01-11 01:33:26 +01:00
|
|
|
* (R1) = Du1
|
|
|
|
* (R2) = Du2
|
|
|
|
* else
|
|
|
|
* Dc1 = (R1)
|
|
|
|
* Dc2 = (R2)
|
|
|
|
*/
|
|
|
|
|
2018-05-12 07:02:47 +02:00
|
|
|
if (tb_cflags(s->base.tb) & CF_PARALLEL) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_exit_atomic(tcg_env);
|
2017-07-15 00:37:21 +02:00
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
TCGv regs = tcg_constant_i32(REG(ext2, 6) |
|
|
|
|
(REG(ext1, 6) << 3) |
|
|
|
|
(REG(ext2, 0) << 6) |
|
|
|
|
(REG(ext1, 0) << 9));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_cas2w(tcg_env, regs, addr1, addr2);
|
2017-07-15 00:37:21 +02:00
|
|
|
}
|
2016-01-11 01:33:26 +01:00
|
|
|
|
|
|
|
/* Note that cas2w also assigned to env->cc_op. */
|
|
|
|
s->cc_op = CC_OP_CMPW;
|
|
|
|
s->cc_op_synced = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(cas2l)
|
|
|
|
{
|
|
|
|
uint16_t ext1, ext2;
|
|
|
|
TCGv addr1, addr2, regs;
|
|
|
|
|
|
|
|
/* cas2 Dc1:Dc2,Du1:Du2,(Rn1):(Rn2) */
|
|
|
|
|
|
|
|
ext1 = read_im16(env, s);
|
|
|
|
|
|
|
|
if (ext1 & 0x8000) {
|
|
|
|
/* Address Register */
|
|
|
|
addr1 = AREG(ext1, 12);
|
|
|
|
} else {
|
|
|
|
/* Data Register */
|
|
|
|
addr1 = DREG(ext1, 12);
|
|
|
|
}
|
|
|
|
|
|
|
|
ext2 = read_im16(env, s);
|
|
|
|
if (ext2 & 0x8000) {
|
|
|
|
/* Address Register */
|
|
|
|
addr2 = AREG(ext2, 12);
|
|
|
|
} else {
|
|
|
|
/* Data Register */
|
|
|
|
addr2 = DREG(ext2, 12);
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* if (R1) == Dc1 && (R2) == Dc2 then
|
2016-01-11 01:33:26 +01:00
|
|
|
* (R1) = Du1
|
|
|
|
* (R2) = Du2
|
|
|
|
* else
|
|
|
|
* Dc1 = (R1)
|
|
|
|
* Dc2 = (R2)
|
|
|
|
*/
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
regs = tcg_constant_i32(REG(ext2, 6) |
|
|
|
|
(REG(ext1, 6) << 3) |
|
|
|
|
(REG(ext2, 0) << 6) |
|
|
|
|
(REG(ext1, 0) << 9));
|
2018-05-12 07:02:47 +02:00
|
|
|
if (tb_cflags(s->base.tb) & CF_PARALLEL) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_cas2l_parallel(tcg_env, regs, addr1, addr2);
|
2017-07-15 00:37:21 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_cas2l(tcg_env, regs, addr1, addr2);
|
2017-07-15 00:37:21 +02:00
|
|
|
}
|
2016-01-11 01:33:26 +01:00
|
|
|
|
|
|
|
/* Note that cas2l also assigned to env->cc_op. */
|
|
|
|
s->cc_op = CC_OP_CMPL;
|
|
|
|
s->cc_op_synced = 1;
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(byterev)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
reg = DREG(insn, 0);
|
2009-03-13 10:34:48 +01:00
|
|
|
tcg_gen_bswap32_i32(reg, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv dest;
|
2006-10-22 02:18:54 +02:00
|
|
|
int op;
|
|
|
|
int opsize;
|
|
|
|
|
|
|
|
switch (insn >> 12) {
|
|
|
|
case 1: /* move.b */
|
|
|
|
opsize = OS_BYTE;
|
|
|
|
break;
|
|
|
|
case 2: /* move.l */
|
|
|
|
opsize = OS_LONG;
|
|
|
|
break;
|
|
|
|
case 3: /* move.w */
|
|
|
|
opsize = OS_WORD;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src, opsize, 1, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
op = (insn >> 6) & 7;
|
|
|
|
if (op == 1) {
|
|
|
|
/* movea */
|
|
|
|
/* The value will already have been sign extended. */
|
|
|
|
dest = AREG(insn, 9);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(dest, src);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
|
|
|
/* normal move */
|
|
|
|
uint16_t dest_ea;
|
|
|
|
dest_ea = ((insn >> 9) & 7) | (op << 3);
|
2012-09-08 12:48:20 +02:00
|
|
|
DEST_EA(env, dest_ea, opsize, src, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
/* This will be correct because loads sign extend. */
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, src, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(negx)
|
|
|
|
{
|
2015-08-14 16:59:26 +02:00
|
|
|
TCGv z;
|
|
|
|
TCGv src;
|
|
|
|
TCGv addr;
|
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-08-14 16:59:26 +02:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
SRC_EA(env, src, opsize, 1, &addr);
|
|
|
|
|
|
|
|
gen_flush_flags(s); /* compute old Z */
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
2020-10-09 08:44:43 +02:00
|
|
|
* Perform subtract with borrow.
|
2015-08-14 16:59:26 +02:00
|
|
|
* (X, N) = -(src + X);
|
|
|
|
*/
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
z = tcg_constant_i32(0);
|
2015-08-14 16:59:26 +02:00
|
|
|
tcg_gen_add2_i32(QREG_CC_N, QREG_CC_X, src, z, QREG_CC_X, z);
|
|
|
|
tcg_gen_sub2_i32(QREG_CC_N, QREG_CC_X, z, z, QREG_CC_N, QREG_CC_X);
|
|
|
|
gen_ext(QREG_CC_N, QREG_CC_N, opsize, 1);
|
|
|
|
|
|
|
|
tcg_gen_andi_i32(QREG_CC_X, QREG_CC_X, 1);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Compute signed-overflow for negation. The normal formula for
|
2015-08-14 16:59:26 +02:00
|
|
|
* subtraction is (res ^ src) & (src ^ dest), but with dest==0
|
2020-10-09 08:44:43 +02:00
|
|
|
* this simplifies to res & src.
|
2015-08-14 16:59:26 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
tcg_gen_and_i32(QREG_CC_V, QREG_CC_N, src);
|
|
|
|
|
|
|
|
/* Copy the rest of the results into place. */
|
|
|
|
tcg_gen_or_i32(QREG_CC_Z, QREG_CC_Z, QREG_CC_N); /* !Z is sticky */
|
|
|
|
tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X);
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
|
|
|
|
/* result is in QREG_CC_N */
|
|
|
|
|
|
|
|
DEST_EA(env, insn, opsize, QREG_CC_N, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(lea)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
reg = AREG(insn, 9);
|
2012-09-08 12:48:20 +02:00
|
|
|
tmp = gen_lea(env, s, insn, OS_LONG);
|
2008-05-25 00:29:16 +02:00
|
|
|
if (IS_NULL_QREG(tmp)) {
|
2007-05-27 00:11:13 +02:00
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, tmp);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(clr)
|
|
|
|
{
|
|
|
|
int opsize;
|
2016-01-10 14:53:33 +01:00
|
|
|
TCGv zero;
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
zero = tcg_constant_i32(0);
|
2015-08-09 01:12:46 +02:00
|
|
|
opsize = insn_opsize(insn);
|
2016-01-10 14:53:33 +01:00
|
|
|
DEST_EA(env, insn, opsize, zero, NULL);
|
|
|
|
gen_logic_cc(s, zero, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2007-05-23 21:58:11 +02:00
|
|
|
DISAS_INSN(move_from_ccr)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv ccr;
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
ccr = gen_get_ccr(s);
|
2016-01-17 18:55:13 +01:00
|
|
|
DEST_EA(env, insn, OS_WORD, ccr, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(neg)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src1;
|
2016-01-16 23:13:23 +01:00
|
|
|
TCGv dest;
|
|
|
|
TCGv addr;
|
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-16 23:13:23 +01:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
SRC_EA(env, src1, opsize, 1, &addr);
|
|
|
|
dest = tcg_temp_new();
|
|
|
|
tcg_gen_neg_i32(dest, src1);
|
|
|
|
set_cc_op(s, CC_OP_SUBB + opsize);
|
|
|
|
gen_update_cc_add(dest, src1, opsize);
|
|
|
|
tcg_gen_setcondi_i32(TCG_COND_NE, QREG_CC_X, dest, 0);
|
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2007-05-23 21:58:11 +02:00
|
|
|
DISAS_INSN(move_to_ccr)
|
|
|
|
{
|
2018-01-04 02:29:10 +01:00
|
|
|
gen_move_to_sr(env, s, insn, true);
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(not)
|
|
|
|
{
|
2016-01-16 23:13:52 +01:00
|
|
|
TCGv src1;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv addr;
|
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-16 23:13:52 +01:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
SRC_EA(env, src1, opsize, 1, &addr);
|
|
|
|
dest = tcg_temp_new();
|
|
|
|
tcg_gen_not_i32(dest, src1);
|
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
|
|
|
gen_logic_cc(s, dest, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(swap)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src1;
|
|
|
|
TCGv src2;
|
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
src1 = tcg_temp_new();
|
|
|
|
src2 = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = DREG(insn, 0);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_shli_i32(src1, reg, 16);
|
|
|
|
tcg_gen_shri_i32(src2, reg, 16);
|
|
|
|
tcg_gen_or_i32(reg, src1, src2);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, reg, OS_LONG);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-17 01:13:07 +01:00
|
|
|
DISAS_INSN(bkpt)
|
|
|
|
{
|
2023-06-13 15:33:41 +02:00
|
|
|
#if defined(CONFIG_USER_ONLY)
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_DEBUG);
|
2023-06-13 15:33:41 +02:00
|
|
|
#else
|
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2023-01-26 13:52:34 +01:00
|
|
|
#endif
|
2016-01-17 01:13:07 +01:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(pea)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2012-09-08 12:48:20 +02:00
|
|
|
tmp = gen_lea(env, s, insn, OS_LONG);
|
2008-05-25 00:29:16 +02:00
|
|
|
if (IS_NULL_QREG(tmp)) {
|
2007-05-27 00:11:13 +02:00
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
2007-05-23 21:58:11 +02:00
|
|
|
gen_push(s, tmp);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(ext)
|
|
|
|
{
|
|
|
|
int op;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
reg = DREG(insn, 0);
|
|
|
|
op = (insn >> 6) & 7;
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
if (op == 3)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext16s_i32(tmp, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext8s_i32(tmp, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
if (op == 2)
|
|
|
|
gen_partset_reg(OS_WORD, reg, tmp);
|
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, tmp);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, tmp, OS_LONG);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(tst)
|
|
|
|
{
|
|
|
|
int opsize;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-08-09 01:12:46 +02:00
|
|
|
opsize = insn_opsize(insn);
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, tmp, opsize, 1, NULL);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, tmp, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(pulse)
|
|
|
|
{
|
|
|
|
/* Implemented as a NOP. */
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(illegal)
|
|
|
|
{
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(tas)
|
|
|
|
{
|
2022-08-29 07:17:46 +02:00
|
|
|
int mode = extract32(insn, 3, 3);
|
|
|
|
int reg0 = REG(insn, 0);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2022-08-29 07:17:46 +02:00
|
|
|
if (mode == 0) {
|
|
|
|
/* data register direct */
|
|
|
|
TCGv dest = cpu_dregs[reg0];
|
|
|
|
gen_logic_cc(s, dest, OS_BYTE);
|
|
|
|
tcg_gen_ori_tl(dest, dest, 0x80);
|
|
|
|
} else {
|
|
|
|
TCGv src1, addr;
|
|
|
|
|
|
|
|
addr = gen_lea_mode(env, s, mode, reg0, OS_BYTE);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
src1 = tcg_temp_new();
|
|
|
|
tcg_gen_atomic_fetch_or_tl(src1, addr, tcg_constant_tl(0x80),
|
|
|
|
IS_USER(s), MO_SB);
|
|
|
|
gen_logic_cc(s, src1, OS_BYTE);
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 3: /* Indirect postincrement. */
|
|
|
|
tcg_gen_addi_i32(AREG(insn, 0), addr, 1);
|
|
|
|
break;
|
|
|
|
case 4: /* Indirect predecrememnt. */
|
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), addr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(mull)
|
|
|
|
{
|
|
|
|
uint16_t ext;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src1;
|
2016-01-16 23:17:26 +01:00
|
|
|
int sign;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2016-01-16 23:17:26 +01:00
|
|
|
|
|
|
|
sign = ext & 0x800;
|
|
|
|
|
|
|
|
if (ext & 0x400) {
|
|
|
|
if (!m68k_feature(s->env, M68K_FEATURE_QUAD_MULDIV)) {
|
2018-10-30 17:55:54 +01:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2016-01-16 23:17:26 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SRC_EA(env, src1, OS_LONG, 0, NULL);
|
|
|
|
|
|
|
|
if (sign) {
|
|
|
|
tcg_gen_muls2_i32(QREG_CC_Z, QREG_CC_N, src1, DREG(ext, 12));
|
|
|
|
} else {
|
|
|
|
tcg_gen_mulu2_i32(QREG_CC_Z, QREG_CC_N, src1, DREG(ext, 12));
|
|
|
|
}
|
|
|
|
/* if Dl == Dh, 68040 returns low word */
|
|
|
|
tcg_gen_mov_i32(DREG(ext, 0), QREG_CC_N);
|
|
|
|
tcg_gen_mov_i32(DREG(ext, 12), QREG_CC_Z);
|
|
|
|
tcg_gen_or_i32(QREG_CC_Z, QREG_CC_Z, QREG_CC_N);
|
|
|
|
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_C, 0);
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2006-10-22 02:18:54 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src1, OS_LONG, 0, NULL);
|
2022-09-17 13:25:12 +02:00
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2016-01-16 23:17:26 +01:00
|
|
|
tcg_gen_movi_i32(QREG_CC_C, 0);
|
|
|
|
if (sign) {
|
|
|
|
tcg_gen_muls2_i32(QREG_CC_N, QREG_CC_V, src1, DREG(ext, 12));
|
|
|
|
/* QREG_CC_V is -(QREG_CC_V != (QREG_CC_N >> 31)) */
|
|
|
|
tcg_gen_sari_i32(QREG_CC_Z, QREG_CC_N, 31);
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(TCG_COND_NE, QREG_CC_V,
|
|
|
|
QREG_CC_V, QREG_CC_Z);
|
2016-01-16 23:17:26 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_mulu2_i32(QREG_CC_N, QREG_CC_V, src1, DREG(ext, 12));
|
|
|
|
/* QREG_CC_V is -(QREG_CC_V != 0), use QREG_CC_C as 0 */
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(TCG_COND_NE, QREG_CC_V,
|
|
|
|
QREG_CC_V, QREG_CC_C);
|
2016-01-16 23:17:26 +01:00
|
|
|
}
|
|
|
|
tcg_gen_mov_i32(DREG(ext, 12), QREG_CC_N);
|
|
|
|
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
} else {
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* The upper 32 bits of the product are discarded, so
|
|
|
|
* muls.l and mulu.l are functionally equivalent.
|
|
|
|
*/
|
2016-01-16 23:17:26 +01:00
|
|
|
tcg_gen_mul_i32(DREG(ext, 12), src1, DREG(ext, 12));
|
|
|
|
gen_logic_cc(s, DREG(ext, 12), OS_LONG);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-12 20:44:21 +01:00
|
|
|
static void gen_link(DisasContext *s, uint16_t insn, int32_t offset)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
reg = AREG(insn, 0);
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_subi_i32(tmp, QREG_SP, 4);
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, OS_LONG, tmp, reg, IS_USER(s));
|
2016-01-12 20:44:21 +01:00
|
|
|
if ((insn & 7) != 7) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, tmp);
|
2016-01-12 20:44:21 +01:00
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(QREG_SP, tmp, offset);
|
2016-01-12 20:44:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(link)
|
|
|
|
{
|
|
|
|
int16_t offset;
|
|
|
|
|
|
|
|
offset = read_im16(env, s);
|
|
|
|
gen_link(s, insn, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(linkl)
|
|
|
|
{
|
|
|
|
int32_t offset;
|
|
|
|
|
|
|
|
offset = read_im32(env, s);
|
|
|
|
gen_link(s, insn, offset);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(unlk)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
src = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = AREG(insn, 0);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(src, reg);
|
2018-01-18 20:38:43 +01:00
|
|
|
tmp = gen_load(s, OS_LONG, src, 0, IS_USER(s));
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, tmp);
|
|
|
|
tcg_gen_addi_i32(QREG_SP, src, 4);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2018-01-04 02:29:07 +01:00
|
|
|
DISAS_INSN(reset)
|
|
|
|
{
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_reset(tcg_env);
|
2018-01-04 02:29:07 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(nop)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-05 12:00:14 +02:00
|
|
|
DISAS_INSN(rtd)
|
|
|
|
{
|
|
|
|
TCGv tmp;
|
|
|
|
int16_t offset = read_im16(env, s);
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
tmp = gen_load(s, OS_LONG, QREG_SP, 0, IS_USER(s));
|
2017-06-05 12:00:14 +02:00
|
|
|
tcg_gen_addi_i32(QREG_SP, QREG_SP, offset + 4);
|
|
|
|
gen_jmp(s, tmp);
|
|
|
|
}
|
|
|
|
|
2021-03-07 22:25:52 +01:00
|
|
|
DISAS_INSN(rtr)
|
|
|
|
{
|
|
|
|
TCGv tmp;
|
|
|
|
TCGv ccr;
|
|
|
|
TCGv sp;
|
|
|
|
|
|
|
|
sp = tcg_temp_new();
|
|
|
|
ccr = gen_load(s, OS_WORD, QREG_SP, 0, IS_USER(s));
|
|
|
|
tcg_gen_addi_i32(sp, QREG_SP, 2);
|
|
|
|
tmp = gen_load(s, OS_LONG, sp, 0, IS_USER(s));
|
|
|
|
tcg_gen_addi_i32(QREG_SP, sp, 4);
|
|
|
|
|
|
|
|
gen_set_sr(s, ccr, true);
|
|
|
|
|
|
|
|
gen_jmp(s, tmp);
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(rts)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
tmp = gen_load(s, OS_LONG, QREG_SP, 0, IS_USER(s));
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(QREG_SP, QREG_SP, 4);
|
2006-10-22 02:18:54 +02:00
|
|
|
gen_jmp(s, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(jump)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Load the target address first to ensure correct exception
|
|
|
|
* behavior.
|
|
|
|
*/
|
2012-09-08 12:48:20 +02:00
|
|
|
tmp = gen_lea(env, s, insn, OS_LONG);
|
2008-05-25 00:29:16 +02:00
|
|
|
if (IS_NULL_QREG(tmp)) {
|
2007-05-27 00:11:13 +02:00
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
if ((insn & 0x40) == 0) {
|
|
|
|
/* jsr */
|
2023-02-26 02:39:06 +01:00
|
|
|
gen_push(s, tcg_constant_i32(s->pc));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
gen_jmp(s, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(addsubq)
|
|
|
|
{
|
2016-01-17 00:57:01 +01:00
|
|
|
TCGv src;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv dest;
|
2016-01-17 00:57:01 +01:00
|
|
|
TCGv val;
|
|
|
|
int imm;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv addr;
|
2016-01-17 00:57:01 +01:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-17 00:57:01 +01:00
|
|
|
if ((insn & 070) == 010) {
|
|
|
|
/* Operation on address register is always long. */
|
|
|
|
opsize = OS_LONG;
|
|
|
|
} else {
|
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
}
|
|
|
|
SRC_EA(env, src, opsize, 1, &addr);
|
|
|
|
imm = (insn >> 9) & 7;
|
|
|
|
if (imm == 0) {
|
|
|
|
imm = 8;
|
|
|
|
}
|
2023-02-26 02:39:06 +01:00
|
|
|
val = tcg_constant_i32(imm);
|
2008-11-17 15:43:54 +01:00
|
|
|
dest = tcg_temp_new();
|
2016-01-17 00:57:01 +01:00
|
|
|
tcg_gen_mov_i32(dest, src);
|
2006-10-22 02:18:54 +02:00
|
|
|
if ((insn & 0x38) == 0x08) {
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Don't update condition codes if the destination is an
|
|
|
|
* address register.
|
|
|
|
*/
|
2006-10-22 02:18:54 +02:00
|
|
|
if (insn & 0x0100) {
|
2016-01-17 00:57:01 +01:00
|
|
|
tcg_gen_sub_i32(dest, dest, val);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-01-17 00:57:01 +01:00
|
|
|
tcg_gen_add_i32(dest, dest, val);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (insn & 0x0100) {
|
2016-01-17 00:57:01 +01:00
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_X, dest, val);
|
|
|
|
tcg_gen_sub_i32(dest, dest, val);
|
|
|
|
set_cc_op(s, CC_OP_SUBB + opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-01-17 00:57:01 +01:00
|
|
|
tcg_gen_add_i32(dest, dest, val);
|
|
|
|
tcg_gen_setcond_i32(TCG_COND_LTU, QREG_CC_X, dest, val);
|
|
|
|
set_cc_op(s, CC_OP_ADDB + opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-01-17 00:57:01 +01:00
|
|
|
gen_update_cc_add(dest, val, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-01-17 00:57:01 +01:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(branch)
|
|
|
|
{
|
|
|
|
int32_t offset;
|
|
|
|
uint32_t base;
|
|
|
|
int op;
|
2007-09-17 10:09:54 +02:00
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
base = s->pc;
|
|
|
|
op = (insn >> 8) & 0xf;
|
|
|
|
offset = (int8_t)insn;
|
|
|
|
if (offset == 0) {
|
2015-06-24 02:28:59 +02:00
|
|
|
offset = (int16_t)read_im16(env, s);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else if (offset == -1) {
|
2012-09-08 12:48:20 +02:00
|
|
|
offset = read_im32(env, s);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
if (op == 1) {
|
|
|
|
/* bsr */
|
2023-02-26 02:39:06 +01:00
|
|
|
gen_push(s, tcg_constant_i32(s->pc));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
if (op > 1) {
|
|
|
|
/* Bcc */
|
2019-03-10 01:34:23 +01:00
|
|
|
TCGLabel *l1 = gen_new_label();
|
2006-10-22 02:18:54 +02:00
|
|
|
gen_jmpcc(s, ((insn >> 8) & 0xf) ^ 1, l1);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 1, base + offset, s->base.pc_next);
|
2006-10-22 02:18:54 +02:00
|
|
|
gen_set_label(l1);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 0, s->pc, s->base.pc_next);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
|
|
|
/* Unconditional branch. */
|
2018-01-04 02:28:57 +01:00
|
|
|
update_cc_op(s);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 0, base + offset, s->base.pc_next);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(moveq)
|
|
|
|
{
|
2016-01-10 14:53:33 +01:00
|
|
|
tcg_gen_movi_i32(DREG(insn, 9), (int8_t)insn);
|
|
|
|
gen_logic_cc(s, DREG(insn, 9), OS_LONG);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(mvzs)
|
|
|
|
{
|
|
|
|
int opsize;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
if (insn & 0x40)
|
|
|
|
opsize = OS_WORD;
|
|
|
|
else
|
|
|
|
opsize = OS_BYTE;
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src, opsize, (insn & 0x80) == 0, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = DREG(insn, 9);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, src);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, src, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(or)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv src;
|
|
|
|
TCGv addr;
|
2016-01-16 23:40:50 +01:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-16 23:40:50 +01:00
|
|
|
opsize = insn_opsize(insn);
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 9), opsize, 0);
|
2008-11-17 15:43:54 +01:00
|
|
|
dest = tcg_temp_new();
|
2006-10-22 02:18:54 +02:00
|
|
|
if (insn & 0x100) {
|
2016-01-16 23:40:50 +01:00
|
|
|
SRC_EA(env, src, opsize, 0, &addr);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_or_i32(dest, src, reg);
|
2016-01-16 23:40:50 +01:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-01-16 23:40:50 +01:00
|
|
|
SRC_EA(env, src, opsize, 0, NULL);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_or_i32(dest, src, reg);
|
2016-01-16 23:40:50 +01:00
|
|
|
gen_partset_reg(opsize, DREG(insn, 9), dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-01-16 23:40:50 +01:00
|
|
|
gen_logic_cc(s, dest, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(suba)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-16 23:33:43 +01:00
|
|
|
SRC_EA(env, src, (insn & 0x100) ? OS_LONG : OS_WORD, 1, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = AREG(insn, 9);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_sub_i32(reg, reg, src);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2015-08-14 16:59:26 +02:00
|
|
|
static inline void gen_subx(DisasContext *s, TCGv src, TCGv dest, int opsize)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2023-02-26 02:05:31 +01:00
|
|
|
TCGv tmp, zero;
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
gen_flush_flags(s); /* compute old Z */
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
2020-10-09 08:44:43 +02:00
|
|
|
* Perform subtract with borrow.
|
2015-08-14 16:59:26 +02:00
|
|
|
* (X, N) = dest - (src + X);
|
|
|
|
*/
|
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
zero = tcg_constant_i32(0);
|
|
|
|
tcg_gen_add2_i32(QREG_CC_N, QREG_CC_X, src, zero, QREG_CC_X, zero);
|
|
|
|
tcg_gen_sub2_i32(QREG_CC_N, QREG_CC_X, dest, zero, QREG_CC_N, QREG_CC_X);
|
2015-08-14 16:59:26 +02:00
|
|
|
gen_ext(QREG_CC_N, QREG_CC_N, opsize, 1);
|
|
|
|
tcg_gen_andi_i32(QREG_CC_X, QREG_CC_X, 1);
|
|
|
|
|
2020-10-09 08:44:43 +02:00
|
|
|
/* Compute signed-overflow for subtract. */
|
2015-08-14 16:59:26 +02:00
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
tmp = tcg_temp_new();
|
2015-08-14 16:59:26 +02:00
|
|
|
tcg_gen_xor_i32(QREG_CC_V, QREG_CC_N, dest);
|
|
|
|
tcg_gen_xor_i32(tmp, dest, src);
|
|
|
|
tcg_gen_and_i32(QREG_CC_V, QREG_CC_V, tmp);
|
|
|
|
|
|
|
|
/* Copy the rest of the results into place. */
|
|
|
|
tcg_gen_or_i32(QREG_CC_Z, QREG_CC_Z, QREG_CC_N); /* !Z is sticky */
|
|
|
|
tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X);
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
|
|
|
|
/* result is in QREG_CC_N */
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(subx_reg)
|
|
|
|
{
|
|
|
|
TCGv dest;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
2015-08-14 16:59:26 +02:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-08-14 16:59:26 +02:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
src = gen_extend(s, DREG(insn, 0), opsize, 1);
|
|
|
|
dest = gen_extend(s, DREG(insn, 9), opsize, 1);
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
gen_subx(s, src, dest, opsize);
|
|
|
|
|
|
|
|
gen_partset_reg(opsize, DREG(insn, 9), QREG_CC_N);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(subx_mem)
|
|
|
|
{
|
|
|
|
TCGv src;
|
|
|
|
TCGv addr_src;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv addr_dest;
|
|
|
|
int opsize;
|
|
|
|
|
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
|
|
|
|
addr_src = AREG(insn, 0);
|
2018-04-18 08:41:53 +02:00
|
|
|
tcg_gen_subi_i32(addr_src, addr_src, opsize_bytes(opsize));
|
2018-01-18 20:38:43 +01:00
|
|
|
src = gen_load(s, opsize, addr_src, 1, IS_USER(s));
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
addr_dest = AREG(insn, 9);
|
2018-04-18 08:41:53 +02:00
|
|
|
tcg_gen_subi_i32(addr_dest, addr_dest, opsize_bytes(opsize));
|
2018-01-18 20:38:43 +01:00
|
|
|
dest = gen_load(s, opsize, addr_dest, 1, IS_USER(s));
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
gen_subx(s, src, dest, opsize);
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, opsize, addr_dest, QREG_CC_N, IS_USER(s));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(mov3q)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
2006-10-22 02:18:54 +02:00
|
|
|
int val;
|
|
|
|
|
|
|
|
val = (insn >> 9) & 7;
|
2023-02-26 02:39:06 +01:00
|
|
|
if (val == 0) {
|
2006-10-22 02:18:54 +02:00
|
|
|
val = -1;
|
2023-02-26 02:39:06 +01:00
|
|
|
}
|
|
|
|
src = tcg_constant_i32(val);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, src, OS_LONG);
|
2012-09-08 12:48:20 +02:00
|
|
|
DEST_EA(env, insn, OS_LONG, src, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(cmp)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
int opsize;
|
|
|
|
|
2015-08-09 02:41:40 +02:00
|
|
|
opsize = insn_opsize(insn);
|
2016-01-17 14:34:09 +01:00
|
|
|
SRC_EA(env, src, opsize, 1, NULL);
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 9), opsize, 1);
|
2016-01-17 14:34:09 +01:00
|
|
|
gen_update_cc_cmp(s, reg, src, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(cmpa)
|
|
|
|
{
|
|
|
|
int opsize;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
if (insn & 0x100) {
|
|
|
|
opsize = OS_LONG;
|
|
|
|
} else {
|
|
|
|
opsize = OS_WORD;
|
|
|
|
}
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, src, opsize, 1, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = AREG(insn, 9);
|
2016-11-23 21:45:56 +01:00
|
|
|
gen_update_cc_cmp(s, reg, src, OS_LONG);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-11-03 21:50:03 +01:00
|
|
|
DISAS_INSN(cmpm)
|
|
|
|
{
|
|
|
|
int opsize = insn_opsize(insn);
|
|
|
|
TCGv src, dst;
|
|
|
|
|
|
|
|
/* Post-increment load (mode 3) from Ay. */
|
|
|
|
src = gen_ea_mode(env, s, 3, REG(insn, 0), opsize,
|
2018-01-18 20:38:43 +01:00
|
|
|
NULL_QREG, NULL, EA_LOADS, IS_USER(s));
|
2016-11-03 21:50:03 +01:00
|
|
|
/* Post-increment load (mode 3) from Ax. */
|
|
|
|
dst = gen_ea_mode(env, s, 3, REG(insn, 9), opsize,
|
2018-01-18 20:38:43 +01:00
|
|
|
NULL_QREG, NULL, EA_LOADS, IS_USER(s));
|
2016-11-03 21:50:03 +01:00
|
|
|
|
|
|
|
gen_update_cc_cmp(s, dst, src, opsize);
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(eor)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv addr;
|
2016-01-16 23:32:31 +01:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-16 23:32:31 +01:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
|
|
|
|
SRC_EA(env, src, opsize, 0, &addr);
|
2008-11-17 15:43:54 +01:00
|
|
|
dest = tcg_temp_new();
|
2016-01-16 23:32:31 +01:00
|
|
|
tcg_gen_xor_i32(dest, src, DREG(insn, 9));
|
|
|
|
gen_logic_cc(s, dest, opsize);
|
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-16 23:05:55 +01:00
|
|
|
static void do_exg(TCGv reg1, TCGv reg2)
|
|
|
|
{
|
|
|
|
TCGv temp = tcg_temp_new();
|
|
|
|
tcg_gen_mov_i32(temp, reg1);
|
|
|
|
tcg_gen_mov_i32(reg1, reg2);
|
|
|
|
tcg_gen_mov_i32(reg2, temp);
|
|
|
|
}
|
|
|
|
|
2016-11-23 13:57:56 +01:00
|
|
|
DISAS_INSN(exg_dd)
|
2016-01-16 23:05:55 +01:00
|
|
|
{
|
|
|
|
/* exchange Dx and Dy */
|
|
|
|
do_exg(DREG(insn, 9), DREG(insn, 0));
|
|
|
|
}
|
|
|
|
|
2016-11-23 13:57:56 +01:00
|
|
|
DISAS_INSN(exg_aa)
|
2016-01-16 23:05:55 +01:00
|
|
|
{
|
|
|
|
/* exchange Ax and Ay */
|
|
|
|
do_exg(AREG(insn, 9), AREG(insn, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(exg_da)
|
|
|
|
{
|
|
|
|
/* exchange Dx and Ay */
|
|
|
|
do_exg(DREG(insn, 9), AREG(insn, 0));
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(and)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv addr;
|
2016-01-16 23:38:08 +01:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
dest = tcg_temp_new();
|
2016-01-16 23:38:08 +01:00
|
|
|
|
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
reg = DREG(insn, 9);
|
2006-10-22 02:18:54 +02:00
|
|
|
if (insn & 0x100) {
|
2016-01-16 23:38:08 +01:00
|
|
|
SRC_EA(env, src, opsize, 0, &addr);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_and_i32(dest, src, reg);
|
2016-01-16 23:38:08 +01:00
|
|
|
DEST_EA(env, insn, opsize, dest, &addr);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-01-16 23:38:08 +01:00
|
|
|
SRC_EA(env, src, opsize, 0, NULL);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_and_i32(dest, src, reg);
|
2016-01-16 23:38:08 +01:00
|
|
|
gen_partset_reg(opsize, reg, dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-01-16 23:38:08 +01:00
|
|
|
gen_logic_cc(s, dest, opsize);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(adda)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
|
|
|
TCGv reg;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-01-16 23:33:43 +01:00
|
|
|
SRC_EA(env, src, (insn & 0x100) ? OS_LONG : OS_WORD, 1, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
reg = AREG(insn, 9);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_add_i32(reg, reg, src);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2015-08-14 16:59:26 +02:00
|
|
|
static inline void gen_addx(DisasContext *s, TCGv src, TCGv dest, int opsize)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2023-02-26 02:05:31 +01:00
|
|
|
TCGv tmp, zero;
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
gen_flush_flags(s); /* compute old Z */
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Perform addition with carry.
|
2015-08-14 16:59:26 +02:00
|
|
|
* (X, N) = src + dest + X;
|
|
|
|
*/
|
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
zero = tcg_constant_i32(0);
|
|
|
|
tcg_gen_add2_i32(QREG_CC_N, QREG_CC_X, QREG_CC_X, zero, dest, zero);
|
|
|
|
tcg_gen_add2_i32(QREG_CC_N, QREG_CC_X, QREG_CC_N, QREG_CC_X, src, zero);
|
2015-08-14 16:59:26 +02:00
|
|
|
gen_ext(QREG_CC_N, QREG_CC_N, opsize, 1);
|
|
|
|
|
|
|
|
/* Compute signed-overflow for addition. */
|
|
|
|
|
2023-02-26 02:05:31 +01:00
|
|
|
tmp = tcg_temp_new();
|
2015-08-14 16:59:26 +02:00
|
|
|
tcg_gen_xor_i32(QREG_CC_V, QREG_CC_N, src);
|
|
|
|
tcg_gen_xor_i32(tmp, dest, src);
|
|
|
|
tcg_gen_andc_i32(QREG_CC_V, QREG_CC_V, tmp);
|
|
|
|
|
|
|
|
/* Copy the rest of the results into place. */
|
|
|
|
tcg_gen_or_i32(QREG_CC_Z, QREG_CC_Z, QREG_CC_N); /* !Z is sticky */
|
|
|
|
tcg_gen_mov_i32(QREG_CC_C, QREG_CC_X);
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
|
|
|
|
/* result is in QREG_CC_N */
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(addx_reg)
|
|
|
|
{
|
|
|
|
TCGv dest;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv src;
|
2015-08-14 16:59:26 +02:00
|
|
|
int opsize;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-08-14 16:59:26 +02:00
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
dest = gen_extend(s, DREG(insn, 9), opsize, 1);
|
|
|
|
src = gen_extend(s, DREG(insn, 0), opsize, 1);
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
gen_addx(s, src, dest, opsize);
|
|
|
|
|
|
|
|
gen_partset_reg(opsize, DREG(insn, 9), QREG_CC_N);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(addx_mem)
|
|
|
|
{
|
|
|
|
TCGv src;
|
|
|
|
TCGv addr_src;
|
|
|
|
TCGv dest;
|
|
|
|
TCGv addr_dest;
|
|
|
|
int opsize;
|
|
|
|
|
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
|
|
|
|
addr_src = AREG(insn, 0);
|
|
|
|
tcg_gen_subi_i32(addr_src, addr_src, opsize_bytes(opsize));
|
2018-01-18 20:38:43 +01:00
|
|
|
src = gen_load(s, opsize, addr_src, 1, IS_USER(s));
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
addr_dest = AREG(insn, 9);
|
|
|
|
tcg_gen_subi_i32(addr_dest, addr_dest, opsize_bytes(opsize));
|
2018-01-18 20:38:43 +01:00
|
|
|
dest = gen_load(s, opsize, addr_dest, 1, IS_USER(s));
|
2015-08-14 16:59:26 +02:00
|
|
|
|
|
|
|
gen_addx(s, src, dest, opsize);
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
gen_store(s, opsize, addr_dest, QREG_CC_N, IS_USER(s));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:09 +01:00
|
|
|
static inline void shift_im(DisasContext *s, uint16_t insn, int opsize)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2016-11-09 14:46:09 +01:00
|
|
|
int count = (insn >> 9) & 7;
|
|
|
|
int logical = insn & 8;
|
|
|
|
int left = insn & 0x100;
|
|
|
|
int bits = opsize_bytes(opsize) * 8;
|
2018-03-19 12:35:43 +01:00
|
|
|
TCGv reg = gen_extend(s, DREG(insn, 0), opsize, !logical);
|
2016-11-09 14:46:09 +01:00
|
|
|
|
|
|
|
if (count == 0) {
|
|
|
|
count = 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0);
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_shri_i32(QREG_CC_C, reg, bits - count);
|
|
|
|
tcg_gen_shli_i32(QREG_CC_N, reg, count);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Note that ColdFire always clears V (done above),
|
|
|
|
* while M68000 sets if the most significant bit is changed at
|
|
|
|
* any time during the shift operation.
|
|
|
|
*/
|
2022-09-17 13:25:12 +02:00
|
|
|
if (!logical && m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2016-11-09 14:46:09 +01:00
|
|
|
/* if shift count >= bits, V is (reg != 0) */
|
|
|
|
if (count >= bits) {
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(TCG_COND_NE, QREG_CC_V, reg, QREG_CC_V);
|
2016-11-09 14:46:09 +01:00
|
|
|
} else {
|
|
|
|
TCGv t0 = tcg_temp_new();
|
|
|
|
tcg_gen_sari_i32(QREG_CC_V, reg, bits - 1);
|
|
|
|
tcg_gen_sari_i32(t0, reg, bits - count - 1);
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(TCG_COND_NE, QREG_CC_V, QREG_CC_V, t0);
|
2016-11-09 14:46:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tcg_gen_shri_i32(QREG_CC_C, reg, count - 1);
|
|
|
|
if (logical) {
|
|
|
|
tcg_gen_shri_i32(QREG_CC_N, reg, count);
|
|
|
|
} else {
|
|
|
|
tcg_gen_sari_i32(QREG_CC_N, reg, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_ext(QREG_CC_N, QREG_CC_N, opsize, 1);
|
|
|
|
tcg_gen_andi_i32(QREG_CC_C, QREG_CC_C, 1);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_X, QREG_CC_C);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-11-09 14:46:09 +01:00
|
|
|
gen_partset_reg(opsize, DREG(insn, 0), QREG_CC_N);
|
2015-08-14 16:59:20 +02:00
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2016-11-09 14:46:09 +01:00
|
|
|
}
|
2015-08-14 16:59:20 +02:00
|
|
|
|
2016-11-09 14:46:09 +01:00
|
|
|
static inline void shift_reg(DisasContext *s, uint16_t insn, int opsize)
|
|
|
|
{
|
|
|
|
int logical = insn & 8;
|
|
|
|
int left = insn & 0x100;
|
|
|
|
int bits = opsize_bytes(opsize) * 8;
|
2018-03-19 12:35:43 +01:00
|
|
|
TCGv reg = gen_extend(s, DREG(insn, 0), opsize, !logical);
|
2016-11-09 14:46:09 +01:00
|
|
|
TCGv s32;
|
|
|
|
TCGv_i64 t64, s64;
|
|
|
|
|
|
|
|
t64 = tcg_temp_new_i64();
|
|
|
|
s64 = tcg_temp_new_i64();
|
|
|
|
s32 = tcg_temp_new();
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Note that m68k truncates the shift count modulo 64, not 32.
|
|
|
|
* In addition, a 64-bit shift makes it easy to find "the last
|
|
|
|
* bit shifted out", for the carry flag.
|
|
|
|
*/
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_andi_i32(s32, DREG(insn, 9), 63);
|
|
|
|
tcg_gen_extu_i32_i64(s64, s32);
|
|
|
|
tcg_gen_extu_i32_i64(t64, reg);
|
|
|
|
|
|
|
|
/* Optimistically set V=0. Also used as a zero source below. */
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0);
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_shl_i64(t64, t64, s64);
|
|
|
|
|
|
|
|
if (opsize == OS_LONG) {
|
|
|
|
tcg_gen_extr_i64_i32(QREG_CC_N, QREG_CC_C, t64);
|
|
|
|
/* Note that C=0 if shift count is 0, and we get that for free. */
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
TCGv zero = tcg_constant_i32(0);
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_extrl_i64_i32(QREG_CC_N, t64);
|
|
|
|
tcg_gen_shri_i32(QREG_CC_C, QREG_CC_N, bits);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, QREG_CC_C,
|
|
|
|
s32, zero, zero, QREG_CC_C);
|
|
|
|
}
|
|
|
|
tcg_gen_andi_i32(QREG_CC_C, QREG_CC_C, 1);
|
|
|
|
|
|
|
|
/* X = C, but only if the shift count was non-zero. */
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, QREG_CC_X, s32, QREG_CC_V,
|
|
|
|
QREG_CC_C, QREG_CC_X);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* M68000 sets V if the most significant bit is changed at
|
2016-11-09 14:46:09 +01:00
|
|
|
* any time during the shift operation. Do this via creating
|
|
|
|
* an extension of the sign bit, comparing, and discarding
|
|
|
|
* the bits below the sign bit. I.e.
|
|
|
|
* int64_t s = (intN_t)reg;
|
|
|
|
* int64_t t = (int64_t)(intN_t)reg << count;
|
|
|
|
* V = ((s ^ t) & (-1 << (bits - 1))) != 0
|
|
|
|
*/
|
2022-09-17 13:25:12 +02:00
|
|
|
if (!logical && m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2023-02-26 02:39:06 +01:00
|
|
|
TCGv_i64 tt = tcg_constant_i64(32);
|
2016-11-09 14:46:09 +01:00
|
|
|
/* if shift is greater than 32, use 32 */
|
|
|
|
tcg_gen_movcond_i64(TCG_COND_GT, s64, s64, tt, tt, s64);
|
|
|
|
/* Sign extend the input to 64 bits; re-do the shift. */
|
|
|
|
tcg_gen_ext_i32_i64(t64, reg);
|
|
|
|
tcg_gen_shl_i64(s64, t64, s64);
|
|
|
|
/* Clear all bits that are unchanged. */
|
|
|
|
tcg_gen_xor_i64(t64, t64, s64);
|
|
|
|
/* Ignore the bits below the sign bit. */
|
|
|
|
tcg_gen_andi_i64(t64, t64, -1ULL << (bits - 1));
|
|
|
|
/* If any bits remain set, we have overflow. */
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i64(TCG_COND_NE, t64, t64, tcg_constant_i64(0));
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_extrl_i64_i32(QREG_CC_V, t64);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_shli_i64(t64, t64, 32);
|
|
|
|
if (logical) {
|
|
|
|
tcg_gen_shr_i64(t64, t64, s64);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_sar_i64(t64, t64, s64);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_extr_i64_i32(QREG_CC_C, QREG_CC_N, t64);
|
|
|
|
|
|
|
|
/* Note that C=0 if shift count is 0, and we get that for free. */
|
|
|
|
tcg_gen_shri_i32(QREG_CC_C, QREG_CC_C, 31);
|
|
|
|
|
|
|
|
/* X = C, but only if the shift count was non-zero. */
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_NE, QREG_CC_X, s32, QREG_CC_V,
|
|
|
|
QREG_CC_C, QREG_CC_X);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2016-11-09 14:46:09 +01:00
|
|
|
gen_ext(QREG_CC_N, QREG_CC_N, opsize, 1);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
|
|
|
|
/* Write back the result. */
|
|
|
|
gen_partset_reg(opsize, DREG(insn, 0), QREG_CC_N);
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(shift8_im)
|
|
|
|
{
|
|
|
|
shift_im(s, insn, OS_BYTE);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(shift16_im)
|
|
|
|
{
|
|
|
|
shift_im(s, insn, OS_WORD);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(shift_im)
|
|
|
|
{
|
|
|
|
shift_im(s, insn, OS_LONG);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(shift8_reg)
|
|
|
|
{
|
|
|
|
shift_reg(s, insn, OS_BYTE);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(shift16_reg)
|
|
|
|
{
|
|
|
|
shift_reg(s, insn, OS_WORD);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(shift_reg)
|
|
|
|
{
|
2016-11-09 14:46:09 +01:00
|
|
|
shift_reg(s, insn, OS_LONG);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2016-11-09 14:46:09 +01:00
|
|
|
DISAS_INSN(shift_mem)
|
|
|
|
{
|
|
|
|
int logical = insn & 8;
|
|
|
|
int left = insn & 0x100;
|
|
|
|
TCGv src;
|
|
|
|
TCGv addr;
|
|
|
|
|
|
|
|
SRC_EA(env, src, OS_WORD, !logical, &addr);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0);
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_shri_i32(QREG_CC_C, src, 15);
|
|
|
|
tcg_gen_shli_i32(QREG_CC_N, src, 1);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Note that ColdFire always clears V,
|
|
|
|
* while M68000 sets if the most significant bit is changed at
|
|
|
|
* any time during the shift operation
|
|
|
|
*/
|
2022-09-17 13:25:12 +02:00
|
|
|
if (!logical && m68k_feature(s->env, M68K_FEATURE_M68K)) {
|
2018-03-19 12:35:43 +01:00
|
|
|
src = gen_extend(s, src, OS_WORD, 1);
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_xor_i32(QREG_CC_V, QREG_CC_N, src);
|
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_mov_i32(QREG_CC_C, src);
|
|
|
|
if (logical) {
|
|
|
|
tcg_gen_shri_i32(QREG_CC_N, src, 1);
|
2006-10-22 02:18:54 +02:00
|
|
|
} else {
|
2016-11-09 14:46:09 +01:00
|
|
|
tcg_gen_sari_i32(QREG_CC_N, src, 1);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
}
|
2016-11-09 14:46:09 +01:00
|
|
|
|
|
|
|
gen_ext(QREG_CC_N, QREG_CC_N, OS_WORD, 1);
|
|
|
|
tcg_gen_andi_i32(QREG_CC_C, QREG_CC_C, 1);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, QREG_CC_N);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_X, QREG_CC_C);
|
|
|
|
|
|
|
|
DEST_EA(env, insn, OS_WORD, QREG_CC_N, &addr);
|
2015-08-14 16:59:20 +02:00
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2016-01-11 00:54:57 +01:00
|
|
|
static void rotate(TCGv reg, TCGv shift, int left, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 8:
|
|
|
|
/* Replicate the 8-bit input so that a 32-bit rotate works. */
|
|
|
|
tcg_gen_ext8u_i32(reg, reg);
|
|
|
|
tcg_gen_muli_i32(reg, reg, 0x01010101);
|
|
|
|
goto do_long;
|
|
|
|
case 16:
|
|
|
|
/* Replicate the 16-bit input so that a 32-bit rotate works. */
|
|
|
|
tcg_gen_deposit_i32(reg, reg, reg, 16, 16);
|
|
|
|
goto do_long;
|
|
|
|
do_long:
|
|
|
|
default:
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_rotl_i32(reg, reg, shift);
|
|
|
|
} else {
|
|
|
|
tcg_gen_rotr_i32(reg, reg, shift);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute flags */
|
|
|
|
|
|
|
|
switch (size) {
|
|
|
|
case 8:
|
|
|
|
tcg_gen_ext8s_i32(reg, reg);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
tcg_gen_ext16s_i32(reg, reg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* QREG_CC_X is not affected */
|
|
|
|
|
|
|
|
tcg_gen_mov_i32(QREG_CC_N, reg);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, reg);
|
|
|
|
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_andi_i32(QREG_CC_C, reg, 1);
|
|
|
|
} else {
|
|
|
|
tcg_gen_shri_i32(QREG_CC_C, reg, 31);
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0); /* always cleared */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rotate_x_flags(TCGv reg, TCGv X, int size)
|
|
|
|
{
|
|
|
|
switch (size) {
|
|
|
|
case 8:
|
|
|
|
tcg_gen_ext8s_i32(reg, reg);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
tcg_gen_ext16s_i32(reg, reg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tcg_gen_mov_i32(QREG_CC_N, reg);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_Z, reg);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_X, X);
|
|
|
|
tcg_gen_mov_i32(QREG_CC_C, X);
|
|
|
|
tcg_gen_movi_i32(QREG_CC_V, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Result of rotate_x() is valid if 0 <= shift <= size */
|
|
|
|
static TCGv rotate_x(TCGv reg, TCGv shift, int left, int size)
|
|
|
|
{
|
|
|
|
TCGv X, shl, shr, shx, sz, zero;
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
sz = tcg_constant_i32(size);
|
2016-01-11 00:54:57 +01:00
|
|
|
|
|
|
|
shr = tcg_temp_new();
|
|
|
|
shl = tcg_temp_new();
|
|
|
|
shx = tcg_temp_new();
|
|
|
|
if (left) {
|
|
|
|
tcg_gen_mov_i32(shl, shift); /* shl = shift */
|
|
|
|
tcg_gen_movi_i32(shr, size + 1);
|
|
|
|
tcg_gen_sub_i32(shr, shr, shift); /* shr = size + 1 - shift */
|
|
|
|
tcg_gen_subi_i32(shx, shift, 1); /* shx = shift - 1 */
|
|
|
|
/* shx = shx < 0 ? size : shx; */
|
2023-02-26 02:39:06 +01:00
|
|
|
zero = tcg_constant_i32(0);
|
2016-01-11 00:54:57 +01:00
|
|
|
tcg_gen_movcond_i32(TCG_COND_LT, shx, shx, zero, sz, shx);
|
|
|
|
} else {
|
|
|
|
tcg_gen_mov_i32(shr, shift); /* shr = shift */
|
|
|
|
tcg_gen_movi_i32(shl, size + 1);
|
|
|
|
tcg_gen_sub_i32(shl, shl, shift); /* shl = size + 1 - shift */
|
|
|
|
tcg_gen_sub_i32(shx, sz, shift); /* shx = size - shift */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reg = (reg << shl) | (reg >> shr) | (x << shx); */
|
|
|
|
|
|
|
|
tcg_gen_shl_i32(shl, reg, shl);
|
|
|
|
tcg_gen_shr_i32(shr, reg, shr);
|
|
|
|
tcg_gen_or_i32(reg, shl, shr);
|
|
|
|
tcg_gen_shl_i32(shx, QREG_CC_X, shx);
|
|
|
|
tcg_gen_or_i32(reg, reg, shx);
|
|
|
|
|
|
|
|
/* X = (reg >> size) & 1 */
|
|
|
|
|
|
|
|
X = tcg_temp_new();
|
2019-03-10 01:34:27 +01:00
|
|
|
tcg_gen_extract_i32(X, reg, size, 1);
|
2016-01-11 00:54:57 +01:00
|
|
|
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Result of rotate32_x() is valid if 0 <= shift < 33 */
|
|
|
|
static TCGv rotate32_x(TCGv reg, TCGv shift, int left)
|
|
|
|
{
|
|
|
|
TCGv_i64 t0, shift64;
|
|
|
|
TCGv X, lo, hi, zero;
|
|
|
|
|
|
|
|
shift64 = tcg_temp_new_i64();
|
|
|
|
tcg_gen_extu_i32_i64(shift64, shift);
|
|
|
|
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
X = tcg_temp_new();
|
|
|
|
lo = tcg_temp_new();
|
|
|
|
hi = tcg_temp_new();
|
|
|
|
|
|
|
|
if (left) {
|
|
|
|
/* create [reg:X:..] */
|
|
|
|
|
|
|
|
tcg_gen_shli_i32(lo, QREG_CC_X, 31);
|
|
|
|
tcg_gen_concat_i32_i64(t0, lo, reg);
|
|
|
|
|
|
|
|
/* rotate */
|
|
|
|
|
|
|
|
tcg_gen_rotl_i64(t0, t0, shift64);
|
|
|
|
|
|
|
|
/* result is [reg:..:reg:X] */
|
|
|
|
|
|
|
|
tcg_gen_extr_i64_i32(lo, hi, t0);
|
|
|
|
tcg_gen_andi_i32(X, lo, 1);
|
|
|
|
|
|
|
|
tcg_gen_shri_i32(lo, lo, 1);
|
|
|
|
} else {
|
|
|
|
/* create [..:X:reg] */
|
|
|
|
|
|
|
|
tcg_gen_concat_i32_i64(t0, reg, QREG_CC_X);
|
|
|
|
|
|
|
|
tcg_gen_rotr_i64(t0, t0, shift64);
|
|
|
|
|
|
|
|
/* result is value: [X:reg:..:reg] */
|
|
|
|
|
|
|
|
tcg_gen_extr_i64_i32(lo, hi, t0);
|
|
|
|
|
|
|
|
/* extract X */
|
|
|
|
|
|
|
|
tcg_gen_shri_i32(X, hi, 31);
|
|
|
|
|
|
|
|
/* extract result */
|
|
|
|
|
|
|
|
tcg_gen_shli_i32(hi, hi, 1);
|
|
|
|
}
|
|
|
|
tcg_gen_or_i32(lo, lo, hi);
|
|
|
|
|
|
|
|
/* if shift == 0, register and X are not affected */
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
zero = tcg_constant_i32(0);
|
2016-01-11 00:54:57 +01:00
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, X, shift, zero, QREG_CC_X, X);
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, reg, shift, zero, reg, lo);
|
|
|
|
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate_im)
|
|
|
|
{
|
|
|
|
TCGv shift;
|
|
|
|
int tmp;
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
|
|
|
|
tmp = (insn >> 9) & 7;
|
|
|
|
if (tmp == 0) {
|
|
|
|
tmp = 8;
|
|
|
|
}
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
shift = tcg_constant_i32(tmp);
|
2016-01-11 00:54:57 +01:00
|
|
|
if (insn & 8) {
|
|
|
|
rotate(DREG(insn, 0), shift, left, 32);
|
|
|
|
} else {
|
|
|
|
TCGv X = rotate32_x(DREG(insn, 0), shift, left);
|
|
|
|
rotate_x_flags(DREG(insn, 0), X, 32);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate8_im)
|
|
|
|
{
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
TCGv reg;
|
|
|
|
TCGv shift;
|
|
|
|
int tmp;
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 0), OS_BYTE, 0);
|
2016-01-11 00:54:57 +01:00
|
|
|
|
|
|
|
tmp = (insn >> 9) & 7;
|
|
|
|
if (tmp == 0) {
|
|
|
|
tmp = 8;
|
|
|
|
}
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
shift = tcg_constant_i32(tmp);
|
2016-01-11 00:54:57 +01:00
|
|
|
if (insn & 8) {
|
|
|
|
rotate(reg, shift, left, 8);
|
|
|
|
} else {
|
|
|
|
TCGv X = rotate_x(reg, shift, left, 8);
|
|
|
|
rotate_x_flags(reg, X, 8);
|
|
|
|
}
|
|
|
|
gen_partset_reg(OS_BYTE, DREG(insn, 0), reg);
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate16_im)
|
|
|
|
{
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
TCGv reg;
|
|
|
|
TCGv shift;
|
|
|
|
int tmp;
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 0), OS_WORD, 0);
|
2016-01-11 00:54:57 +01:00
|
|
|
tmp = (insn >> 9) & 7;
|
|
|
|
if (tmp == 0) {
|
|
|
|
tmp = 8;
|
|
|
|
}
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
shift = tcg_constant_i32(tmp);
|
2016-01-11 00:54:57 +01:00
|
|
|
if (insn & 8) {
|
|
|
|
rotate(reg, shift, left, 16);
|
|
|
|
} else {
|
|
|
|
TCGv X = rotate_x(reg, shift, left, 16);
|
|
|
|
rotate_x_flags(reg, X, 16);
|
|
|
|
}
|
|
|
|
gen_partset_reg(OS_WORD, DREG(insn, 0), reg);
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate_reg)
|
|
|
|
{
|
|
|
|
TCGv reg;
|
|
|
|
TCGv src;
|
|
|
|
TCGv t0, t1;
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
|
|
|
|
reg = DREG(insn, 0);
|
|
|
|
src = DREG(insn, 9);
|
|
|
|
/* shift in [0..63] */
|
|
|
|
t0 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(t0, src, 63);
|
|
|
|
t1 = tcg_temp_new_i32();
|
|
|
|
if (insn & 8) {
|
|
|
|
tcg_gen_andi_i32(t1, src, 31);
|
|
|
|
rotate(reg, t1, left, 32);
|
|
|
|
/* if shift == 0, clear C */
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, QREG_CC_C,
|
|
|
|
t0, QREG_CC_V /* 0 */,
|
|
|
|
QREG_CC_V /* 0 */, QREG_CC_C);
|
|
|
|
} else {
|
|
|
|
TCGv X;
|
|
|
|
/* modulo 33 */
|
|
|
|
tcg_gen_movi_i32(t1, 33);
|
|
|
|
tcg_gen_remu_i32(t1, t0, t1);
|
|
|
|
X = rotate32_x(DREG(insn, 0), t1, left);
|
|
|
|
rotate_x_flags(DREG(insn, 0), X, 32);
|
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate8_reg)
|
|
|
|
{
|
|
|
|
TCGv reg;
|
|
|
|
TCGv src;
|
|
|
|
TCGv t0, t1;
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 0), OS_BYTE, 0);
|
2016-01-11 00:54:57 +01:00
|
|
|
src = DREG(insn, 9);
|
|
|
|
/* shift in [0..63] */
|
|
|
|
t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_andi_i32(t0, src, 63);
|
|
|
|
t1 = tcg_temp_new_i32();
|
|
|
|
if (insn & 8) {
|
|
|
|
tcg_gen_andi_i32(t1, src, 7);
|
|
|
|
rotate(reg, t1, left, 8);
|
|
|
|
/* if shift == 0, clear C */
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, QREG_CC_C,
|
|
|
|
t0, QREG_CC_V /* 0 */,
|
|
|
|
QREG_CC_V /* 0 */, QREG_CC_C);
|
|
|
|
} else {
|
|
|
|
TCGv X;
|
|
|
|
/* modulo 9 */
|
|
|
|
tcg_gen_movi_i32(t1, 9);
|
|
|
|
tcg_gen_remu_i32(t1, t0, t1);
|
|
|
|
X = rotate_x(reg, t1, left, 8);
|
|
|
|
rotate_x_flags(reg, X, 8);
|
|
|
|
}
|
|
|
|
gen_partset_reg(OS_BYTE, DREG(insn, 0), reg);
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate16_reg)
|
|
|
|
{
|
|
|
|
TCGv reg;
|
|
|
|
TCGv src;
|
|
|
|
TCGv t0, t1;
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 0), OS_WORD, 0);
|
2016-01-11 00:54:57 +01:00
|
|
|
src = DREG(insn, 9);
|
|
|
|
/* shift in [0..63] */
|
|
|
|
t0 = tcg_temp_new_i32();
|
|
|
|
tcg_gen_andi_i32(t0, src, 63);
|
|
|
|
t1 = tcg_temp_new_i32();
|
|
|
|
if (insn & 8) {
|
|
|
|
tcg_gen_andi_i32(t1, src, 15);
|
|
|
|
rotate(reg, t1, left, 16);
|
|
|
|
/* if shift == 0, clear C */
|
|
|
|
tcg_gen_movcond_i32(TCG_COND_EQ, QREG_CC_C,
|
|
|
|
t0, QREG_CC_V /* 0 */,
|
|
|
|
QREG_CC_V /* 0 */, QREG_CC_C);
|
|
|
|
} else {
|
|
|
|
TCGv X;
|
|
|
|
/* modulo 17 */
|
|
|
|
tcg_gen_movi_i32(t1, 17);
|
|
|
|
tcg_gen_remu_i32(t1, t0, t1);
|
|
|
|
X = rotate_x(reg, t1, left, 16);
|
|
|
|
rotate_x_flags(reg, X, 16);
|
|
|
|
}
|
|
|
|
gen_partset_reg(OS_WORD, DREG(insn, 0), reg);
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rotate_mem)
|
|
|
|
{
|
|
|
|
TCGv src;
|
|
|
|
TCGv addr;
|
|
|
|
TCGv shift;
|
|
|
|
int left = (insn & 0x100);
|
|
|
|
|
|
|
|
SRC_EA(env, src, OS_WORD, 0, &addr);
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
shift = tcg_constant_i32(1);
|
2016-01-11 00:54:57 +01:00
|
|
|
if (insn & 0x0200) {
|
|
|
|
rotate(src, shift, left, 16);
|
|
|
|
} else {
|
|
|
|
TCGv X = rotate_x(src, shift, left, 16);
|
|
|
|
rotate_x_flags(src, X, 16);
|
|
|
|
}
|
|
|
|
DEST_EA(env, insn, OS_WORD, src, &addr);
|
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:10 +01:00
|
|
|
DISAS_INSN(bfext_reg)
|
|
|
|
{
|
|
|
|
int ext = read_im16(env, s);
|
|
|
|
int is_sign = insn & 0x200;
|
|
|
|
TCGv src = DREG(insn, 0);
|
|
|
|
TCGv dst = DREG(ext, 12);
|
|
|
|
int len = ((extract32(ext, 0, 5) - 1) & 31) + 1;
|
|
|
|
int ofs = extract32(ext, 6, 5); /* big bit-endian */
|
|
|
|
int pos = 32 - ofs - len; /* little bit-endian */
|
|
|
|
TCGv tmp = tcg_temp_new();
|
|
|
|
TCGv shift;
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* In general, we're going to rotate the field so that it's at the
|
|
|
|
* top of the word and then right-shift by the complement of the
|
|
|
|
* width to extend the field.
|
|
|
|
*/
|
2016-11-09 14:46:10 +01:00
|
|
|
if (ext & 0x20) {
|
|
|
|
/* Variable width. */
|
|
|
|
if (ext & 0x800) {
|
|
|
|
/* Variable offset. */
|
|
|
|
tcg_gen_andi_i32(tmp, DREG(ext, 6), 31);
|
|
|
|
tcg_gen_rotl_i32(tmp, src, tmp);
|
|
|
|
} else {
|
|
|
|
tcg_gen_rotli_i32(tmp, src, ofs);
|
|
|
|
}
|
|
|
|
|
|
|
|
shift = tcg_temp_new();
|
|
|
|
tcg_gen_neg_i32(shift, DREG(ext, 0));
|
|
|
|
tcg_gen_andi_i32(shift, shift, 31);
|
|
|
|
tcg_gen_sar_i32(QREG_CC_N, tmp, shift);
|
|
|
|
if (is_sign) {
|
|
|
|
tcg_gen_mov_i32(dst, QREG_CC_N);
|
|
|
|
} else {
|
|
|
|
tcg_gen_shr_i32(dst, tmp, shift);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Immediate width. */
|
|
|
|
if (ext & 0x800) {
|
|
|
|
/* Variable offset */
|
|
|
|
tcg_gen_andi_i32(tmp, DREG(ext, 6), 31);
|
|
|
|
tcg_gen_rotl_i32(tmp, src, tmp);
|
|
|
|
src = tmp;
|
|
|
|
pos = 32 - len;
|
|
|
|
} else {
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Immediate offset. If the field doesn't wrap around the
|
|
|
|
* end of the word, rely on (s)extract completely.
|
|
|
|
*/
|
2016-11-09 14:46:10 +01:00
|
|
|
if (pos < 0) {
|
|
|
|
tcg_gen_rotli_i32(tmp, src, ofs);
|
|
|
|
src = tmp;
|
|
|
|
pos = 32 - len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_sextract_i32(QREG_CC_N, src, pos, len);
|
|
|
|
if (is_sign) {
|
|
|
|
tcg_gen_mov_i32(dst, QREG_CC_N);
|
|
|
|
} else {
|
|
|
|
tcg_gen_extract_i32(dst, src, pos, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:11 +01:00
|
|
|
DISAS_INSN(bfext_mem)
|
|
|
|
{
|
|
|
|
int ext = read_im16(env, s);
|
|
|
|
int is_sign = insn & 0x200;
|
|
|
|
TCGv dest = DREG(ext, 12);
|
|
|
|
TCGv addr, len, ofs;
|
|
|
|
|
|
|
|
addr = gen_lea(env, s, insn, OS_UNSIZED);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext & 0x20) {
|
|
|
|
len = DREG(ext, 0);
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
len = tcg_constant_i32(extract32(ext, 0, 5));
|
2016-11-09 14:46:11 +01:00
|
|
|
}
|
|
|
|
if (ext & 0x800) {
|
|
|
|
ofs = DREG(ext, 6);
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
ofs = tcg_constant_i32(extract32(ext, 6, 5));
|
2016-11-09 14:46:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_sign) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfexts_mem(dest, tcg_env, addr, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
tcg_gen_mov_i32(QREG_CC_N, dest);
|
|
|
|
} else {
|
|
|
|
TCGv_i64 tmp = tcg_temp_new_i64();
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfextu_mem(tmp, tcg_env, addr, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
tcg_gen_extr_i64_i32(dest, QREG_CC_N, tmp);
|
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:10 +01:00
|
|
|
DISAS_INSN(bfop_reg)
|
|
|
|
{
|
|
|
|
int ext = read_im16(env, s);
|
|
|
|
TCGv src = DREG(insn, 0);
|
|
|
|
int len = ((extract32(ext, 0, 5) - 1) & 31) + 1;
|
|
|
|
int ofs = extract32(ext, 6, 5); /* big bit-endian */
|
2023-02-26 02:37:18 +01:00
|
|
|
TCGv mask, tofs = NULL, tlen = NULL;
|
|
|
|
bool is_bfffo = (insn & 0x0f00) == 0x0d00;
|
2016-11-09 14:46:10 +01:00
|
|
|
|
|
|
|
if ((ext & 0x820) == 0) {
|
|
|
|
/* Immediate width and offset. */
|
|
|
|
uint32_t maski = 0x7fffffffu >> (len - 1);
|
|
|
|
if (ofs + len <= 32) {
|
|
|
|
tcg_gen_shli_i32(QREG_CC_N, src, ofs);
|
|
|
|
} else {
|
|
|
|
tcg_gen_rotli_i32(QREG_CC_N, src, ofs);
|
|
|
|
}
|
|
|
|
tcg_gen_andi_i32(QREG_CC_N, QREG_CC_N, ~maski);
|
2023-02-26 02:37:18 +01:00
|
|
|
|
|
|
|
mask = tcg_constant_i32(ror32(maski, ofs));
|
|
|
|
if (is_bfffo) {
|
|
|
|
tofs = tcg_constant_i32(ofs);
|
|
|
|
tlen = tcg_constant_i32(len);
|
2016-11-15 21:44:29 +01:00
|
|
|
}
|
2016-11-09 14:46:10 +01:00
|
|
|
} else {
|
|
|
|
TCGv tmp = tcg_temp_new();
|
2023-02-26 02:37:18 +01:00
|
|
|
|
|
|
|
mask = tcg_temp_new();
|
2016-11-09 14:46:10 +01:00
|
|
|
if (ext & 0x20) {
|
|
|
|
/* Variable width */
|
|
|
|
tcg_gen_subi_i32(tmp, DREG(ext, 0), 1);
|
|
|
|
tcg_gen_andi_i32(tmp, tmp, 31);
|
2023-02-26 02:37:18 +01:00
|
|
|
tcg_gen_shr_i32(mask, tcg_constant_i32(0x7fffffffu), tmp);
|
|
|
|
if (is_bfffo) {
|
|
|
|
tlen = tcg_temp_new();
|
2016-11-15 21:44:29 +01:00
|
|
|
tcg_gen_addi_i32(tlen, tmp, 1);
|
|
|
|
}
|
2016-11-09 14:46:10 +01:00
|
|
|
} else {
|
|
|
|
/* Immediate width */
|
2023-02-26 02:37:18 +01:00
|
|
|
tcg_gen_movi_i32(mask, 0x7fffffffu >> (len - 1));
|
|
|
|
if (is_bfffo) {
|
|
|
|
tlen = tcg_constant_i32(len);
|
2016-11-15 21:44:29 +01:00
|
|
|
}
|
2016-11-09 14:46:10 +01:00
|
|
|
}
|
2023-02-26 02:37:18 +01:00
|
|
|
|
2016-11-09 14:46:10 +01:00
|
|
|
if (ext & 0x800) {
|
|
|
|
/* Variable offset */
|
|
|
|
tcg_gen_andi_i32(tmp, DREG(ext, 6), 31);
|
|
|
|
tcg_gen_rotl_i32(QREG_CC_N, src, tmp);
|
|
|
|
tcg_gen_andc_i32(QREG_CC_N, QREG_CC_N, mask);
|
|
|
|
tcg_gen_rotr_i32(mask, mask, tmp);
|
2023-02-26 02:37:18 +01:00
|
|
|
if (is_bfffo) {
|
|
|
|
tofs = tmp;
|
2016-11-15 21:44:29 +01:00
|
|
|
}
|
2016-11-09 14:46:10 +01:00
|
|
|
} else {
|
|
|
|
/* Immediate offset (and variable width) */
|
|
|
|
tcg_gen_rotli_i32(QREG_CC_N, src, ofs);
|
|
|
|
tcg_gen_andc_i32(QREG_CC_N, QREG_CC_N, mask);
|
|
|
|
tcg_gen_rotri_i32(mask, mask, ofs);
|
2023-02-26 02:37:18 +01:00
|
|
|
if (is_bfffo) {
|
|
|
|
tofs = tcg_constant_i32(ofs);
|
2016-11-15 21:44:29 +01:00
|
|
|
}
|
2016-11-09 14:46:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
|
|
|
|
|
|
|
switch (insn & 0x0f00) {
|
|
|
|
case 0x0a00: /* bfchg */
|
|
|
|
tcg_gen_eqv_i32(src, src, mask);
|
|
|
|
break;
|
|
|
|
case 0x0c00: /* bfclr */
|
|
|
|
tcg_gen_and_i32(src, src, mask);
|
|
|
|
break;
|
2016-11-15 21:44:29 +01:00
|
|
|
case 0x0d00: /* bfffo */
|
|
|
|
gen_helper_bfffo_reg(DREG(ext, 12), QREG_CC_N, tofs, tlen);
|
|
|
|
break;
|
2016-11-09 14:46:10 +01:00
|
|
|
case 0x0e00: /* bfset */
|
|
|
|
tcg_gen_orc_i32(src, src, mask);
|
|
|
|
break;
|
|
|
|
case 0x0800: /* bftst */
|
|
|
|
/* flags already set; no other work to do. */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:11 +01:00
|
|
|
DISAS_INSN(bfop_mem)
|
|
|
|
{
|
|
|
|
int ext = read_im16(env, s);
|
|
|
|
TCGv addr, len, ofs;
|
2016-11-15 21:44:29 +01:00
|
|
|
TCGv_i64 t64;
|
2016-11-09 14:46:11 +01:00
|
|
|
|
|
|
|
addr = gen_lea(env, s, insn, OS_UNSIZED);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext & 0x20) {
|
|
|
|
len = DREG(ext, 0);
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
len = tcg_constant_i32(extract32(ext, 0, 5));
|
2016-11-09 14:46:11 +01:00
|
|
|
}
|
|
|
|
if (ext & 0x800) {
|
|
|
|
ofs = DREG(ext, 6);
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
ofs = tcg_constant_i32(extract32(ext, 6, 5));
|
2016-11-09 14:46:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (insn & 0x0f00) {
|
|
|
|
case 0x0a00: /* bfchg */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfchg_mem(QREG_CC_N, tcg_env, addr, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
break;
|
|
|
|
case 0x0c00: /* bfclr */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfclr_mem(QREG_CC_N, tcg_env, addr, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
break;
|
2016-11-15 21:44:29 +01:00
|
|
|
case 0x0d00: /* bfffo */
|
|
|
|
t64 = tcg_temp_new_i64();
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfffo_mem(t64, tcg_env, addr, ofs, len);
|
2016-11-15 21:44:29 +01:00
|
|
|
tcg_gen_extr_i64_i32(DREG(ext, 12), QREG_CC_N, t64);
|
|
|
|
break;
|
2016-11-09 14:46:11 +01:00
|
|
|
case 0x0e00: /* bfset */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfset_mem(QREG_CC_N, tcg_env, addr, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
break;
|
|
|
|
case 0x0800: /* bftst */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfexts_mem(QREG_CC_N, tcg_env, addr, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:10 +01:00
|
|
|
DISAS_INSN(bfins_reg)
|
|
|
|
{
|
|
|
|
int ext = read_im16(env, s);
|
|
|
|
TCGv dst = DREG(insn, 0);
|
|
|
|
TCGv src = DREG(ext, 12);
|
|
|
|
int len = ((extract32(ext, 0, 5) - 1) & 31) + 1;
|
|
|
|
int ofs = extract32(ext, 6, 5); /* big bit-endian */
|
|
|
|
int pos = 32 - ofs - len; /* little bit-endian */
|
|
|
|
TCGv tmp;
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
|
|
|
|
if (ext & 0x20) {
|
|
|
|
/* Variable width */
|
|
|
|
tcg_gen_neg_i32(tmp, DREG(ext, 0));
|
|
|
|
tcg_gen_andi_i32(tmp, tmp, 31);
|
|
|
|
tcg_gen_shl_i32(QREG_CC_N, src, tmp);
|
|
|
|
} else {
|
|
|
|
/* Immediate width */
|
|
|
|
tcg_gen_shli_i32(QREG_CC_N, src, 32 - len);
|
|
|
|
}
|
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
|
|
|
|
|
|
|
/* Immediate width and offset */
|
|
|
|
if ((ext & 0x820) == 0) {
|
|
|
|
/* Check for suitability for deposit. */
|
|
|
|
if (pos >= 0) {
|
|
|
|
tcg_gen_deposit_i32(dst, dst, src, pos, len);
|
|
|
|
} else {
|
|
|
|
uint32_t maski = -2U << (len - 1);
|
|
|
|
uint32_t roti = (ofs + len) & 31;
|
|
|
|
tcg_gen_andi_i32(tmp, src, ~maski);
|
|
|
|
tcg_gen_rotri_i32(tmp, tmp, roti);
|
|
|
|
tcg_gen_andi_i32(dst, dst, ror32(maski, roti));
|
|
|
|
tcg_gen_or_i32(dst, dst, tmp);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TCGv mask = tcg_temp_new();
|
|
|
|
TCGv rot = tcg_temp_new();
|
|
|
|
|
|
|
|
if (ext & 0x20) {
|
|
|
|
/* Variable width */
|
|
|
|
tcg_gen_subi_i32(rot, DREG(ext, 0), 1);
|
|
|
|
tcg_gen_andi_i32(rot, rot, 31);
|
|
|
|
tcg_gen_movi_i32(mask, -2);
|
|
|
|
tcg_gen_shl_i32(mask, mask, rot);
|
|
|
|
tcg_gen_mov_i32(rot, DREG(ext, 0));
|
|
|
|
tcg_gen_andc_i32(tmp, src, mask);
|
|
|
|
} else {
|
|
|
|
/* Immediate width (variable offset) */
|
|
|
|
uint32_t maski = -2U << (len - 1);
|
|
|
|
tcg_gen_andi_i32(tmp, src, ~maski);
|
|
|
|
tcg_gen_movi_i32(mask, maski);
|
|
|
|
tcg_gen_movi_i32(rot, len & 31);
|
|
|
|
}
|
|
|
|
if (ext & 0x800) {
|
|
|
|
/* Variable offset */
|
|
|
|
tcg_gen_add_i32(rot, rot, DREG(ext, 6));
|
|
|
|
} else {
|
|
|
|
/* Immediate offset (variable width) */
|
|
|
|
tcg_gen_addi_i32(rot, rot, ofs);
|
|
|
|
}
|
|
|
|
tcg_gen_andi_i32(rot, rot, 31);
|
|
|
|
tcg_gen_rotr_i32(mask, mask, rot);
|
|
|
|
tcg_gen_rotr_i32(tmp, tmp, rot);
|
|
|
|
tcg_gen_and_i32(dst, dst, mask);
|
|
|
|
tcg_gen_or_i32(dst, dst, tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-09 14:46:11 +01:00
|
|
|
DISAS_INSN(bfins_mem)
|
|
|
|
{
|
|
|
|
int ext = read_im16(env, s);
|
|
|
|
TCGv src = DREG(ext, 12);
|
|
|
|
TCGv addr, len, ofs;
|
|
|
|
|
|
|
|
addr = gen_lea(env, s, insn, OS_UNSIZED);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext & 0x20) {
|
|
|
|
len = DREG(ext, 0);
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
len = tcg_constant_i32(extract32(ext, 0, 5));
|
2016-11-09 14:46:11 +01:00
|
|
|
}
|
|
|
|
if (ext & 0x800) {
|
|
|
|
ofs = DREG(ext, 6);
|
|
|
|
} else {
|
2023-02-26 02:39:06 +01:00
|
|
|
ofs = tcg_constant_i32(extract32(ext, 6, 5));
|
2016-11-09 14:46:11 +01:00
|
|
|
}
|
|
|
|
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_bfins_mem(QREG_CC_N, tcg_env, addr, src, ofs, len);
|
2016-11-09 14:46:11 +01:00
|
|
|
set_cc_op(s, CC_OP_LOGIC);
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(ff1)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2007-05-28 04:20:34 +02:00
|
|
|
reg = DREG(insn, 0);
|
2015-08-09 02:41:40 +02:00
|
|
|
gen_logic_cc(s, reg, OS_LONG);
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_helper_ff1(reg, reg);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-04 02:29:03 +01:00
|
|
|
DISAS_INSN(chk)
|
2007-05-23 21:58:11 +02:00
|
|
|
{
|
2018-01-04 02:29:03 +01:00
|
|
|
TCGv src, reg;
|
|
|
|
int opsize;
|
2007-05-23 21:58:11 +02:00
|
|
|
|
2018-01-04 02:29:03 +01:00
|
|
|
switch ((insn >> 7) & 3) {
|
|
|
|
case 3:
|
|
|
|
opsize = OS_WORD;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (m68k_feature(env, M68K_FEATURE_CHK2)) {
|
|
|
|
opsize = OS_LONG;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthru */
|
|
|
|
default:
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2018-01-04 02:29:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
SRC_EA(env, src, opsize, 1, NULL);
|
2018-03-19 12:35:43 +01:00
|
|
|
reg = gen_extend(s, DREG(insn, 9), opsize, 1);
|
2018-01-04 02:29:03 +01:00
|
|
|
|
|
|
|
gen_flush_flags(s);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_chk(tcg_env, reg, src);
|
2018-01-04 02:29:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(chk2)
|
|
|
|
{
|
|
|
|
uint16_t ext;
|
|
|
|
TCGv addr1, addr2, bound1, bound2, reg;
|
|
|
|
int opsize;
|
|
|
|
|
|
|
|
switch ((insn >> 9) & 3) {
|
|
|
|
case 0:
|
|
|
|
opsize = OS_BYTE;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
opsize = OS_WORD;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
opsize = OS_LONG;
|
|
|
|
break;
|
|
|
|
default:
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2018-01-04 02:29:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
if ((ext & 0x0800) == 0) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2018-01-04 02:29:03 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr1 = gen_lea(env, s, insn, OS_UNSIZED);
|
|
|
|
addr2 = tcg_temp_new();
|
|
|
|
tcg_gen_addi_i32(addr2, addr1, opsize_bytes(opsize));
|
|
|
|
|
2018-01-18 20:38:43 +01:00
|
|
|
bound1 = gen_load(s, opsize, addr1, 1, IS_USER(s));
|
|
|
|
bound2 = gen_load(s, opsize, addr2, 1, IS_USER(s));
|
2018-01-04 02:29:03 +01:00
|
|
|
|
|
|
|
reg = tcg_temp_new();
|
|
|
|
if (ext & 0x8000) {
|
|
|
|
tcg_gen_mov_i32(reg, AREG(ext, 12));
|
|
|
|
} else {
|
|
|
|
gen_ext(reg, DREG(ext, 12), opsize, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_flush_flags(s);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_chk2(tcg_env, reg, bound1, bound2);
|
2018-01-04 02:29:03 +01:00
|
|
|
}
|
|
|
|
|
2018-01-04 02:29:04 +01:00
|
|
|
static void m68k_copy_line(TCGv dst, TCGv src, int index)
|
|
|
|
{
|
|
|
|
TCGv addr;
|
|
|
|
TCGv_i64 t0, t1;
|
|
|
|
|
|
|
|
addr = tcg_temp_new();
|
|
|
|
|
|
|
|
t0 = tcg_temp_new_i64();
|
|
|
|
t1 = tcg_temp_new_i64();
|
|
|
|
|
|
|
|
tcg_gen_andi_i32(addr, src, ~15);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t0, addr, index, MO_TEUQ);
|
2018-01-04 02:29:04 +01:00
|
|
|
tcg_gen_addi_i32(addr, addr, 8);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_i64(t1, addr, index, MO_TEUQ);
|
2018-01-04 02:29:04 +01:00
|
|
|
|
|
|
|
tcg_gen_andi_i32(addr, dst, ~15);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_i64(t0, addr, index, MO_TEUQ);
|
2018-01-04 02:29:04 +01:00
|
|
|
tcg_gen_addi_i32(addr, addr, 8);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_i64(t1, addr, index, MO_TEUQ);
|
2018-01-04 02:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move16_reg)
|
|
|
|
{
|
|
|
|
int index = IS_USER(s);
|
|
|
|
TCGv tmp;
|
|
|
|
uint16_t ext;
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
if ((ext & (1 << 15)) == 0) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2018-01-04 02:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
m68k_copy_line(AREG(ext, 12), AREG(insn, 0), index);
|
|
|
|
|
|
|
|
/* Ax can be Ay, so save Ay before incrementing Ax */
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
tcg_gen_mov_i32(tmp, AREG(ext, 12));
|
|
|
|
tcg_gen_addi_i32(AREG(insn, 0), AREG(insn, 0), 16);
|
|
|
|
tcg_gen_addi_i32(AREG(ext, 12), tmp, 16);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move16_mem)
|
|
|
|
{
|
|
|
|
int index = IS_USER(s);
|
|
|
|
TCGv reg, addr;
|
|
|
|
|
|
|
|
reg = AREG(insn, 0);
|
2023-02-26 02:39:06 +01:00
|
|
|
addr = tcg_constant_i32(read_im32(env, s));
|
2018-01-04 02:29:04 +01:00
|
|
|
|
|
|
|
if ((insn >> 3) & 1) {
|
|
|
|
/* MOVE16 (xxx).L, (Ay) */
|
|
|
|
m68k_copy_line(reg, addr, index);
|
|
|
|
} else {
|
|
|
|
/* MOVE16 (Ay), (xxx).L */
|
|
|
|
m68k_copy_line(addr, reg, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((insn >> 3) & 2) == 0) {
|
|
|
|
/* (Ay)+ */
|
|
|
|
tcg_gen_addi_i32(reg, reg, 16);
|
|
|
|
}
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(strldsr)
|
|
|
|
{
|
|
|
|
uint16_t ext;
|
|
|
|
uint32_t addr;
|
|
|
|
|
|
|
|
addr = s->pc - 2;
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2007-05-23 21:58:11 +02:00
|
|
|
if (ext != 0x46FC) {
|
2018-10-30 17:55:54 +01:00
|
|
|
gen_exception(s, addr, EXCP_ILLEGAL);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s) || (ext & SR_S) == 0) {
|
2006-10-22 02:18:54 +02:00
|
|
|
gen_exception(s, addr, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
gen_push(s, gen_get_sr(s));
|
|
|
|
gen_set_sr_im(s, ext, 0);
|
2022-09-17 13:25:15 +02:00
|
|
|
gen_exit_tb(s);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move_from_sr)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv sr;
|
2007-05-23 21:58:11 +02:00
|
|
|
|
2022-09-25 15:48:04 +02:00
|
|
|
if (IS_USER(s) && m68k_feature(env, M68K_FEATURE_MOVEFROMSR_PRIV)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
sr = gen_get_sr(s);
|
2016-01-17 18:55:13 +01:00
|
|
|
DEST_EA(env, insn, OS_WORD, sr, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2018-01-18 20:38:44 +01:00
|
|
|
DISAS_INSN(moves)
|
|
|
|
{
|
|
|
|
int opsize;
|
|
|
|
uint16_t ext;
|
|
|
|
TCGv reg;
|
|
|
|
TCGv addr;
|
|
|
|
int extend;
|
|
|
|
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-18 20:38:44 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
|
|
|
|
opsize = insn_opsize(insn);
|
|
|
|
|
|
|
|
if (ext & 0x8000) {
|
|
|
|
/* address register */
|
|
|
|
reg = AREG(ext, 12);
|
|
|
|
extend = 1;
|
|
|
|
} else {
|
|
|
|
/* data register */
|
|
|
|
reg = DREG(ext, 12);
|
|
|
|
extend = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = gen_lea(env, s, insn, opsize);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext & 0x0800) {
|
|
|
|
/* from reg to ea */
|
|
|
|
gen_store(s, opsize, addr, reg, DFC_INDEX(s));
|
|
|
|
} else {
|
|
|
|
/* from ea to reg */
|
|
|
|
TCGv tmp = gen_load(s, opsize, addr, 0, SFC_INDEX(s));
|
|
|
|
if (extend) {
|
|
|
|
gen_ext(reg, tmp, opsize, 1);
|
|
|
|
} else {
|
|
|
|
gen_partset_reg(opsize, reg, tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (extract32(insn, 3, 3)) {
|
|
|
|
case 3: /* Indirect postincrement. */
|
|
|
|
tcg_gen_addi_i32(AREG(insn, 0), addr,
|
|
|
|
REG(insn, 0) == 7 && opsize == OS_BYTE
|
|
|
|
? 2
|
|
|
|
: opsize_bytes(opsize));
|
|
|
|
break;
|
|
|
|
case 4: /* Indirect predecrememnt. */
|
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), addr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(move_to_sr)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-01-04 02:29:10 +01:00
|
|
|
gen_move_to_sr(env, s, insn, false);
|
2018-05-12 07:02:46 +02:00
|
|
|
gen_exit_tb(s);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move_from_usp)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_ld_i32(AREG(insn, 0), tcg_env,
|
2015-06-19 15:43:25 +02:00
|
|
|
offsetof(CPUM68KState, sp[M68K_USP]));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move_to_usp)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_st_i32(AREG(insn, 0), tcg_env,
|
2015-06-19 15:43:25 +02:00
|
|
|
offsetof(CPUM68KState, sp[M68K_USP]));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(halt)
|
|
|
|
{
|
2018-01-04 02:29:05 +01:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_exception(s, s->pc, EXCP_HALT_INSN);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(stop)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
uint16_t ext;
|
|
|
|
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
gen_set_sr_im(s, ext, 0);
|
2013-01-17 18:51:17 +01:00
|
|
|
tcg_gen_movi_i32(cpu_halted, 1);
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_exception(s, s->pc, EXCP_HLT);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(rte)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_RTE);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-04 02:29:12 +01:00
|
|
|
DISAS_INSN(cf_movec)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
uint16_t ext;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2007-05-23 21:58:11 +02:00
|
|
|
|
|
|
|
if (ext & 0x8000) {
|
|
|
|
reg = AREG(ext, 12);
|
|
|
|
} else {
|
|
|
|
reg = DREG(ext, 12);
|
|
|
|
}
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_cf_movec_to(tcg_env, tcg_constant_i32(ext & 0xfff), reg);
|
2018-05-12 07:02:46 +02:00
|
|
|
gen_exit_tb(s);
|
2018-01-04 02:29:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(m68k_movec)
|
|
|
|
{
|
|
|
|
uint16_t ext;
|
2023-02-26 02:39:06 +01:00
|
|
|
TCGv reg, creg;
|
2018-01-04 02:29:12 +01:00
|
|
|
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:12 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
|
|
|
|
if (ext & 0x8000) {
|
|
|
|
reg = AREG(ext, 12);
|
|
|
|
} else {
|
|
|
|
reg = DREG(ext, 12);
|
|
|
|
}
|
2023-02-26 02:39:06 +01:00
|
|
|
creg = tcg_constant_i32(ext & 0xfff);
|
2018-01-04 02:29:12 +01:00
|
|
|
if (insn & 1) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_m68k_movec_to(tcg_env, creg, reg);
|
2018-01-04 02:29:12 +01:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_m68k_movec_from(reg, tcg_env, creg);
|
2018-01-04 02:29:12 +01:00
|
|
|
}
|
2018-05-12 07:02:46 +02:00
|
|
|
gen_exit_tb(s);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(intouch)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* ICache fetch. Implement as no-op. */
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(cpushl)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Cache push/invalidate. Implement as no-op. */
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2018-01-04 02:29:06 +01:00
|
|
|
DISAS_INSN(cpush)
|
|
|
|
{
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Cache push/invalidate. Implement as no-op. */
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(cinv)
|
|
|
|
{
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:06 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Invalidate cache line. Implement as no-op. */
|
|
|
|
}
|
|
|
|
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2018-01-18 20:38:45 +01:00
|
|
|
DISAS_INSN(pflush)
|
|
|
|
{
|
|
|
|
TCGv opmode;
|
|
|
|
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-18 20:38:45 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
opmode = tcg_constant_i32((insn >> 3) & 3);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_pflush(tcg_env, AREG(insn, 0), opmode);
|
2018-01-18 20:38:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(ptest)
|
|
|
|
{
|
|
|
|
TCGv is_read;
|
|
|
|
|
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-18 20:38:45 +01:00
|
|
|
return;
|
|
|
|
}
|
2023-02-26 02:39:06 +01:00
|
|
|
is_read = tcg_constant_i32((insn >> 5) & 1);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ptest(tcg_env, AREG(insn, 0), is_read);
|
2018-01-18 20:38:45 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(wddata)
|
|
|
|
{
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(wdebug)
|
|
|
|
{
|
2007-05-23 21:58:11 +02:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2007-05-23 21:58:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* TODO: Implement wdebug. */
|
2019-03-23 02:23:25 +01:00
|
|
|
cpu_abort(env_cpu(env), "WDEBUG not implemented");
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2018-01-04 02:29:05 +01:00
|
|
|
#endif
|
2006-10-22 02:18:54 +02:00
|
|
|
|
|
|
|
DISAS_INSN(trap)
|
|
|
|
{
|
2022-06-02 03:33:45 +02:00
|
|
|
gen_exception(s, s->pc, EXCP_TRAP0 + (insn & 0xf));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2022-06-02 03:33:54 +02:00
|
|
|
static void do_trapcc(DisasContext *s, DisasCompare *c)
|
|
|
|
{
|
|
|
|
if (c->tcond != TCG_COND_NEVER) {
|
|
|
|
TCGLabel *over = NULL;
|
|
|
|
|
|
|
|
update_cc_op(s);
|
|
|
|
|
|
|
|
if (c->tcond != TCG_COND_ALWAYS) {
|
|
|
|
/* Jump over if !c. */
|
|
|
|
over = gen_new_label();
|
|
|
|
tcg_gen_brcond_i32(tcg_invert_cond(c->tcond), c->v1, c->v2, over);
|
|
|
|
}
|
|
|
|
|
|
|
|
tcg_gen_movi_i32(QREG_PC, s->pc);
|
|
|
|
gen_raise_exception_format2(s, EXCP_TRAPCC, s->base.pc_next);
|
|
|
|
|
|
|
|
if (over != NULL) {
|
|
|
|
gen_set_label(over);
|
|
|
|
s->base.is_jmp = DISAS_NEXT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(trapcc)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
|
|
|
|
/* Consume and discard the immediate operand. */
|
|
|
|
switch (extract32(insn, 0, 3)) {
|
|
|
|
case 2: /* trapcc.w */
|
|
|
|
(void)read_im16(env, s);
|
|
|
|
break;
|
|
|
|
case 3: /* trapcc.l */
|
|
|
|
(void)read_im32(env, s);
|
|
|
|
break;
|
|
|
|
case 4: /* trapcc (no operand) */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* trapcc registered with only valid opmodes */
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_cc_cond(&c, s, extract32(insn, 8, 4));
|
|
|
|
do_trapcc(s, &c);
|
|
|
|
}
|
|
|
|
|
2022-06-02 03:33:56 +02:00
|
|
|
DISAS_INSN(trapv)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
|
|
|
|
gen_cc_cond(&c, s, 9); /* V set */
|
|
|
|
do_trapcc(s, &c);
|
|
|
|
}
|
|
|
|
|
2017-06-20 22:51:20 +02:00
|
|
|
static void gen_load_fcr(DisasContext *s, TCGv res, int reg)
|
|
|
|
{
|
|
|
|
switch (reg) {
|
|
|
|
case M68K_FPIAR:
|
|
|
|
tcg_gen_movi_i32(res, 0);
|
|
|
|
break;
|
|
|
|
case M68K_FPSR:
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_ld_i32(res, tcg_env, offsetof(CPUM68KState, fpsr));
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case M68K_FPCR:
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_ld_i32(res, tcg_env, offsetof(CPUM68KState, fpcr));
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_store_fcr(DisasContext *s, TCGv val, int reg)
|
|
|
|
{
|
|
|
|
switch (reg) {
|
|
|
|
case M68K_FPIAR:
|
|
|
|
break;
|
|
|
|
case M68K_FPSR:
|
2023-09-14 01:37:36 +02:00
|
|
|
tcg_gen_st_i32(val, tcg_env, offsetof(CPUM68KState, fpsr));
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case M68K_FPCR:
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_fpcr(tcg_env, val);
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_qemu_store_fcr(DisasContext *s, TCGv addr, int reg)
|
|
|
|
{
|
|
|
|
int index = IS_USER(s);
|
|
|
|
TCGv tmp;
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
gen_load_fcr(s, tmp, reg);
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_st_tl(tmp, addr, index, MO_TEUL);
|
2017-06-20 22:51:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_qemu_load_fcr(DisasContext *s, TCGv addr, int reg)
|
|
|
|
{
|
|
|
|
int index = IS_USER(s);
|
|
|
|
TCGv tmp;
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
2023-05-02 15:57:36 +02:00
|
|
|
tcg_gen_qemu_ld_tl(tmp, addr, index, MO_TEUL);
|
2017-06-20 22:51:20 +02:00
|
|
|
gen_store_fcr(s, tmp, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-20 22:51:16 +02:00
|
|
|
static void gen_op_fmove_fcr(CPUM68KState *env, DisasContext *s,
|
|
|
|
uint32_t insn, uint32_t ext)
|
|
|
|
{
|
|
|
|
int mask = (ext >> 10) & 7;
|
|
|
|
int is_write = (ext >> 13) & 1;
|
2017-06-20 22:51:20 +02:00
|
|
|
int mode = extract32(insn, 3, 3);
|
|
|
|
int i;
|
|
|
|
TCGv addr, tmp;
|
2017-06-20 22:51:16 +02:00
|
|
|
|
2017-06-20 22:51:20 +02:00
|
|
|
switch (mode) {
|
|
|
|
case 0: /* Dn */
|
|
|
|
if (mask != M68K_FPIAR && mask != M68K_FPSR && mask != M68K_FPCR) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2017-06-20 22:51:20 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-06-20 22:51:16 +02:00
|
|
|
if (is_write) {
|
2017-06-20 22:51:20 +02:00
|
|
|
gen_load_fcr(s, DREG(insn, 0), mask);
|
|
|
|
} else {
|
|
|
|
gen_store_fcr(s, DREG(insn, 0), mask);
|
2017-06-20 22:51:16 +02:00
|
|
|
}
|
2017-06-20 22:51:20 +02:00
|
|
|
return;
|
|
|
|
case 1: /* An, only with FPIAR */
|
|
|
|
if (mask != M68K_FPIAR) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
2017-06-20 22:51:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (is_write) {
|
|
|
|
gen_load_fcr(s, AREG(insn, 0), mask);
|
|
|
|
} else {
|
|
|
|
gen_store_fcr(s, AREG(insn, 0), mask);
|
|
|
|
}
|
|
|
|
return;
|
2020-05-31 13:02:31 +02:00
|
|
|
case 7: /* Immediate */
|
|
|
|
if (REG(insn, 0) == 4) {
|
|
|
|
if (is_write ||
|
|
|
|
(mask != M68K_FPIAR && mask != M68K_FPSR &&
|
|
|
|
mask != M68K_FPCR)) {
|
|
|
|
gen_exception(s, s->base.pc_next, EXCP_ILLEGAL);
|
|
|
|
return;
|
|
|
|
}
|
2023-02-26 02:39:06 +01:00
|
|
|
tmp = tcg_constant_i32(read_im32(env, s));
|
2020-05-31 13:02:31 +02:00
|
|
|
gen_store_fcr(s, tmp, mask);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
default:
|
2017-06-20 22:51:16 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-06-20 22:51:20 +02:00
|
|
|
|
|
|
|
tmp = gen_lea(env, s, insn, OS_LONG);
|
|
|
|
if (IS_NULL_QREG(tmp)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = tcg_temp_new();
|
|
|
|
tcg_gen_mov_i32(addr, tmp);
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* mask:
|
2017-06-20 22:51:20 +02:00
|
|
|
*
|
|
|
|
* 0b100 Floating-Point Control Register
|
|
|
|
* 0b010 Floating-Point Status Register
|
|
|
|
* 0b001 Floating-Point Instruction Address Register
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (is_write && mode == 4) {
|
|
|
|
for (i = 2; i >= 0; i--, mask >>= 1) {
|
|
|
|
if (mask & 1) {
|
|
|
|
gen_qemu_store_fcr(s, addr, 1 << i);
|
|
|
|
if (mask != 1) {
|
|
|
|
tcg_gen_subi_i32(addr, addr, opsize_bytes(OS_LONG));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), addr);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < 3; i++, mask >>= 1) {
|
|
|
|
if (mask & 1) {
|
|
|
|
if (is_write) {
|
|
|
|
gen_qemu_store_fcr(s, addr, 1 << i);
|
|
|
|
} else {
|
|
|
|
gen_qemu_load_fcr(s, addr, 1 << i);
|
|
|
|
}
|
|
|
|
if (mask != 1 || mode == 3) {
|
|
|
|
tcg_gen_addi_i32(addr, addr, opsize_bytes(OS_LONG));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mode == 3) {
|
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), addr);
|
|
|
|
}
|
|
|
|
}
|
2017-06-20 22:51:16 +02:00
|
|
|
}
|
|
|
|
|
2017-06-28 22:42:41 +02:00
|
|
|
static void gen_op_fmovem(CPUM68KState *env, DisasContext *s,
|
|
|
|
uint32_t insn, uint32_t ext)
|
|
|
|
{
|
|
|
|
int opsize;
|
|
|
|
TCGv addr, tmp;
|
|
|
|
int mode = (ext >> 11) & 0x3;
|
|
|
|
int is_load = ((ext & 0x2000) == 0);
|
|
|
|
|
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_FPU)) {
|
|
|
|
opsize = OS_EXTENDED;
|
|
|
|
} else {
|
|
|
|
opsize = OS_DOUBLE; /* FIXME */
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = gen_lea(env, s, insn, opsize);
|
|
|
|
if (IS_NULL_QREG(addr)) {
|
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
|
|
|
if (mode & 0x1) {
|
|
|
|
/* Dynamic register list */
|
|
|
|
tcg_gen_ext8u_i32(tmp, DREG(ext, 4));
|
|
|
|
} else {
|
|
|
|
/* Static register list */
|
|
|
|
tcg_gen_movi_i32(tmp, ext & 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_load && (mode & 2) == 0) {
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* predecrement addressing mode
|
2017-06-28 22:42:41 +02:00
|
|
|
* only available to store register to memory
|
|
|
|
*/
|
|
|
|
if (opsize == OS_EXTENDED) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmovemx_st_predec(tmp, tcg_env, addr, tmp);
|
2017-06-28 22:42:41 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmovemd_st_predec(tmp, tcg_env, addr, tmp);
|
2017-06-28 22:42:41 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* postincrement addressing mode */
|
|
|
|
if (opsize == OS_EXTENDED) {
|
|
|
|
if (is_load) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmovemx_ld_postinc(tmp, tcg_env, addr, tmp);
|
2017-06-28 22:42:41 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmovemx_st_postinc(tmp, tcg_env, addr, tmp);
|
2017-06-28 22:42:41 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (is_load) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmovemd_ld_postinc(tmp, tcg_env, addr, tmp);
|
2017-06-28 22:42:41 +02:00
|
|
|
} else {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmovemd_st_postinc(tmp, tcg_env, addr, tmp);
|
2017-06-28 22:42:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((insn & 070) == 030 || (insn & 070) == 040) {
|
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* ??? FP exceptions are not implemented. Most exceptions are deferred until
|
|
|
|
* immediately before the next FP instruction is executed.
|
|
|
|
*/
|
2006-10-22 02:18:54 +02:00
|
|
|
DISAS_INSN(fpu)
|
|
|
|
{
|
|
|
|
uint16_t ext;
|
|
|
|
int opmode;
|
|
|
|
int opsize;
|
2017-06-20 22:51:18 +02:00
|
|
|
TCGv_ptr cpu_src, cpu_dest;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2006-10-22 02:18:54 +02:00
|
|
|
opmode = ext & 0x7f;
|
|
|
|
switch ((ext >> 13) & 7) {
|
2017-06-28 22:42:36 +02:00
|
|
|
case 0:
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
goto undef;
|
2017-06-28 22:42:36 +02:00
|
|
|
case 2:
|
|
|
|
if (insn == 0xf200 && (ext & 0xfc00) == 0x5c00) {
|
|
|
|
/* fmovecr */
|
2023-02-26 02:39:06 +01:00
|
|
|
TCGv rom_offset = tcg_constant_i32(opmode);
|
2017-06-28 22:42:36 +02:00
|
|
|
cpu_dest = gen_fp_ptr(REG(ext, 7));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fconst(tcg_env, cpu_dest, rom_offset);
|
2017-06-28 22:42:36 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
break;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 3: /* fmove out */
|
2017-06-20 22:51:18 +02:00
|
|
|
cpu_src = gen_fp_ptr(REG(ext, 7));
|
2017-06-12 01:16:29 +02:00
|
|
|
opsize = ext_opsize(ext, 10);
|
2018-01-18 20:38:43 +01:00
|
|
|
if (gen_ea_fp(env, s, insn, opsize, cpu_src,
|
|
|
|
EA_STORE, IS_USER(s)) == -1) {
|
2017-06-20 22:51:18 +02:00
|
|
|
gen_addr_fault(s);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftst(tcg_env, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
return;
|
|
|
|
case 4: /* fmove to control register. */
|
|
|
|
case 5: /* fmove from control register. */
|
2017-06-20 22:51:16 +02:00
|
|
|
gen_op_fmove_fcr(env, s, insn, ext);
|
|
|
|
return;
|
2007-09-16 23:08:06 +02:00
|
|
|
case 6: /* fmovem */
|
2006-10-22 02:18:54 +02:00
|
|
|
case 7:
|
2017-06-28 22:42:41 +02:00
|
|
|
if ((ext & 0x1000) == 0 && !m68k_feature(s->env, M68K_FEATURE_FPU)) {
|
|
|
|
goto undef;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2017-06-28 22:42:41 +02:00
|
|
|
gen_op_fmovem(env, s, insn, ext);
|
2006-10-22 02:18:54 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ext & (1 << 14)) {
|
|
|
|
/* Source effective address. */
|
2017-06-12 01:16:29 +02:00
|
|
|
opsize = ext_opsize(ext, 10);
|
2017-06-20 22:51:18 +02:00
|
|
|
cpu_src = gen_fp_result_ptr();
|
2018-01-18 20:38:43 +01:00
|
|
|
if (gen_ea_fp(env, s, insn, opsize, cpu_src,
|
|
|
|
EA_LOADS, IS_USER(s)) == -1) {
|
2017-06-20 22:51:18 +02:00
|
|
|
gen_addr_fault(s);
|
|
|
|
return;
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Source register. */
|
2017-06-20 22:51:18 +02:00
|
|
|
opsize = OS_EXTENDED;
|
|
|
|
cpu_src = gen_fp_ptr(REG(ext, 10));
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2017-06-20 22:51:18 +02:00
|
|
|
cpu_dest = gen_fp_ptr(REG(ext, 7));
|
2006-10-22 02:18:54 +02:00
|
|
|
switch (opmode) {
|
2017-06-28 22:42:40 +02:00
|
|
|
case 0: /* fmove */
|
2017-06-20 22:51:18 +02:00
|
|
|
gen_fp_move(cpu_dest, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:40 +02:00
|
|
|
case 0x40: /* fsmove */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsround(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:40 +02:00
|
|
|
break;
|
|
|
|
case 0x44: /* fdmove */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdround(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:40 +02:00
|
|
|
break;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 1: /* fint */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_firound(tcg_env, cpu_dest, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2018-03-12 21:27:27 +01:00
|
|
|
case 2: /* fsinh */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsinh(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:27 +01:00
|
|
|
break;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 3: /* fintrz */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fitrunc(tcg_env, cpu_dest, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 4: /* fsqrt */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsqrt(tcg_env, cpu_dest, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x41: /* fssqrt */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fssqrt(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
|
|
|
case 0x45: /* fdsqrt */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdsqrt(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
2018-03-05 21:39:04 +01:00
|
|
|
case 0x06: /* flognp1 */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_flognp1(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:04 +01:00
|
|
|
break;
|
2020-05-31 15:19:51 +02:00
|
|
|
case 0x08: /* fetoxm1 */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fetoxm1(tcg_env, cpu_dest, cpu_src);
|
2020-05-31 15:19:51 +02:00
|
|
|
break;
|
2018-03-12 21:27:26 +01:00
|
|
|
case 0x09: /* ftanh */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftanh(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:26 +01:00
|
|
|
break;
|
2018-03-12 21:27:22 +01:00
|
|
|
case 0x0a: /* fatan */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fatan(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:22 +01:00
|
|
|
break;
|
2018-03-12 21:27:23 +01:00
|
|
|
case 0x0c: /* fasin */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fasin(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:23 +01:00
|
|
|
break;
|
2018-03-12 21:27:25 +01:00
|
|
|
case 0x0d: /* fatanh */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fatanh(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:25 +01:00
|
|
|
break;
|
2018-03-12 21:27:19 +01:00
|
|
|
case 0x0e: /* fsin */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsin(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:19 +01:00
|
|
|
break;
|
2018-03-12 21:27:18 +01:00
|
|
|
case 0x0f: /* ftan */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftan(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:18 +01:00
|
|
|
break;
|
2018-03-05 21:39:08 +01:00
|
|
|
case 0x10: /* fetox */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fetox(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:08 +01:00
|
|
|
break;
|
2018-03-05 21:39:09 +01:00
|
|
|
case 0x11: /* ftwotox */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftwotox(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:09 +01:00
|
|
|
break;
|
2018-03-05 21:39:10 +01:00
|
|
|
case 0x12: /* ftentox */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftentox(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:10 +01:00
|
|
|
break;
|
2018-03-05 21:39:05 +01:00
|
|
|
case 0x14: /* flogn */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_flogn(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:05 +01:00
|
|
|
break;
|
2018-03-05 21:39:06 +01:00
|
|
|
case 0x15: /* flog10 */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_flog10(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:06 +01:00
|
|
|
break;
|
2018-03-05 21:39:07 +01:00
|
|
|
case 0x16: /* flog2 */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_flog2(tcg_env, cpu_dest, cpu_src);
|
2018-03-05 21:39:07 +01:00
|
|
|
break;
|
2017-06-28 22:42:40 +02:00
|
|
|
case 0x18: /* fabs */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fabs(tcg_env, cpu_dest, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:40 +02:00
|
|
|
case 0x58: /* fsabs */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsabs(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:40 +02:00
|
|
|
break;
|
|
|
|
case 0x5c: /* fdabs */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdabs(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:40 +02:00
|
|
|
break;
|
2018-03-12 21:27:28 +01:00
|
|
|
case 0x19: /* fcosh */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fcosh(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:28 +01:00
|
|
|
break;
|
2017-06-28 22:42:40 +02:00
|
|
|
case 0x1a: /* fneg */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fneg(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:40 +02:00
|
|
|
break;
|
|
|
|
case 0x5a: /* fsneg */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsneg(tcg_env, cpu_dest, cpu_src);
|
2017-06-28 22:42:40 +02:00
|
|
|
break;
|
|
|
|
case 0x5e: /* fdneg */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdneg(tcg_env, cpu_dest, cpu_src);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2018-03-12 21:27:24 +01:00
|
|
|
case 0x1c: /* facos */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_facos(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:24 +01:00
|
|
|
break;
|
2018-03-12 21:27:20 +01:00
|
|
|
case 0x1d: /* fcos */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fcos(tcg_env, cpu_dest, cpu_src);
|
2018-03-12 21:27:20 +01:00
|
|
|
break;
|
2018-02-24 21:18:02 +01:00
|
|
|
case 0x1e: /* fgetexp */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fgetexp(tcg_env, cpu_dest, cpu_src);
|
2018-02-24 21:18:02 +01:00
|
|
|
break;
|
|
|
|
case 0x1f: /* fgetman */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fgetman(tcg_env, cpu_dest, cpu_src);
|
2018-02-24 21:18:02 +01:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x20: /* fdiv */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdiv(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x60: /* fsdiv */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsdiv(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
|
|
|
case 0x64: /* fddiv */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fddiv(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
2018-02-24 21:18:00 +01:00
|
|
|
case 0x21: /* fmod */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmod(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2018-02-24 21:18:00 +01:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x22: /* fadd */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fadd(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x62: /* fsadd */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsadd(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
|
|
|
case 0x66: /* fdadd */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdadd(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
|
|
|
case 0x23: /* fmul */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fmul(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x63: /* fsmul */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsmul(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
|
|
|
case 0x67: /* fdmul */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdmul(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
2017-06-28 22:42:39 +02:00
|
|
|
case 0x24: /* fsgldiv */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsgldiv(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2018-02-24 21:18:00 +01:00
|
|
|
break;
|
|
|
|
case 0x25: /* frem */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_frem(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2018-02-24 21:18:02 +01:00
|
|
|
break;
|
|
|
|
case 0x26: /* fscale */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fscale(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:39 +02:00
|
|
|
break;
|
|
|
|
case 0x27: /* fsglmul */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsglmul(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:39 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x28: /* fsub */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsub(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-28 22:42:37 +02:00
|
|
|
case 0x68: /* fssub */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fssub(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
|
|
|
case 0x6c: /* fdsub */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fdsub(tcg_env, cpu_dest, cpu_src, cpu_dest);
|
2017-06-28 22:42:37 +02:00
|
|
|
break;
|
2018-03-12 21:27:21 +01:00
|
|
|
case 0x30: case 0x31: case 0x32:
|
|
|
|
case 0x33: case 0x34: case 0x35:
|
|
|
|
case 0x36: case 0x37: {
|
|
|
|
TCGv_ptr cpu_dest2 = gen_fp_ptr(REG(ext, 0));
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fsincos(tcg_env, cpu_dest, cpu_dest2, cpu_src);
|
2018-03-12 21:27:21 +01:00
|
|
|
}
|
|
|
|
break;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 0x38: /* fcmp */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_fcmp(tcg_env, cpu_src, cpu_dest);
|
2017-06-20 22:51:20 +02:00
|
|
|
return;
|
2006-10-22 02:18:54 +02:00
|
|
|
case 0x3a: /* ftst */
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftst(tcg_env, cpu_src);
|
2017-06-20 22:51:20 +02:00
|
|
|
return;
|
2006-10-22 02:18:54 +02:00
|
|
|
default:
|
|
|
|
goto undef;
|
|
|
|
}
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_ftst(tcg_env, cpu_dest);
|
2006-10-22 02:18:54 +02:00
|
|
|
return;
|
|
|
|
undef:
|
2008-11-17 15:43:54 +01:00
|
|
|
/* FIXME: Is this right for offset addressing modes? */
|
2006-10-22 02:18:54 +02:00
|
|
|
s->pc -= 2;
|
2012-09-08 12:48:20 +02:00
|
|
|
disas_undef_fpu(env, s, insn);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2017-06-28 22:42:35 +02:00
|
|
|
static void gen_fcc_cond(DisasCompare *c, DisasContext *s, int cond)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2017-06-28 22:42:35 +02:00
|
|
|
TCGv fpsr;
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2023-02-26 02:39:06 +01:00
|
|
|
c->v2 = tcg_constant_i32(0);
|
2017-06-28 22:42:35 +02:00
|
|
|
/* TODO: Raise BSUN exception. */
|
2017-06-20 22:51:20 +02:00
|
|
|
fpsr = tcg_temp_new();
|
|
|
|
gen_load_fcr(s, fpsr, M68K_FPSR);
|
2017-06-28 22:42:35 +02:00
|
|
|
switch (cond) {
|
2017-06-20 22:51:20 +02:00
|
|
|
case 0: /* False */
|
|
|
|
case 16: /* Signaling False */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = c->v2;
|
|
|
|
c->tcond = TCG_COND_NEVER;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 1: /* EQual Z */
|
|
|
|
case 17: /* Signaling EQual Z */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 2: /* Ordered Greater Than !(A || Z || N) */
|
|
|
|
case 18: /* Greater Than !(A || Z || N) */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr,
|
2017-06-20 22:51:20 +02:00
|
|
|
FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N);
|
2017-06-28 22:42:35 +02:00
|
|
|
c->tcond = TCG_COND_EQ;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 3: /* Ordered Greater than or Equal Z || !(A || N) */
|
|
|
|
case 19: /* Greater than or Equal Z || !(A || N) */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A);
|
|
|
|
tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A));
|
|
|
|
tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_Z | FPSR_CC_N);
|
|
|
|
tcg_gen_or_i32(c->v1, c->v1, fpsr);
|
|
|
|
tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 4: /* Ordered Less Than !(!N || A || Z); */
|
|
|
|
case 20: /* Less Than !(!N || A || Z); */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_xori_i32(c->v1, fpsr, FPSR_CC_N);
|
|
|
|
tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_N | FPSR_CC_A | FPSR_CC_Z);
|
|
|
|
c->tcond = TCG_COND_EQ;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 5: /* Ordered Less than or Equal Z || (N && !A) */
|
|
|
|
case 21: /* Less than or Equal Z || (N && !A) */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A);
|
|
|
|
tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_A));
|
|
|
|
tcg_gen_andc_i32(c->v1, fpsr, c->v1);
|
|
|
|
tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_Z | FPSR_CC_N);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 6: /* Ordered Greater or Less than !(A || Z) */
|
|
|
|
case 22: /* Greater or Less than !(A || Z) */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z);
|
|
|
|
c->tcond = TCG_COND_EQ;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 7: /* Ordered !A */
|
|
|
|
case 23: /* Greater, Less or Equal !A */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A);
|
|
|
|
c->tcond = TCG_COND_EQ;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 8: /* Unordered A */
|
|
|
|
case 24: /* Not Greater, Less or Equal A */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 9: /* Unordered or Equal A || Z */
|
|
|
|
case 25: /* Not Greater or Less then A || Z */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 10: /* Unordered or Greater Than A || !(N || Z)) */
|
|
|
|
case 26: /* Not Less or Equal A || !(N || Z)) */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z);
|
|
|
|
tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z));
|
|
|
|
tcg_gen_andi_i32(fpsr, fpsr, FPSR_CC_A | FPSR_CC_N);
|
|
|
|
tcg_gen_or_i32(c->v1, c->v1, fpsr);
|
|
|
|
tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 11: /* Unordered or Greater or Equal A || Z || !N */
|
|
|
|
case 27: /* Not Less Than A || Z || !N */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N);
|
|
|
|
tcg_gen_xori_i32(c->v1, c->v1, FPSR_CC_N);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 12: /* Unordered or Less Than A || (N && !Z) */
|
|
|
|
case 28: /* Not Greater than or Equal A || (N && !Z) */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z);
|
|
|
|
tcg_gen_shli_i32(c->v1, c->v1, ctz32(FPSR_CC_N) - ctz32(FPSR_CC_Z));
|
|
|
|
tcg_gen_andc_i32(c->v1, fpsr, c->v1);
|
|
|
|
tcg_gen_andi_i32(c->v1, c->v1, FPSR_CC_A | FPSR_CC_N);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 13: /* Unordered or Less or Equal A || Z || N */
|
|
|
|
case 29: /* Not Greater Than A || Z || N */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_A | FPSR_CC_Z | FPSR_CC_N);
|
|
|
|
c->tcond = TCG_COND_NE;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 14: /* Not Equal !Z */
|
|
|
|
case 30: /* Signaling Not Equal !Z */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = tcg_temp_new();
|
|
|
|
tcg_gen_andi_i32(c->v1, fpsr, FPSR_CC_Z);
|
|
|
|
c->tcond = TCG_COND_EQ;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
2017-06-20 22:51:20 +02:00
|
|
|
case 15: /* True */
|
|
|
|
case 31: /* Signaling True */
|
2017-06-28 22:42:35 +02:00
|
|
|
c->v1 = c->v2;
|
|
|
|
c->tcond = TCG_COND_ALWAYS;
|
2006-10-22 02:18:54 +02:00
|
|
|
break;
|
|
|
|
}
|
2017-06-28 22:42:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void gen_fjmpcc(DisasContext *s, int cond, TCGLabel *l1)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
|
|
|
|
gen_fcc_cond(&c, s, cond);
|
2018-01-04 02:28:57 +01:00
|
|
|
update_cc_op(s);
|
2017-06-28 22:42:35 +02:00
|
|
|
tcg_gen_brcond_i32(c.tcond, c.v1, c.v2, l1);
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(fbcc)
|
|
|
|
{
|
|
|
|
uint32_t offset;
|
|
|
|
uint32_t base;
|
|
|
|
TCGLabel *l1;
|
|
|
|
|
|
|
|
base = s->pc;
|
|
|
|
offset = (int16_t)read_im16(env, s);
|
|
|
|
if (insn & (1 << 6)) {
|
|
|
|
offset = (offset << 16) | read_im16(env, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
l1 = gen_new_label();
|
|
|
|
update_cc_op(s);
|
|
|
|
gen_fjmpcc(s, insn & 0x3f, l1);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 0, s->pc, s->base.pc_next);
|
2006-10-22 02:18:54 +02:00
|
|
|
gen_set_label(l1);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(s, 1, base + offset, s->base.pc_next);
|
2017-06-28 22:42:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(fscc)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
int cond;
|
|
|
|
TCGv tmp;
|
|
|
|
uint16_t ext;
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
cond = ext & 0x3f;
|
|
|
|
gen_fcc_cond(&c, s, cond);
|
|
|
|
|
|
|
|
tmp = tcg_temp_new();
|
2023-08-05 02:07:59 +02:00
|
|
|
tcg_gen_negsetcond_i32(c.tcond, tmp, c.v1, c.v2);
|
2017-06-28 22:42:35 +02:00
|
|
|
|
|
|
|
DEST_EA(env, insn, OS_BYTE, tmp, NULL);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2022-06-02 03:33:57 +02:00
|
|
|
DISAS_INSN(ftrapcc)
|
|
|
|
{
|
|
|
|
DisasCompare c;
|
|
|
|
uint16_t ext;
|
|
|
|
int cond;
|
|
|
|
|
|
|
|
ext = read_im16(env, s);
|
|
|
|
cond = ext & 0x3f;
|
|
|
|
|
|
|
|
/* Consume and discard the immediate operand. */
|
|
|
|
switch (extract32(insn, 0, 3)) {
|
|
|
|
case 2: /* ftrapcc.w */
|
|
|
|
(void)read_im16(env, s);
|
|
|
|
break;
|
|
|
|
case 3: /* ftrapcc.l */
|
|
|
|
(void)read_im32(env, s);
|
|
|
|
break;
|
|
|
|
case 4: /* ftrapcc (no operand) */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ftrapcc registered with only valid opmodes */
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
gen_fcc_cond(&c, s, cond);
|
|
|
|
do_trapcc(s, &c);
|
|
|
|
}
|
|
|
|
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-05-23 21:58:11 +02:00
|
|
|
DISAS_INSN(frestore)
|
|
|
|
{
|
2018-01-04 02:29:08 +01:00
|
|
|
TCGv addr;
|
2013-09-03 17:38:47 +02:00
|
|
|
|
2018-01-04 02:29:05 +01:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:05 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-01-04 02:29:08 +01:00
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_M68040)) {
|
|
|
|
SRC_EA(env, addr, OS_LONG, 0, NULL);
|
|
|
|
/* FIXME: check the state frame */
|
|
|
|
} else {
|
|
|
|
disas_undef(env, s, insn);
|
|
|
|
}
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(fsave)
|
|
|
|
{
|
2018-01-04 02:29:05 +01:00
|
|
|
if (IS_USER(s)) {
|
2018-05-12 07:02:47 +02:00
|
|
|
gen_exception(s, s->base.pc_next, EXCP_PRIVILEGE);
|
2018-01-04 02:29:05 +01:00
|
|
|
return;
|
|
|
|
}
|
2013-09-03 17:38:47 +02:00
|
|
|
|
2018-01-04 02:29:08 +01:00
|
|
|
if (m68k_feature(s->env, M68K_FEATURE_M68040)) {
|
|
|
|
/* always write IDLE */
|
2023-02-26 02:39:06 +01:00
|
|
|
TCGv idle = tcg_constant_i32(0x41000000);
|
2018-01-04 02:29:08 +01:00
|
|
|
DEST_EA(env, insn, OS_LONG, idle, NULL);
|
|
|
|
} else {
|
|
|
|
disas_undef(env, s, insn);
|
|
|
|
}
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
2018-01-04 02:29:05 +01:00
|
|
|
#endif
|
2007-05-23 21:58:11 +02:00
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
static inline TCGv gen_mac_extract_word(DisasContext *s, TCGv val, int upper)
|
2007-05-29 16:57:59 +02:00
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv tmp = tcg_temp_new();
|
2007-05-29 16:57:59 +02:00
|
|
|
if (s->env->macsr & MACSR_FI) {
|
|
|
|
if (upper)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_andi_i32(tmp, val, 0xffff0000);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_shli_i32(tmp, val, 16);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else if (s->env->macsr & MACSR_SU) {
|
|
|
|
if (upper)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_sari_i32(tmp, val, 16);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext16s_i32(tmp, val);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else {
|
|
|
|
if (upper)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_shri_i32(tmp, val, 16);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext16u_i32(tmp, val);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
static void gen_mac_clear_flags(void)
|
|
|
|
{
|
|
|
|
tcg_gen_andi_i32(QREG_MACSR, QREG_MACSR,
|
|
|
|
~(MACSR_V | MACSR_Z | MACSR_N | MACSR_EV));
|
|
|
|
}
|
|
|
|
|
2007-05-29 16:57:59 +02:00
|
|
|
DISAS_INSN(mac)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv rx;
|
|
|
|
TCGv ry;
|
2007-05-29 16:57:59 +02:00
|
|
|
uint16_t ext;
|
|
|
|
int acc;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv tmp;
|
|
|
|
TCGv addr;
|
|
|
|
TCGv loadval;
|
2007-05-29 16:57:59 +02:00
|
|
|
int dual;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv saved_flags;
|
|
|
|
|
2008-11-17 15:43:54 +01:00
|
|
|
if (!s->done_mac) {
|
|
|
|
s->mactmp = tcg_temp_new_i64();
|
|
|
|
s->done_mac = 1;
|
|
|
|
}
|
2007-05-29 16:57:59 +02:00
|
|
|
|
2015-06-24 02:28:59 +02:00
|
|
|
ext = read_im16(env, s);
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
acc = ((insn >> 7) & 1) | ((ext >> 3) & 2);
|
|
|
|
dual = ((insn & 0x30) != 0 && (ext & 3) != 0);
|
2007-06-03 14:35:08 +02:00
|
|
|
if (dual && !m68k_feature(s->env, M68K_FEATURE_CF_EMAC_B)) {
|
2012-09-08 12:48:20 +02:00
|
|
|
disas_undef(env, s, insn);
|
2007-06-03 14:35:08 +02:00
|
|
|
return;
|
|
|
|
}
|
2007-05-29 16:57:59 +02:00
|
|
|
if (insn & 0x30) {
|
|
|
|
/* MAC with load. */
|
2012-09-08 12:48:20 +02:00
|
|
|
tmp = gen_lea(env, s, insn, OS_LONG);
|
2008-11-17 15:43:54 +01:00
|
|
|
addr = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_and_i32(addr, tmp, QREG_MAC_MASK);
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Load the value now to ensure correct exception behavior.
|
|
|
|
* Perform writeback after reading the MAC inputs.
|
|
|
|
*/
|
2018-01-18 20:38:43 +01:00
|
|
|
loadval = gen_load(s, OS_LONG, addr, 0, IS_USER(s));
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
acc ^= 1;
|
|
|
|
rx = (ext & 0x8000) ? AREG(ext, 12) : DREG(insn, 12);
|
|
|
|
ry = (ext & 8) ? AREG(ext, 0) : DREG(ext, 0);
|
|
|
|
} else {
|
2008-05-25 00:29:16 +02:00
|
|
|
loadval = addr = NULL_QREG;
|
2007-05-29 16:57:59 +02:00
|
|
|
rx = (insn & 0x40) ? AREG(insn, 9) : DREG(insn, 9);
|
|
|
|
ry = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0);
|
|
|
|
}
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_mac_clear_flags();
|
|
|
|
#if 0
|
2007-05-29 16:57:59 +02:00
|
|
|
l1 = -1;
|
2008-05-25 00:29:16 +02:00
|
|
|
/* Disabled because conditional branches clobber temporary vars. */
|
2007-05-29 16:57:59 +02:00
|
|
|
if ((s->env->macsr & MACSR_OMC) != 0 && !dual) {
|
|
|
|
/* Skip the multiply if we know we will ignore it. */
|
|
|
|
l1 = gen_new_label();
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_andi_i32(tmp, QREG_MACSR, 1 << (acc + 8));
|
2007-05-29 16:57:59 +02:00
|
|
|
gen_op_jmp_nz32(tmp, l1);
|
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
#endif
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
if ((ext & 0x0800) == 0) {
|
|
|
|
/* Word. */
|
|
|
|
rx = gen_mac_extract_word(s, rx, (ext & 0x80) != 0);
|
|
|
|
ry = gen_mac_extract_word(s, ry, (ext & 0x40) != 0);
|
|
|
|
}
|
|
|
|
if (s->env->macsr & MACSR_FI) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macmulf(s->mactmp, tcg_env, rx, ry);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else {
|
|
|
|
if (s->env->macsr & MACSR_SU)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macmuls(s->mactmp, tcg_env, rx, ry);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macmulu(s->mactmp, tcg_env, rx, ry);
|
2007-05-29 16:57:59 +02:00
|
|
|
switch ((ext >> 9) & 3) {
|
|
|
|
case 1:
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_shli_i64(s->mactmp, s->mactmp, 1);
|
2007-05-29 16:57:59 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_shri_i64(s->mactmp, s->mactmp, 1);
|
2007-05-29 16:57:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dual) {
|
|
|
|
/* Save the overflow flag from the multiply. */
|
2008-11-17 15:43:54 +01:00
|
|
|
saved_flags = tcg_temp_new();
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(saved_flags, QREG_MACSR);
|
|
|
|
} else {
|
|
|
|
saved_flags = NULL_QREG;
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
#if 0
|
|
|
|
/* Disabled because conditional branches clobber temporary vars. */
|
2007-05-29 16:57:59 +02:00
|
|
|
if ((s->env->macsr & MACSR_OMC) != 0 && dual) {
|
|
|
|
/* Skip the accumulate if the value is already saturated. */
|
|
|
|
l1 = gen_new_label();
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2023-02-26 02:39:06 +01:00
|
|
|
gen_op_and32(tmp, QREG_MACSR, tcg_constant_i32(MACSR_PAV0 << acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
gen_op_jmp_nz32(tmp, l1);
|
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
#endif
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
if (insn & 0x100)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_sub_i64(MACREG(acc), MACREG(acc), s->mactmp);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_add_i64(MACREG(acc), MACREG(acc), s->mactmp);
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
if (s->env->macsr & MACSR_FI)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macsatf(tcg_env, tcg_constant_i32(acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
else if (s->env->macsr & MACSR_SU)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macsats(tcg_env, tcg_constant_i32(acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macsatu(tcg_env, tcg_constant_i32(acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
|
2008-05-25 00:29:16 +02:00
|
|
|
#if 0
|
|
|
|
/* Disabled because conditional branches clobber temporary vars. */
|
2007-05-29 16:57:59 +02:00
|
|
|
if (l1 != -1)
|
|
|
|
gen_set_label(l1);
|
2008-05-25 00:29:16 +02:00
|
|
|
#endif
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
if (dual) {
|
|
|
|
/* Dual accumulate variant. */
|
|
|
|
acc = (ext >> 2) & 3;
|
|
|
|
/* Restore the overflow flag from the multiplier. */
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(QREG_MACSR, saved_flags);
|
|
|
|
#if 0
|
|
|
|
/* Disabled because conditional branches clobber temporary vars. */
|
2007-05-29 16:57:59 +02:00
|
|
|
if ((s->env->macsr & MACSR_OMC) != 0) {
|
|
|
|
/* Skip the accumulate if the value is already saturated. */
|
|
|
|
l1 = gen_new_label();
|
2008-11-17 15:43:54 +01:00
|
|
|
tmp = tcg_temp_new();
|
2023-02-26 02:39:06 +01:00
|
|
|
gen_op_and32(tmp, QREG_MACSR, tcg_constant_i32(MACSR_PAV0 << acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
gen_op_jmp_nz32(tmp, l1);
|
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
#endif
|
2007-05-29 16:57:59 +02:00
|
|
|
if (ext & 2)
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_sub_i64(MACREG(acc), MACREG(acc), s->mactmp);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_add_i64(MACREG(acc), MACREG(acc), s->mactmp);
|
2007-05-29 16:57:59 +02:00
|
|
|
if (s->env->macsr & MACSR_FI)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macsatf(tcg_env, tcg_constant_i32(acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
else if (s->env->macsr & MACSR_SU)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macsats(tcg_env, tcg_constant_i32(acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_macsatu(tcg_env, tcg_constant_i32(acc));
|
2008-05-25 00:29:16 +02:00
|
|
|
#if 0
|
|
|
|
/* Disabled because conditional branches clobber temporary vars. */
|
2007-05-29 16:57:59 +02:00
|
|
|
if (l1 != -1)
|
|
|
|
gen_set_label(l1);
|
2008-05-25 00:29:16 +02:00
|
|
|
#endif
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_mac_set_flags(tcg_env, tcg_constant_i32(acc));
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
if (insn & 0x30) {
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv rw;
|
2007-05-29 16:57:59 +02:00
|
|
|
rw = (insn & 0x40) ? AREG(insn, 9) : DREG(insn, 9);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(rw, loadval);
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* FIXME: Should address writeback happen with the masked or
|
|
|
|
* unmasked value?
|
|
|
|
*/
|
2007-05-29 16:57:59 +02:00
|
|
|
switch ((insn >> 3) & 7) {
|
|
|
|
case 3: /* Post-increment. */
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_addi_i32(AREG(insn, 0), addr, 4);
|
2007-05-29 16:57:59 +02:00
|
|
|
break;
|
|
|
|
case 4: /* Pre-decrement. */
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(AREG(insn, 0), addr);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(from_mac)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv rx;
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i64 acc;
|
2008-05-25 00:29:16 +02:00
|
|
|
int accnum;
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
rx = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0);
|
2008-05-25 00:29:16 +02:00
|
|
|
accnum = (insn >> 9) & 3;
|
|
|
|
acc = MACREG(accnum);
|
2007-05-29 16:57:59 +02:00
|
|
|
if (s->env->macsr & MACSR_FI) {
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_get_macf(rx, tcg_env, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else if ((s->env->macsr & MACSR_OMC) == 0) {
|
2015-07-24 20:49:53 +02:00
|
|
|
tcg_gen_extrl_i64_i32(rx, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else if (s->env->macsr & MACSR_SU) {
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_helper_get_macs(rx, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else {
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_helper_get_macu(rx, acc);
|
|
|
|
}
|
|
|
|
if (insn & 0x40) {
|
|
|
|
tcg_gen_movi_i64(acc, 0);
|
|
|
|
tcg_gen_andi_i32(QREG_MACSR, QREG_MACSR, ~(MACSR_PAV0 << accnum));
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(move_mac)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
/* FIXME: This can be done without a helper. */
|
2007-05-29 16:57:59 +02:00
|
|
|
int src;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv dest;
|
2007-05-29 16:57:59 +02:00
|
|
|
src = insn & 3;
|
2023-02-26 02:39:06 +01:00
|
|
|
dest = tcg_constant_i32((insn >> 9) & 3);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_mac_move(tcg_env, dest, tcg_constant_i32(src));
|
2008-05-25 00:29:16 +02:00
|
|
|
gen_mac_clear_flags();
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_mac_set_flags(tcg_env, dest);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(from_macsr)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2007-05-29 16:57:59 +02:00
|
|
|
|
|
|
|
reg = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, QREG_MACSR);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(from_mask)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
2007-05-29 16:57:59 +02:00
|
|
|
reg = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_mov_i32(reg, QREG_MAC_MASK);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(from_mext)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv reg;
|
|
|
|
TCGv acc;
|
2007-05-29 16:57:59 +02:00
|
|
|
reg = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0);
|
2023-02-26 02:39:06 +01:00
|
|
|
acc = tcg_constant_i32((insn & 0x400) ? 2 : 0);
|
2007-05-29 16:57:59 +02:00
|
|
|
if (s->env->macsr & MACSR_FI)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_get_mac_extf(reg, tcg_env, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_get_mac_exti(reg, tcg_env, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(macsr_to_ccr)
|
|
|
|
{
|
2015-08-14 16:59:20 +02:00
|
|
|
TCGv tmp = tcg_temp_new();
|
2022-09-13 16:28:17 +02:00
|
|
|
|
|
|
|
/* Note that X and C are always cleared. */
|
|
|
|
tcg_gen_andi_i32(tmp, QREG_MACSR, CCF_N | CCF_Z | CCF_V);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_ccr(tcg_env, tmp);
|
2015-08-09 01:44:24 +02:00
|
|
|
set_cc_op(s, CC_OP_FLAGS);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(to_mac)
|
|
|
|
{
|
2008-11-17 15:43:54 +01:00
|
|
|
TCGv_i64 acc;
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv val;
|
|
|
|
int accnum;
|
|
|
|
accnum = (insn >> 9) & 3;
|
|
|
|
acc = MACREG(accnum);
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, val, OS_LONG, 0, NULL);
|
2007-05-29 16:57:59 +02:00
|
|
|
if (s->env->macsr & MACSR_FI) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext_i32_i64(acc, val);
|
|
|
|
tcg_gen_shli_i64(acc, acc, 8);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else if (s->env->macsr & MACSR_SU) {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ext_i32_i64(acc, val);
|
2007-05-29 16:57:59 +02:00
|
|
|
} else {
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_extu_i32_i64(acc, val);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_andi_i32(QREG_MACSR, QREG_MACSR, ~(MACSR_PAV0 << accnum));
|
|
|
|
gen_mac_clear_flags();
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_mac_set_flags(tcg_env, tcg_constant_i32(accnum));
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(to_macsr)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv val;
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, val, OS_LONG, 0, NULL);
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_macsr(tcg_env, val);
|
2018-05-12 07:02:46 +02:00
|
|
|
gen_exit_tb(s);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(to_mask)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv val;
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, val, OS_LONG, 0, NULL);
|
2008-05-25 00:29:16 +02:00
|
|
|
tcg_gen_ori_i32(QREG_MAC_MASK, val, 0xffff0000);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DISAS_INSN(to_mext)
|
|
|
|
{
|
2008-05-25 00:29:16 +02:00
|
|
|
TCGv val;
|
|
|
|
TCGv acc;
|
2012-09-08 12:48:20 +02:00
|
|
|
SRC_EA(env, val, OS_LONG, 0, NULL);
|
2023-02-26 02:39:06 +01:00
|
|
|
acc = tcg_constant_i32((insn & 0x400) ? 2 : 0);
|
2007-05-29 16:57:59 +02:00
|
|
|
if (s->env->macsr & MACSR_FI)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_mac_extf(tcg_env, val, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
else if (s->env->macsr & MACSR_SU)
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_mac_exts(tcg_env, val, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
else
|
2023-09-14 01:37:36 +02:00
|
|
|
gen_helper_set_mac_extu(tcg_env, val, acc);
|
2007-05-29 16:57:59 +02:00
|
|
|
}
|
|
|
|
|
2006-10-22 02:18:54 +02:00
|
|
|
static disas_proc opcode_table[65536];
|
|
|
|
|
|
|
|
static void
|
|
|
|
register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int from;
|
|
|
|
int to;
|
|
|
|
|
|
|
|
/* Sanity check. All set bits must be included in the mask. */
|
2007-05-28 03:46:43 +02:00
|
|
|
if (opcode & ~mask) {
|
|
|
|
fprintf(stderr,
|
|
|
|
"qemu internal error: bogus opcode definition %04x/%04x\n",
|
|
|
|
opcode, mask);
|
2006-10-22 02:18:54 +02:00
|
|
|
abort();
|
2007-05-28 03:46:43 +02:00
|
|
|
}
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* This could probably be cleverer. For now just optimize the case where
|
|
|
|
* the top bits are known.
|
|
|
|
*/
|
2006-10-22 02:18:54 +02:00
|
|
|
/* Find the first zero bit in the mask. */
|
|
|
|
i = 0x8000;
|
|
|
|
while ((i & mask) != 0)
|
|
|
|
i >>= 1;
|
|
|
|
/* Iterate over all combinations of this and lower bits. */
|
|
|
|
if (i == 0)
|
|
|
|
i = 1;
|
|
|
|
else
|
|
|
|
i <<= 1;
|
|
|
|
from = opcode & ~(i - 1);
|
|
|
|
to = from + i;
|
2007-05-23 21:58:11 +02:00
|
|
|
for (i = from; i < to; i++) {
|
2006-10-22 02:18:54 +02:00
|
|
|
if ((i & mask) == opcode)
|
|
|
|
opcode_table[i] = proc;
|
2007-05-23 21:58:11 +02:00
|
|
|
}
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Register m68k opcode handlers. Order is important.
|
|
|
|
* Later insn override earlier ones.
|
|
|
|
*/
|
2007-05-26 18:52:21 +02:00
|
|
|
void register_m68k_insns (CPUM68KState *env)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Build the opcode table only once to avoid
|
|
|
|
* multithreading issues.
|
|
|
|
*/
|
2016-02-03 10:22:35 +01:00
|
|
|
if (opcode_table[0] != NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2015-06-23 20:55:08 +02:00
|
|
|
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* use BASE() for instruction available
|
2015-06-23 20:55:08 +02:00
|
|
|
* for CF_ISA_A and M68000.
|
|
|
|
*/
|
|
|
|
#define BASE(name, opcode, mask) \
|
|
|
|
register_opcode(disas_##name, 0x##opcode, 0x##mask)
|
2007-06-03 14:35:08 +02:00
|
|
|
#define INSN(name, opcode, mask, feature) do { \
|
2007-05-26 18:52:21 +02:00
|
|
|
if (m68k_feature(env, M68K_FEATURE_##feature)) \
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(name, opcode, mask); \
|
2007-06-03 14:35:08 +02:00
|
|
|
} while(0)
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(undef, 0000, 0000);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(arith_im, 0080, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(arith_im, 0000, ff00, M68K);
|
2018-01-04 02:29:03 +01:00
|
|
|
INSN(chk2, 00c0, f9c0, CHK2);
|
2007-06-03 14:35:08 +02:00
|
|
|
INSN(bitrev, 00c0, fff8, CF_ISA_APLUSC);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(bitop_reg, 0100, f1c0);
|
|
|
|
BASE(bitop_reg, 0140, f1c0);
|
|
|
|
BASE(bitop_reg, 0180, f1c0);
|
|
|
|
BASE(bitop_reg, 01c0, f1c0);
|
2018-02-06 13:44:31 +01:00
|
|
|
INSN(movep, 0108, f138, MOVEP);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(arith_im, 0280, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(arith_im, 0200, ff00, M68K);
|
|
|
|
INSN(undef, 02c0, ffc0, M68K);
|
2007-06-03 14:35:08 +02:00
|
|
|
INSN(byterev, 02c0, fff8, CF_ISA_APLUSC);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(arith_im, 0480, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(arith_im, 0400, ff00, M68K);
|
|
|
|
INSN(undef, 04c0, ffc0, M68K);
|
|
|
|
INSN(arith_im, 0600, ff00, M68K);
|
|
|
|
INSN(undef, 06c0, ffc0, M68K);
|
2007-06-03 14:35:08 +02:00
|
|
|
INSN(ff1, 04c0, fff8, CF_ISA_APLUSC);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(arith_im, 0680, fff8, CF_ISA_A);
|
|
|
|
INSN(arith_im, 0c00, ff38, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(arith_im, 0c00, ff00, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(bitop_im, 0800, ffc0);
|
|
|
|
BASE(bitop_im, 0840, ffc0);
|
|
|
|
BASE(bitop_im, 0880, ffc0);
|
|
|
|
BASE(bitop_im, 08c0, ffc0);
|
|
|
|
INSN(arith_im, 0a80, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(arith_im, 0a00, ff00, M68K);
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(moves, 0e00, ff00, M68K);
|
2018-01-18 20:38:44 +01:00
|
|
|
#endif
|
2016-01-11 01:33:26 +01:00
|
|
|
INSN(cas, 0ac0, ffc0, CAS);
|
|
|
|
INSN(cas, 0cc0, ffc0, CAS);
|
|
|
|
INSN(cas, 0ec0, ffc0, CAS);
|
|
|
|
INSN(cas2w, 0cfc, ffff, CAS);
|
|
|
|
INSN(cas2l, 0efc, ffff, CAS);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(move, 1000, f000);
|
|
|
|
BASE(move, 2000, f000);
|
|
|
|
BASE(move, 3000, f000);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(chk, 4000, f040, M68K);
|
2007-06-03 14:35:08 +02:00
|
|
|
INSN(strldsr, 40e7, ffff, CF_ISA_APLUSC);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(negx, 4080, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(negx, 4000, ff00, M68K);
|
|
|
|
INSN(undef, 40c0, ffc0, M68K);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(move_from_sr, 40c0, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(move_from_sr, 40c0, ffc0, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(lea, 41c0, f1c0);
|
|
|
|
BASE(clr, 4200, ff00);
|
|
|
|
BASE(undef, 42c0, ffc0);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(move_from_ccr, 42c0, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(move_from_ccr, 42c0, ffc0, M68K);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(neg, 4480, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(neg, 4400, ff00, M68K);
|
|
|
|
INSN(undef, 44c0, ffc0, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(move_to_ccr, 44c0, ffc0);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(not, 4680, fff8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(not, 4600, ff00, M68K);
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2018-01-04 02:29:10 +01:00
|
|
|
BASE(move_to_sr, 46c0, ffc0);
|
2018-01-04 02:29:05 +01:00
|
|
|
#endif
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(nbcd, 4800, ffc0, M68K);
|
|
|
|
INSN(linkl, 4808, fff8, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(pea, 4840, ffc0);
|
|
|
|
BASE(swap, 4840, fff8);
|
2016-01-17 01:13:07 +01:00
|
|
|
INSN(bkpt, 4848, fff8, BKPT);
|
2016-11-09 14:46:07 +01:00
|
|
|
INSN(movem, 48d0, fbf8, CF_ISA_A);
|
|
|
|
INSN(movem, 48e8, fbf8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(movem, 4880, fb80, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(ext, 4880, fff8);
|
|
|
|
BASE(ext, 48c0, fff8);
|
|
|
|
BASE(ext, 49c0, fff8);
|
|
|
|
BASE(tst, 4a00, ff00);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(tas, 4ac0, ffc0, CF_ISA_B);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(tas, 4ac0, ffc0, M68K);
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(halt, 4ac8, ffff, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(halt, 4ac8, ffff, M68K);
|
2018-01-04 02:29:05 +01:00
|
|
|
#endif
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(pulse, 4acc, ffff, CF_ISA_A);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(illegal, 4afc, ffff);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(mull, 4c00, ffc0, CF_ISA_A);
|
2015-06-23 20:55:08 +02:00
|
|
|
INSN(mull, 4c00, ffc0, LONG_MULDIV);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(divl, 4c40, ffc0, CF_ISA_A);
|
2015-06-23 20:55:08 +02:00
|
|
|
INSN(divl, 4c40, ffc0, LONG_MULDIV);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(sats, 4c80, fff8, CF_ISA_B);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(trap, 4e40, fff0);
|
|
|
|
BASE(link, 4e50, fff8);
|
|
|
|
BASE(unlk, 4e58, fff8);
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-06-03 13:13:39 +02:00
|
|
|
INSN(move_to_usp, 4e60, fff8, USP);
|
|
|
|
INSN(move_from_usp, 4e68, fff8, USP);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(reset, 4e70, ffff, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(stop, 4e72, ffff);
|
|
|
|
BASE(rte, 4e73, ffff);
|
2018-01-04 02:29:12 +01:00
|
|
|
INSN(cf_movec, 4e7b, ffff, CF_ISA_A);
|
2021-02-01 01:01:52 +01:00
|
|
|
INSN(m68k_movec, 4e7a, fffe, MOVEC);
|
2018-01-04 02:29:05 +01:00
|
|
|
#endif
|
|
|
|
BASE(nop, 4e71, ffff);
|
2017-06-05 12:00:14 +02:00
|
|
|
INSN(rtd, 4e74, ffff, RTD);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(rts, 4e75, ffff);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(trapv, 4e76, ffff, M68K);
|
|
|
|
INSN(rtr, 4e77, ffff, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(jump, 4e80, ffc0);
|
2016-01-17 00:57:01 +01:00
|
|
|
BASE(jump, 4ec0, ffc0);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(addsubq, 5000, f080, M68K);
|
2016-01-17 00:57:01 +01:00
|
|
|
BASE(addsubq, 5080, f0c0);
|
2016-01-10 23:53:20 +01:00
|
|
|
INSN(scc, 50c0, f0f8, CF_ISA_A); /* Scc.B Dx */
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(scc, 50c0, f0c0, M68K); /* Scc.B <EA> */
|
|
|
|
INSN(dbcc, 50c8, f0f8, M68K);
|
2022-06-02 03:33:54 +02:00
|
|
|
INSN(trapcc, 50fa, f0fe, TRAPCC); /* opmode 010, 011 */
|
|
|
|
INSN(trapcc, 50fc, f0ff, TRAPCC); /* opmode 100 */
|
2022-06-02 03:33:55 +02:00
|
|
|
INSN(trapcc, 51fa, fffe, CF_ISA_A); /* TPF (trapf) opmode 010, 011 */
|
|
|
|
INSN(trapcc, 51fc, ffff, CF_ISA_A); /* TPF (trapf) opmode 100 */
|
2007-06-03 14:35:08 +02:00
|
|
|
|
|
|
|
/* Branch instructions. */
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(branch, 6000, f000);
|
2007-06-03 14:35:08 +02:00
|
|
|
/* Disable long branch instructions, then add back the ones we want. */
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(undef, 60ff, f0ff); /* All long branches. */
|
2007-06-03 14:35:08 +02:00
|
|
|
INSN(branch, 60ff, f0ff, CF_ISA_B);
|
|
|
|
INSN(undef, 60ff, ffff, CF_ISA_B); /* bra.l */
|
|
|
|
INSN(branch, 60ff, ffff, BRAL);
|
2015-06-23 20:55:08 +02:00
|
|
|
INSN(branch, 60ff, f0ff, BCCL);
|
2007-06-03 14:35:08 +02:00
|
|
|
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(moveq, 7000, f100);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(mvzs, 7100, f100, CF_ISA_B);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(or, 8000, f000);
|
|
|
|
BASE(divw, 80c0, f0c0);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(sbcd_reg, 8100, f1f8, M68K);
|
|
|
|
INSN(sbcd_mem, 8108, f1f8, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(addsub, 9000, f000);
|
2015-08-14 16:59:26 +02:00
|
|
|
INSN(undef, 90c0, f0c0, CF_ISA_A);
|
|
|
|
INSN(subx_reg, 9180, f1f8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(subx_reg, 9100, f138, M68K);
|
|
|
|
INSN(subx_mem, 9108, f138, M68K);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(suba, 91c0, f1c0, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(suba, 90c0, f0c0, M68K);
|
2007-05-29 16:57:59 +02:00
|
|
|
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(undef_mac, a000, f000);
|
2007-05-29 16:57:59 +02:00
|
|
|
INSN(mac, a000, f100, CF_EMAC);
|
|
|
|
INSN(from_mac, a180, f9b0, CF_EMAC);
|
|
|
|
INSN(move_mac, a110, f9fc, CF_EMAC);
|
|
|
|
INSN(from_macsr,a980, f9f0, CF_EMAC);
|
|
|
|
INSN(from_mask, ad80, fff0, CF_EMAC);
|
|
|
|
INSN(from_mext, ab80, fbf0, CF_EMAC);
|
|
|
|
INSN(macsr_to_ccr, a9c0, ffff, CF_EMAC);
|
|
|
|
INSN(to_mac, a100, f9c0, CF_EMAC);
|
|
|
|
INSN(to_macsr, a900, ffc0, CF_EMAC);
|
|
|
|
INSN(to_mext, ab00, fbc0, CF_EMAC);
|
|
|
|
INSN(to_mask, ad00, ffc0, CF_EMAC);
|
|
|
|
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(mov3q, a140, f1c0, CF_ISA_B);
|
|
|
|
INSN(cmp, b000, f1c0, CF_ISA_B); /* cmp.b */
|
|
|
|
INSN(cmp, b040, f1c0, CF_ISA_B); /* cmp.w */
|
|
|
|
INSN(cmpa, b0c0, f1c0, CF_ISA_B); /* cmpa.w */
|
|
|
|
INSN(cmp, b080, f1c0, CF_ISA_A);
|
|
|
|
INSN(cmpa, b1c0, f1c0, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(cmp, b000, f100, M68K);
|
|
|
|
INSN(eor, b100, f100, M68K);
|
|
|
|
INSN(cmpm, b108, f138, M68K);
|
|
|
|
INSN(cmpa, b0c0, f0c0, M68K);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(eor, b180, f1c0, CF_ISA_A);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(and, c000, f000);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(exg_dd, c140, f1f8, M68K);
|
|
|
|
INSN(exg_aa, c148, f1f8, M68K);
|
|
|
|
INSN(exg_da, c188, f1f8, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(mulw, c0c0, f0c0);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(abcd_reg, c100, f1f8, M68K);
|
|
|
|
INSN(abcd_mem, c108, f1f8, M68K);
|
2015-06-23 20:55:08 +02:00
|
|
|
BASE(addsub, d000, f000);
|
2015-08-14 16:59:26 +02:00
|
|
|
INSN(undef, d0c0, f0c0, CF_ISA_A);
|
|
|
|
INSN(addx_reg, d180, f1f8, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(addx_reg, d100, f138, M68K);
|
|
|
|
INSN(addx_mem, d108, f138, M68K);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(adda, d1c0, f1c0, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(adda, d0c0, f0c0, M68K);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(shift_im, e080, f0f0, CF_ISA_A);
|
|
|
|
INSN(shift_reg, e0a0, f0f0, CF_ISA_A);
|
2022-09-17 13:25:12 +02:00
|
|
|
INSN(shift8_im, e000, f0f0, M68K);
|
|
|
|
INSN(shift16_im, e040, f0f0, M68K);
|
|
|
|
INSN(shift_im, e080, f0f0, M68K);
|
|
|
|
INSN(shift8_reg, e020, f0f0, M68K);
|
|
|
|
INSN(shift16_reg, e060, f0f0, M68K);
|
|
|
|
INSN(shift_reg, e0a0, f0f0, M68K);
|
|
|
|
INSN(shift_mem, e0c0, fcc0, M68K);
|
|
|
|
INSN(rotate_im, e090, f0f0, M68K);
|
|
|
|
INSN(rotate8_im, e010, f0f0, M68K);
|
|
|
|
INSN(rotate16_im, e050, f0f0, M68K);
|
|
|
|
INSN(rotate_reg, e0b0, f0f0, M68K);
|
|
|
|
INSN(rotate8_reg, e030, f0f0, M68K);
|
|
|
|
INSN(rotate16_reg, e070, f0f0, M68K);
|
|
|
|
INSN(rotate_mem, e4c0, fcc0, M68K);
|
2016-11-09 14:46:11 +01:00
|
|
|
INSN(bfext_mem, e9c0, fdc0, BITFIELD); /* bfextu & bfexts */
|
|
|
|
INSN(bfext_reg, e9c0, fdf8, BITFIELD);
|
|
|
|
INSN(bfins_mem, efc0, ffc0, BITFIELD);
|
2016-11-09 14:46:10 +01:00
|
|
|
INSN(bfins_reg, efc0, fff8, BITFIELD);
|
2016-11-09 14:46:11 +01:00
|
|
|
INSN(bfop_mem, eac0, ffc0, BITFIELD); /* bfchg */
|
2016-11-09 14:46:10 +01:00
|
|
|
INSN(bfop_reg, eac0, fff8, BITFIELD); /* bfchg */
|
2016-11-09 14:46:11 +01:00
|
|
|
INSN(bfop_mem, ecc0, ffc0, BITFIELD); /* bfclr */
|
2016-11-09 14:46:10 +01:00
|
|
|
INSN(bfop_reg, ecc0, fff8, BITFIELD); /* bfclr */
|
2016-11-15 21:44:29 +01:00
|
|
|
INSN(bfop_mem, edc0, ffc0, BITFIELD); /* bfffo */
|
|
|
|
INSN(bfop_reg, edc0, fff8, BITFIELD); /* bfffo */
|
2016-11-09 14:46:11 +01:00
|
|
|
INSN(bfop_mem, eec0, ffc0, BITFIELD); /* bfset */
|
2016-11-09 14:46:10 +01:00
|
|
|
INSN(bfop_reg, eec0, fff8, BITFIELD); /* bfset */
|
2016-11-09 14:46:11 +01:00
|
|
|
INSN(bfop_mem, e8c0, ffc0, BITFIELD); /* bftst */
|
2016-11-09 14:46:10 +01:00
|
|
|
INSN(bfop_reg, e8c0, fff8, BITFIELD); /* bftst */
|
2017-06-20 22:51:18 +02:00
|
|
|
BASE(undef_fpu, f000, f000);
|
2006-10-22 02:18:54 +02:00
|
|
|
INSN(fpu, f200, ffc0, CF_FPU);
|
|
|
|
INSN(fbcc, f280, ffc0, CF_FPU);
|
2017-06-20 22:51:18 +02:00
|
|
|
INSN(fpu, f200, ffc0, FPU);
|
2017-06-28 22:42:35 +02:00
|
|
|
INSN(fscc, f240, ffc0, FPU);
|
2022-06-02 03:33:57 +02:00
|
|
|
INSN(ftrapcc, f27a, fffe, FPU); /* opmode 010, 011 */
|
|
|
|
INSN(ftrapcc, f27c, ffff, FPU); /* opmode 100 */
|
2017-06-20 22:51:18 +02:00
|
|
|
INSN(fbcc, f280, ff80, FPU);
|
2023-06-13 15:33:41 +02:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2018-01-04 02:29:05 +01:00
|
|
|
INSN(frestore, f340, ffc0, CF_FPU);
|
|
|
|
INSN(fsave, f300, ffc0, CF_FPU);
|
2017-06-20 22:51:18 +02:00
|
|
|
INSN(frestore, f340, ffc0, FPU);
|
|
|
|
INSN(fsave, f300, ffc0, FPU);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(intouch, f340, ffc0, CF_ISA_A);
|
|
|
|
INSN(cpushl, f428, ff38, CF_ISA_A);
|
2018-01-04 02:29:06 +01:00
|
|
|
INSN(cpush, f420, ff20, M68040);
|
|
|
|
INSN(cinv, f400, ff20, M68040);
|
2018-01-18 20:38:45 +01:00
|
|
|
INSN(pflush, f500, ffe0, M68040);
|
|
|
|
INSN(ptest, f548, ffd8, M68040);
|
2007-05-26 18:52:21 +02:00
|
|
|
INSN(wddata, fb00, ff00, CF_ISA_A);
|
|
|
|
INSN(wdebug, fbc0, ffc0, CF_ISA_A);
|
2018-01-04 02:29:05 +01:00
|
|
|
#endif
|
|
|
|
INSN(move16_mem, f600, ffe0, M68040);
|
|
|
|
INSN(move16_reg, f620, fff8, M68040);
|
2006-10-22 02:18:54 +02:00
|
|
|
#undef INSN
|
|
|
|
}
|
|
|
|
|
2018-05-12 07:02:48 +02:00
|
|
|
static void m68k_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2018-05-12 07:02:48 +02:00
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
2023-09-14 02:22:49 +02:00
|
|
|
CPUM68KState *env = cpu_env(cpu);
|
2006-10-22 02:18:54 +02:00
|
|
|
|
2007-05-26 23:16:48 +02:00
|
|
|
dc->env = env;
|
2018-05-12 07:02:48 +02:00
|
|
|
dc->pc = dc->base.pc_first;
|
2022-06-02 03:33:52 +02:00
|
|
|
/* This value will always be filled in properly before m68k_tr_tb_stop. */
|
|
|
|
dc->pc_prev = 0xdeadbeef;
|
2006-10-22 02:18:54 +02:00
|
|
|
dc->cc_op = CC_OP_DYNAMIC;
|
2015-08-14 16:59:20 +02:00
|
|
|
dc->cc_op_synced = 1;
|
2008-11-17 15:43:54 +01:00
|
|
|
dc->done_mac = 0;
|
2016-11-03 21:50:01 +01:00
|
|
|
dc->writeback_mask = 0;
|
2021-05-19 16:29:17 +02:00
|
|
|
|
|
|
|
dc->ss_active = (M68K_SR_TRACE(env->sr) == M68K_SR_TRACE_ANY_INS);
|
|
|
|
/* If architectural single step active, limit to 1 */
|
2021-07-19 09:27:53 +02:00
|
|
|
if (dc->ss_active) {
|
2021-05-19 16:29:17 +02:00
|
|
|
dc->base.max_insns = 1;
|
|
|
|
}
|
2018-05-12 07:02:48 +02:00
|
|
|
}
|
target/m68k: add a mechanism to automatically free TCGv
SRC_EA() and gen_extend() can return either a temporary
TCGv or a memory allocated one. Mark them when they are
allocated, and free them automatically at end of the
instruction translation.
We want to free locally allocated TCGv to avoid
overflow in sequence like:
0xc00ae406: movel %fp@(-132),%fp@(-268)
0xc00ae40c: movel %fp@(-128),%fp@(-264)
0xc00ae412: movel %fp@(-20),%fp@(-212)
0xc00ae418: movel %fp@(-16),%fp@(-208)
0xc00ae41e: movel %fp@(-60),%fp@(-220)
0xc00ae424: movel %fp@(-56),%fp@(-216)
0xc00ae42a: movel %fp@(-124),%fp@(-252)
0xc00ae430: movel %fp@(-120),%fp@(-248)
0xc00ae436: movel %fp@(-12),%fp@(-260)
0xc00ae43c: movel %fp@(-8),%fp@(-256)
0xc00ae442: movel %fp@(-52),%fp@(-276)
0xc00ae448: movel %fp@(-48),%fp@(-272)
...
That can fill a lot of TCGv entries in a sequence,
especially since 15fa08f845 ("tcg: Dynamically allocate TCGOps")
we have no limit to fill the TCGOps cache and we can fill
the entire TCG variables array and overflow it.
Suggested-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180319113544.704-3-laurent@vivier.eu>
2018-03-19 12:35:44 +01:00
|
|
|
|
2018-05-12 07:02:48 +02:00
|
|
|
static void m68k_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu)
|
|
|
|
{
|
|
|
|
}
|
2015-09-18 00:58:10 +02:00
|
|
|
|
2018-05-12 07:02:48 +02:00
|
|
|
static void m68k_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
|
|
|
|
{
|
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
|
|
|
tcg_gen_insn_start(dc->base.pc_next, dc->cc_op);
|
|
|
|
}
|
2015-08-29 21:59:29 +02:00
|
|
|
|
2018-05-12 07:02:48 +02:00
|
|
|
static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
|
|
|
|
{
|
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
2023-09-14 02:22:49 +02:00
|
|
|
CPUM68KState *env = cpu_env(cpu);
|
2018-05-12 07:02:50 +02:00
|
|
|
uint16_t insn = read_im16(env, dc);
|
|
|
|
|
|
|
|
opcode_table[insn](env, dc, insn);
|
|
|
|
do_writebacks(dc);
|
2018-05-12 07:02:48 +02:00
|
|
|
|
2022-06-02 03:33:52 +02:00
|
|
|
dc->pc_prev = dc->base.pc_next;
|
2018-05-12 07:02:48 +02:00
|
|
|
dc->base.pc_next = dc->pc;
|
|
|
|
|
2018-05-12 07:02:49 +02:00
|
|
|
if (dc->base.is_jmp == DISAS_NEXT) {
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* Stop translation when the next insn might touch a new page.
|
2018-05-12 07:02:49 +02:00
|
|
|
* This ensures that prefetch aborts at the right place.
|
|
|
|
*
|
|
|
|
* We cannot determine the size of the next insn without
|
|
|
|
* completely decoding it. However, the maximum insn size
|
|
|
|
* is 32 bytes, so end if we do not have that much remaining.
|
|
|
|
* This may produce several small TBs at the end of each page,
|
|
|
|
* but they will all be linked with goto_tb.
|
|
|
|
*
|
|
|
|
* ??? ColdFire maximum is 4 bytes; MC68000's maximum is also
|
|
|
|
* smaller than MC68020's.
|
|
|
|
*/
|
|
|
|
target_ulong start_page_offset
|
|
|
|
= dc->pc - (dc->base.pc_first & TARGET_PAGE_MASK);
|
|
|
|
|
|
|
|
if (start_page_offset >= TARGET_PAGE_SIZE - 32) {
|
|
|
|
dc->base.is_jmp = DISAS_TOO_MANY;
|
|
|
|
}
|
2018-05-12 07:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void m68k_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
|
|
|
|
{
|
|
|
|
DisasContext *dc = container_of(dcbase, DisasContext, base);
|
|
|
|
|
|
|
|
switch (dc->base.is_jmp) {
|
2020-01-16 17:54:54 +01:00
|
|
|
case DISAS_NORETURN:
|
|
|
|
break;
|
2018-05-12 07:02:48 +02:00
|
|
|
case DISAS_TOO_MANY:
|
|
|
|
update_cc_op(dc);
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_jmp_tb(dc, 0, dc->pc, dc->pc_prev);
|
2018-05-12 07:02:48 +02:00
|
|
|
break;
|
|
|
|
case DISAS_JUMP:
|
|
|
|
/* We updated CC_OP and PC in gen_jmp/gen_jmp_im. */
|
2021-07-19 09:27:53 +02:00
|
|
|
if (dc->ss_active) {
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_raise_exception_format2(dc, EXCP_TRACE, dc->pc_prev);
|
2020-01-16 17:54:54 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_lookup_and_goto_ptr();
|
|
|
|
}
|
2018-05-12 07:02:48 +02:00
|
|
|
break;
|
|
|
|
case DISAS_EXIT:
|
2019-06-07 01:41:25 +02:00
|
|
|
/*
|
|
|
|
* We updated CC_OP and PC in gen_exit_tb, but also modified
|
|
|
|
* other state that may require returning to the main loop.
|
|
|
|
*/
|
2021-07-19 09:27:53 +02:00
|
|
|
if (dc->ss_active) {
|
2022-06-02 03:33:52 +02:00
|
|
|
gen_raise_exception_format2(dc, EXCP_TRACE, dc->pc_prev);
|
2020-01-16 17:54:54 +01:00
|
|
|
} else {
|
|
|
|
tcg_gen_exit_tb(NULL, 0);
|
|
|
|
}
|
2018-05-12 07:02:48 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
2018-05-12 07:02:48 +02:00
|
|
|
}
|
|
|
|
|
2022-04-17 20:29:52 +02:00
|
|
|
static void m68k_tr_disas_log(const DisasContextBase *dcbase,
|
|
|
|
CPUState *cpu, FILE *logfile)
|
2018-05-12 07:02:48 +02:00
|
|
|
{
|
2022-04-17 20:29:52 +02:00
|
|
|
fprintf(logfile, "IN: %s\n", lookup_symbol(dcbase->pc_first));
|
|
|
|
target_disas(logfile, cpu, dcbase->pc_first, dcbase->tb->size);
|
2018-05-12 07:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const TranslatorOps m68k_tr_ops = {
|
|
|
|
.init_disas_context = m68k_tr_init_disas_context,
|
|
|
|
.tb_start = m68k_tr_tb_start,
|
|
|
|
.insn_start = m68k_tr_insn_start,
|
|
|
|
.translate_insn = m68k_tr_translate_insn,
|
|
|
|
.tb_stop = m68k_tr_tb_stop,
|
|
|
|
.disas_log = m68k_tr_disas_log,
|
|
|
|
};
|
|
|
|
|
2023-01-29 02:19:22 +01:00
|
|
|
void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int *max_insns,
|
2022-08-11 22:48:03 +02:00
|
|
|
target_ulong pc, void *host_pc)
|
2018-05-12 07:02:48 +02:00
|
|
|
{
|
|
|
|
DisasContext dc;
|
2022-08-11 22:48:03 +02:00
|
|
|
translator_loop(cpu, tb, max_insns, pc, host_pc, &m68k_tr_ops, &dc.base);
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|
|
|
|
|
2017-06-20 22:51:18 +02:00
|
|
|
static double floatx80_to_double(CPUM68KState *env, uint16_t high, uint64_t low)
|
|
|
|
{
|
|
|
|
floatx80 a = { .high = high, .low = low };
|
|
|
|
union {
|
|
|
|
float64 f64;
|
|
|
|
double d;
|
|
|
|
} u;
|
|
|
|
|
|
|
|
u.f64 = floatx80_to_float64(a, &env->fp_status);
|
|
|
|
return u.d;
|
|
|
|
}
|
|
|
|
|
2019-04-17 21:18:02 +02:00
|
|
|
void m68k_cpu_dump_state(CPUState *cs, FILE *f, int flags)
|
2006-10-22 02:18:54 +02:00
|
|
|
{
|
2013-05-27 01:33:50 +02:00
|
|
|
M68kCPU *cpu = M68K_CPU(cs);
|
|
|
|
CPUM68KState *env = &cpu->env;
|
2006-10-22 02:18:54 +02:00
|
|
|
int i;
|
|
|
|
uint16_t sr;
|
2017-06-20 22:51:18 +02:00
|
|
|
for (i = 0; i < 8; i++) {
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "D%d = %08x A%d = %08x "
|
|
|
|
"F%d = %04x %016"PRIx64" (%12g)\n",
|
|
|
|
i, env->dregs[i], i, env->aregs[i],
|
|
|
|
i, env->fregs[i].l.upper, env->fregs[i].l.lower,
|
|
|
|
floatx80_to_double(env, env->fregs[i].l.upper,
|
|
|
|
env->fregs[i].l.lower));
|
|
|
|
}
|
|
|
|
qemu_fprintf(f, "PC = %08x ", env->pc);
|
2015-08-14 16:59:17 +02:00
|
|
|
sr = env->sr | cpu_m68k_get_ccr(env);
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "SR = %04x T:%x I:%x %c%c %c%c%c%c%c\n",
|
|
|
|
sr, (sr & SR_T) >> SR_T_SHIFT, (sr & SR_I) >> SR_I_SHIFT,
|
|
|
|
(sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I',
|
|
|
|
(sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : '-',
|
|
|
|
(sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : '-',
|
|
|
|
(sr & CCF_C) ? 'C' : '-');
|
|
|
|
qemu_fprintf(f, "FPSR = %08x %c%c%c%c ", env->fpsr,
|
|
|
|
(env->fpsr & FPSR_CC_A) ? 'A' : '-',
|
|
|
|
(env->fpsr & FPSR_CC_I) ? 'I' : '-',
|
|
|
|
(env->fpsr & FPSR_CC_Z) ? 'Z' : '-',
|
|
|
|
(env->fpsr & FPSR_CC_N) ? 'N' : '-');
|
|
|
|
qemu_fprintf(f, "\n "
|
|
|
|
"FPCR = %04x ", env->fpcr);
|
2017-06-20 22:51:20 +02:00
|
|
|
switch (env->fpcr & FPCR_PREC_MASK) {
|
|
|
|
case FPCR_PREC_X:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "X ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case FPCR_PREC_S:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "S ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case FPCR_PREC_D:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "D ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (env->fpcr & FPCR_RND_MASK) {
|
|
|
|
case FPCR_RND_N:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "RN ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case FPCR_RND_Z:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "RZ ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case FPCR_RND_M:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "RM ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
case FPCR_RND_P:
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "RP ");
|
2017-06-20 22:51:20 +02:00
|
|
|
break;
|
|
|
|
}
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "\n");
|
2023-06-13 15:33:41 +02:00
|
|
|
#ifndef CONFIG_USER_ONLY
|
2019-04-17 21:18:02 +02:00
|
|
|
qemu_fprintf(f, "%sA7(MSP) = %08x %sA7(USP) = %08x %sA7(ISP) = %08x\n",
|
|
|
|
env->current_sp == M68K_SSP ? "->" : " ", env->sp[M68K_SSP],
|
|
|
|
env->current_sp == M68K_USP ? "->" : " ", env->sp[M68K_USP],
|
|
|
|
env->current_sp == M68K_ISP ? "->" : " ", env->sp[M68K_ISP]);
|
|
|
|
qemu_fprintf(f, "VBR = 0x%08x\n", env->vbr);
|
|
|
|
qemu_fprintf(f, "SFC = %x DFC %x\n", env->sfc, env->dfc);
|
|
|
|
qemu_fprintf(f, "SSW %08x TCR %08x URP %08x SRP %08x\n",
|
|
|
|
env->mmu.ssw, env->mmu.tcr, env->mmu.urp, env->mmu.srp);
|
|
|
|
qemu_fprintf(f, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n",
|
|
|
|
env->mmu.ttr[M68K_DTTR0], env->mmu.ttr[M68K_DTTR1],
|
|
|
|
env->mmu.ttr[M68K_ITTR0], env->mmu.ttr[M68K_ITTR1]);
|
|
|
|
qemu_fprintf(f, "MMUSR %08x, fault at %08x\n",
|
|
|
|
env->mmu.mmusr, env->mmu.ar);
|
2023-06-13 15:33:41 +02:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|
2006-10-22 02:18:54 +02:00
|
|
|
}
|