1996-08-29 03:06:42 +02:00
|
|
|
|
#include <signal.h>
|
1997-09-03 06:10:33 +02:00
|
|
|
|
#include "sim-main.h"
|
1996-08-29 03:06:42 +02:00
|
|
|
|
#include "v850_sim.h"
|
|
|
|
|
#include "simops.h"
|
1997-09-03 06:10:33 +02:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UTIME_H
|
|
|
|
|
#include <utime.h>
|
1997-09-03 09:30:17 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_TIME_H
|
|
|
|
|
#include <time.h>
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
#include <unistd.h>
|
1997-09-03 06:10:33 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#else
|
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
|
#include <strings.h>
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1997-09-01 05:43:56 +02:00
|
|
|
|
/* FIXME - should be including a version of syscall.h that does not
|
|
|
|
|
pollute the name space */
|
|
|
|
|
#include "../../libgloss/v850/sys/syscall.h"
|
1997-09-03 06:10:33 +02:00
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#include "libiberty.h"
|
|
|
|
|
|
1996-10-24 19:39:30 +02:00
|
|
|
|
#include <errno.h>
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1996-10-29 22:24:01 +01:00
|
|
|
|
#include <sys/stat.h>
|
1996-10-30 17:30:59 +01:00
|
|
|
|
#include <sys/times.h>
|
1996-10-31 20:58:14 +01:00
|
|
|
|
#include <sys/time.h>
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#endif
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* start-sanitize-v850e */
|
1997-09-15 16:42:51 +02:00
|
|
|
|
/* This is an array of the bit positions of registers r20 .. r31 in
|
|
|
|
|
that order in a prepare/dispose instruction. */
|
|
|
|
|
int type1_regs[12] = { 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 0, 21 };
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850eq */
|
1997-09-15 16:42:51 +02:00
|
|
|
|
/* This is an array of the bit positions of registers r16 .. r31 in
|
|
|
|
|
that order in a push/pop instruction. */
|
|
|
|
|
int type2_regs[16] = { 3, 2, 1, 0, 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 20, 21};
|
|
|
|
|
/* This is an array of the bit positions of registers r1 .. r15 in
|
|
|
|
|
that order in a push/pop instruction. */
|
|
|
|
|
int type3_regs[15] = { 2, 1, 0, 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 20, 21};
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
#ifndef SIZE_INSTRUCTION
|
1997-09-16 09:03:41 +02:00
|
|
|
|
#define SIZE_INSTRUCTION 18
|
1996-09-11 22:54:21 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SIZE_VALUES
|
|
|
|
|
#define SIZE_VALUES 11
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-16 09:03:41 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
unsigned32 trace_values[3];
|
|
|
|
|
int trace_num_values;
|
|
|
|
|
unsigned32 trace_pc;
|
|
|
|
|
const char *trace_name;
|
1997-09-17 07:31:00 +02:00
|
|
|
|
const char *trace_module;
|
1996-09-12 18:06:02 +02:00
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
void
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input (name, type, size)
|
|
|
|
|
char *name;
|
|
|
|
|
enum op_types type;
|
|
|
|
|
int size;
|
|
|
|
|
{
|
|
|
|
|
|
1997-09-10 07:40:04 +02:00
|
|
|
|
if (!TRACE_ALU_P (STATE_CPU (simulator, 0)))
|
1996-09-11 22:54:21 +02:00
|
|
|
|
return;
|
|
|
|
|
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_pc = PC;
|
|
|
|
|
trace_name = name;
|
1997-09-17 07:31:00 +02:00
|
|
|
|
trace_module = "alu";
|
1996-09-11 22:54:21 +02:00
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case OP_UNKNOWN:
|
|
|
|
|
case OP_NONE:
|
|
|
|
|
case OP_TRAP:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_num_values = 0;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_REG:
|
1997-09-15 10:18:20 +02:00
|
|
|
|
case OP_REG_REG_MOVE:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.regs[OP[0]];
|
|
|
|
|
trace_num_values = 1;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
case OP_BIT_CHANGE:
|
|
|
|
|
/* end-sanitize-v850e */
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_REG_REG:
|
|
|
|
|
case OP_REG_REG_CMP:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.regs[OP[1]];
|
|
|
|
|
trace_values[1] = State.regs[OP[0]];
|
|
|
|
|
trace_num_values = 2;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_IMM_REG:
|
|
|
|
|
case OP_IMM_REG_CMP:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = SEXT5 (OP[0]);
|
|
|
|
|
trace_values[1] = OP[1];
|
|
|
|
|
trace_num_values = 2;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
break;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_IMM_REG_MOVE:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = SEXT5 (OP[0]);
|
|
|
|
|
trace_num_values = 1;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_COND_BR:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.pc;
|
|
|
|
|
trace_values[1] = SEXT9 (OP[0]);
|
|
|
|
|
trace_values[2] = PSW;
|
|
|
|
|
trace_num_values = 3;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_LOAD16:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = OP[1] * size;
|
|
|
|
|
trace_values[1] = State.regs[30];
|
|
|
|
|
trace_num_values = 2;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_STORE16:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.regs[OP[0]];
|
|
|
|
|
trace_values[1] = OP[1] * size;
|
|
|
|
|
trace_values[2] = State.regs[30];
|
|
|
|
|
trace_num_values = 3;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_LOAD32:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = EXTEND16 (OP[2]);
|
|
|
|
|
trace_values[1] = State.regs[OP[0]];
|
|
|
|
|
trace_num_values = 2;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_STORE32:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.regs[OP[1]];
|
|
|
|
|
trace_values[1] = EXTEND16 (OP[2]);
|
|
|
|
|
trace_values[2] = State.regs[OP[0]];
|
|
|
|
|
trace_num_values = 3;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_JUMP:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = SEXT22 (OP[0]);
|
|
|
|
|
trace_values[1] = State.pc;
|
|
|
|
|
trace_num_values = 2;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_IMM_REG_REG:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = EXTEND16 (OP[0]) << size;
|
|
|
|
|
trace_values[1] = State.regs[OP[1]];
|
|
|
|
|
trace_num_values = 2;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
case OP_IMM16_REG_REG:
|
|
|
|
|
trace_values[0] = EXTEND16 (OP[2]) << size;
|
|
|
|
|
trace_values[1] = State.regs[OP[1]];
|
|
|
|
|
trace_num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_UIMM_REG_REG:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = (OP[0] & 0xffff) << size;
|
|
|
|
|
trace_values[1] = State.regs[OP[1]];
|
|
|
|
|
trace_num_values = 2;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
case OP_UIMM16_REG_REG:
|
|
|
|
|
trace_values[0] = (OP[2]) << size;
|
|
|
|
|
trace_values[1] = State.regs[OP[1]];
|
|
|
|
|
trace_num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_BIT:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_num_values = 0;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_EX1:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = PSW;
|
|
|
|
|
trace_num_values = 1;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
break;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_EX2:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_num_values = 0;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
case OP_LDSR:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.regs[OP[0]];
|
|
|
|
|
trace_num_values = 1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
break;
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
|
|
|
|
case OP_STSR:
|
1997-09-16 09:03:41 +02:00
|
|
|
|
trace_values[0] = State.sregs[OP[1]];
|
|
|
|
|
trace_num_values = 1;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
}
|
1997-09-15 10:18:20 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
void
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_result (int has_result, unsigned32 result)
|
1996-09-11 22:54:21 +02:00
|
|
|
|
{
|
1997-09-16 09:03:41 +02:00
|
|
|
|
char buf[1000];
|
|
|
|
|
char *chp;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
|
1997-09-16 09:03:41 +02:00
|
|
|
|
buf[0] = '\0';
|
|
|
|
|
chp = buf;
|
|
|
|
|
|
|
|
|
|
/* write out the values saved during the trace_input call */
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < trace_num_values; i++)
|
|
|
|
|
{
|
|
|
|
|
sprintf (chp, "%*s0x%.8lx", SIZE_VALUES - 10, "", trace_values[i]);
|
|
|
|
|
chp = strchr (chp, '\0');
|
|
|
|
|
}
|
|
|
|
|
while (i++ < 3)
|
|
|
|
|
{
|
|
|
|
|
sprintf (chp, "%*s", SIZE_VALUES, "");
|
|
|
|
|
chp = strchr (chp, '\0');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
/* append any result to the end of the buffer */
|
|
|
|
|
if (has_result)
|
|
|
|
|
sprintf (chp, " :: 0x%.8lx", (unsigned long)result);
|
|
|
|
|
|
|
|
|
|
trace_one_insn (simulator, STATE_CPU (simulator, 0), trace_pc,
|
|
|
|
|
TRACE_LINENUM_P (STATE_CPU (simulator, 0)),
|
1997-09-17 07:31:00 +02:00
|
|
|
|
"simops", __LINE__, trace_module,
|
1997-09-16 16:00:15 +02:00
|
|
|
|
"%-*s -%s", SIZE_INSTRUCTION, trace_name, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
trace_output (result)
|
|
|
|
|
enum op_types result;
|
|
|
|
|
{
|
|
|
|
|
if (!TRACE_ALU_P (STATE_CPU (simulator, 0)))
|
|
|
|
|
return;
|
|
|
|
|
|
1997-09-16 09:03:41 +02:00
|
|
|
|
switch (result)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case OP_UNKNOWN:
|
|
|
|
|
case OP_NONE:
|
|
|
|
|
case OP_TRAP:
|
|
|
|
|
case OP_REG:
|
|
|
|
|
case OP_REG_REG_CMP:
|
|
|
|
|
case OP_IMM_REG_CMP:
|
|
|
|
|
case OP_COND_BR:
|
|
|
|
|
case OP_STORE16:
|
|
|
|
|
case OP_STORE32:
|
|
|
|
|
case OP_BIT:
|
|
|
|
|
case OP_EX2:
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_result (0, 0);
|
1997-09-16 09:03:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LOAD16:
|
|
|
|
|
case OP_STSR:
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_result (1, State.regs[OP[0]]);
|
1997-09-16 09:03:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_REG_REG:
|
|
|
|
|
case OP_REG_REG_MOVE:
|
|
|
|
|
case OP_IMM_REG:
|
|
|
|
|
case OP_IMM_REG_MOVE:
|
|
|
|
|
case OP_LOAD32:
|
|
|
|
|
case OP_EX1:
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_result (1, State.regs[OP[1]]);
|
1997-09-16 09:03:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG_REG:
|
|
|
|
|
case OP_UIMM_REG_REG:
|
1997-09-16 16:00:15 +02:00
|
|
|
|
case OP_IMM16_REG_REG:
|
|
|
|
|
case OP_UIMM16_REG_REG:
|
|
|
|
|
trace_result (1, State.regs[OP[1]]);
|
1997-09-16 09:03:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_JUMP:
|
|
|
|
|
if (OP[1] != 0)
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_result (1, State.regs[OP[1]]);
|
|
|
|
|
else
|
|
|
|
|
trace_result (0, 0);
|
1997-09-16 09:03:41 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LDSR:
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_result (1, State.sregs[OP[1]]);
|
1997-09-16 09:03:41 +02:00
|
|
|
|
break;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
}
|
1997-09-16 09:03:41 +02:00
|
|
|
|
}
|
1996-09-11 22:54:21 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
/* Returns 1 if the specific condition is met, returns 0 otherwise. */
|
1997-09-19 04:20:02 +02:00
|
|
|
|
int
|
1997-08-20 22:57:05 +02:00
|
|
|
|
condition_met (unsigned code)
|
|
|
|
|
{
|
|
|
|
|
unsigned int psw = PSW;
|
|
|
|
|
|
|
|
|
|
switch (code & 0xf)
|
|
|
|
|
{
|
|
|
|
|
case 0x0: return ((psw & PSW_OV) != 0);
|
|
|
|
|
case 0x1: return ((psw & PSW_CY) != 0);
|
|
|
|
|
case 0x2: return ((psw & PSW_Z) != 0);
|
|
|
|
|
case 0x3: return ((((psw & PSW_CY) != 0) | ((psw & PSW_Z) != 0)) != 0);
|
|
|
|
|
case 0x4: return ((psw & PSW_S) != 0);
|
|
|
|
|
/*case 0x5: return 1;*/
|
|
|
|
|
case 0x6: return ((((psw & PSW_S) != 0) ^ ((psw & PSW_OV) != 0)) != 0);
|
|
|
|
|
case 0x7: return (((((psw & PSW_S) != 0) ^ ((psw & PSW_OV) != 0)) || ((psw & PSW_Z) != 0)) != 0);
|
|
|
|
|
case 0x8: return ((psw & PSW_OV) == 0);
|
|
|
|
|
case 0x9: return ((psw & PSW_CY) == 0);
|
|
|
|
|
case 0xa: return ((psw & PSW_Z) == 0);
|
|
|
|
|
case 0xb: return ((((psw & PSW_CY) != 0) | ((psw & PSW_Z) != 0)) == 0);
|
|
|
|
|
case 0xc: return ((psw & PSW_S) == 0);
|
|
|
|
|
case 0xd: return ((psw & PSW_SAT) != 0);
|
|
|
|
|
case 0xe: return ((((psw & PSW_S) != 0) ^ ((psw & PSW_OV) != 0)) == 0);
|
|
|
|
|
case 0xf: return (((((psw & PSW_S) != 0) ^ ((psw & PSW_OV) != 0)) || ((psw & PSW_Z) != 0)) == 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
static unsigned long
|
|
|
|
|
Add32 (unsigned long a1, unsigned long a2, int * carry)
|
|
|
|
|
{
|
|
|
|
|
unsigned long result = (a1 + a2);
|
|
|
|
|
|
|
|
|
|
* carry = (result < a1);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
Multiply64 (boolean sign, unsigned long op0)
|
|
|
|
|
{
|
|
|
|
|
unsigned long op1;
|
|
|
|
|
unsigned long lo;
|
|
|
|
|
unsigned long mid1;
|
|
|
|
|
unsigned long mid2;
|
|
|
|
|
unsigned long hi;
|
|
|
|
|
unsigned long RdLo;
|
|
|
|
|
unsigned long RdHi;
|
|
|
|
|
int carry;
|
|
|
|
|
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
|
|
|
|
|
|
|
|
|
if (sign)
|
|
|
|
|
{
|
|
|
|
|
/* Compute sign of result and adjust operands if necessary. */
|
|
|
|
|
|
|
|
|
|
sign = (op0 ^ op1) & 0x80000000;
|
|
|
|
|
|
|
|
|
|
if (((signed long) op0) < 0)
|
|
|
|
|
op0 = - op0;
|
|
|
|
|
|
|
|
|
|
if (((signed long) op1) < 0)
|
|
|
|
|
op1 = - op1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We can split the 32x32 into four 16x16 operations. This ensures
|
|
|
|
|
that we do not lose precision on 32bit only hosts: */
|
|
|
|
|
lo = ( (op0 & 0xFFFF) * (op1 & 0xFFFF));
|
|
|
|
|
mid1 = ( (op0 & 0xFFFF) * ((op1 >> 16) & 0xFFFF));
|
|
|
|
|
mid2 = (((op0 >> 16) & 0xFFFF) * (op1 & 0xFFFF));
|
|
|
|
|
hi = (((op0 >> 16) & 0xFFFF) * ((op1 >> 16) & 0xFFFF));
|
|
|
|
|
|
|
|
|
|
/* We now need to add all of these results together, taking care
|
|
|
|
|
to propogate the carries from the additions: */
|
|
|
|
|
RdLo = Add32 (lo, (mid1 << 16), & carry);
|
|
|
|
|
RdHi = carry;
|
|
|
|
|
RdLo = Add32 (RdLo, (mid2 << 16), & carry);
|
|
|
|
|
RdHi += (carry + ((mid1 >> 16) & 0xFFFF) + ((mid2 >> 16) & 0xFFFF) + hi);
|
|
|
|
|
|
|
|
|
|
if (sign)
|
|
|
|
|
{
|
|
|
|
|
/* Negate result if necessary. */
|
|
|
|
|
|
|
|
|
|
RdLo = ~ RdLo;
|
|
|
|
|
RdHi = ~ RdHi;
|
|
|
|
|
if (RdLo == 0xFFFFFFFF)
|
|
|
|
|
{
|
|
|
|
|
RdLo = 0;
|
|
|
|
|
RdHi += 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
RdLo += 1;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-16 03:45:23 +02:00
|
|
|
|
/* Don't store into register 0. */
|
|
|
|
|
if (OP[1])
|
|
|
|
|
State.regs[ OP[1] ] = RdLo;
|
|
|
|
|
if (OP[2] >> 11)
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = RdHi;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
1997-09-04 12:10:02 +02:00
|
|
|
|
|
|
|
|
|
/* Read a null terminated string from memory, return in a buffer */
|
|
|
|
|
static char *
|
|
|
|
|
fetch_str (sd, addr)
|
|
|
|
|
SIM_DESC sd;
|
|
|
|
|
address_word addr;
|
|
|
|
|
{
|
|
|
|
|
char *buf;
|
|
|
|
|
int nr = 0;
|
|
|
|
|
while (sim_core_read_1 (STATE_CPU (sd, 0),
|
|
|
|
|
PC, sim_core_read_map, addr + nr) != 0)
|
|
|
|
|
nr++;
|
|
|
|
|
buf = NZALLOC (char, nr + 1);
|
|
|
|
|
sim_read (simulator, addr, buf, nr);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Read a null terminated argument vector from memory, return in a
|
|
|
|
|
buffer */
|
|
|
|
|
static char **
|
|
|
|
|
fetch_argv (sd, addr)
|
|
|
|
|
SIM_DESC sd;
|
|
|
|
|
address_word addr;
|
|
|
|
|
{
|
|
|
|
|
int max_nr = 64;
|
|
|
|
|
int nr = 0;
|
|
|
|
|
char **buf = xmalloc (max_nr * sizeof (char*));
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
unsigned32 a = sim_core_read_4 (STATE_CPU (sd, 0),
|
|
|
|
|
PC, sim_core_read_map, addr + nr * 4);
|
|
|
|
|
if (a == 0) break;
|
|
|
|
|
buf[nr] = fetch_str (sd, a);
|
|
|
|
|
nr ++;
|
|
|
|
|
if (nr == max_nr - 1)
|
|
|
|
|
{
|
|
|
|
|
max_nr += 50;
|
|
|
|
|
buf = xrealloc (buf, max_nr * sizeof (char*));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buf[nr] = 0;
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
/* sst.b */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_380 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("sst.b", OP_STORE16, 1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[30] + (OP[3] & 0x7f), 1, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_STORE16);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sst.h */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_480 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("sst.h", OP_STORE16, 2);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[30] + ((OP[3] & 0x7f) << 1), 2, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_STORE16);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sst.w */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_501 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("sst.w", OP_STORE16, 4);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[30] + ((OP[3] & 0x7e) << 1), 4, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_STORE16);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ld.b */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_700 ()
|
|
|
|
|
{
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int adr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("ld.b", OP_LOAD32, 1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
adr = State.regs[ OP[0] ] + EXTEND16 (OP[2]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
State.regs[ OP[1] ] = EXTEND8 (load_mem (adr, 1));
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ld.h */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_720 ()
|
|
|
|
|
{
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int adr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("ld.h", OP_LOAD32, 2);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
adr = State.regs[ OP[0] ] + EXTEND16 (OP[2]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
adr &= ~0x1;
|
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
State.regs[ OP[1] ] = EXTEND16 (load_mem (adr, 2));
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ld.w */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_10720 ()
|
|
|
|
|
{
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int adr;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("ld.w", OP_LOAD32, 4);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
adr = State.regs[ OP[0] ] + EXTEND16 (OP[2] & ~1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
adr &= ~0x3;
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = load_mem (adr, 4);
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* st.b */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_740 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("st.b", OP_STORE32, 1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
store_mem (State.regs[ OP[0] ] + EXTEND16 (OP[2]), 1, State.regs[ OP[1] ]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_STORE32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* st.h */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 03:06:42 +02:00
|
|
|
|
OP_760 ()
|
|
|
|
|
{
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int adr;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("st.h", OP_STORE32, 2);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
adr = State.regs[ OP[0] ] + EXTEND16 (OP[2]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
adr &= ~1;
|
|
|
|
|
|
|
|
|
|
store_mem (adr, 2, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_STORE32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* st.w */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_10760 ()
|
|
|
|
|
{
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int adr;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("st.w", OP_STORE32, 4);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
adr = State.regs[ OP[0] ] + EXTEND16 (OP[2] & ~1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
adr &= ~3;
|
|
|
|
|
|
|
|
|
|
store_mem (adr, 4, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_STORE32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* add reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_1C0 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-08-30 01:39:23 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("add", OP_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 + op1;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (result < op0 || result < op1);
|
|
|
|
|
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 07:09:08 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add sign_extend(imm5), reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_240 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-08-30 01:39:23 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
int temp;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("add", OP_IMM_REG, 0);
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1996-09-11 22:54:21 +02:00
|
|
|
|
temp = SEXT5 (OP[0]);
|
1996-08-30 01:39:23 +02:00
|
|
|
|
op0 = temp;
|
|
|
|
|
op1 = State.regs[OP[1]];
|
|
|
|
|
result = op0 + op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (result < op0 || result < op1);
|
|
|
|
|
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 01:39:23 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* addi sign_extend(imm16), reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_600 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-08-30 01:39:23 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("addi", OP_IMM16_REG_REG, 0);
|
1996-09-11 22:54:21 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
op0 = EXTEND16 (OP[2]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 + op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (result < op0 || result < op1);
|
|
|
|
|
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 01:39:23 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_IMM16_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* sub reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_1A0 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-08-30 05:07:24 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("sub", OP_REG_REG, 0);
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:07:24 +02:00
|
|
|
|
result = op1 - op0;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 05:07:24 +02:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:07:24 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 05:07:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* subr reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_180 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-08-30 05:07:24 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("subr", OP_REG_REG, 0);
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:07:24 +02:00
|
|
|
|
result = op0 - op1;
|
1996-08-29 22:08:37 +02:00
|
|
|
|
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
cy = (op0 < op1);
|
1996-08-30 05:07:24 +02:00
|
|
|
|
ov = ((op0 & 0x80000000) != (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:07:24 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 05:07:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* sxh reg1 */
|
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_E0 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("mulh", OP_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
State.regs[ OP[1] ] = (EXTEND16 (State.regs[ OP[1] ]) * EXTEND16 (State.regs[ OP[0] ]));
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* mulh sign_extend(imm5), reg2 */
|
|
|
|
|
int
|
|
|
|
|
OP_2E0 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("mulh", OP_IMM_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
State.regs[ OP[1] ] = EXTEND16 (State.regs[ OP[1] ]) * SEXT5 (OP[0]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* mulhi imm16, reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_6E0 ()
|
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("mulhi", OP_IMM16_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
State.regs[ OP[1] ] = EXTEND16 (State.regs[ OP[0] ]) * EXTEND16 (OP[2]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_IMM16_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 22:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 05:07:24 +02:00
|
|
|
|
/* divh reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_40 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
unsigned int op0, op1, result, ov, s, z;
|
|
|
|
|
int temp;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("divh", OP_REG_REG, 0);
|
1996-08-30 05:07:24 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
/* Compute the result. */
|
|
|
|
|
temp = EXTEND16 (State.regs[ OP[0] ]);
|
|
|
|
|
op0 = temp;
|
|
|
|
|
op1 = State.regs[OP[1]];
|
|
|
|
|
|
|
|
|
|
if (op0 == 0xffffffff && op1 == 0x80000000)
|
|
|
|
|
{
|
|
|
|
|
result = 0x80000000;
|
|
|
|
|
ov = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (op0 != 0)
|
|
|
|
|
{
|
|
|
|
|
result = op1 / op0;
|
|
|
|
|
ov = 0;
|
1996-08-30 05:07:24 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
1996-09-03 20:31:48 +02:00
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
result = 0x0;
|
|
|
|
|
ov = 1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
}
|
1997-09-16 16:00:15 +02:00
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
|
|
|
|
| (ov ? PSW_OV : 0));
|
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 06:11:32 +02:00
|
|
|
|
/* cmp reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:11:32 +02:00
|
|
|
|
OP_1E0 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("cmp", OP_REG_REG_CMP, 0);
|
1996-08-30 06:11:32 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 06:11:32 +02:00
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 06:11:32 +02:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 06:11:32 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG_CMP);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 06:11:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cmp sign_extend(imm5), reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:11:32 +02:00
|
|
|
|
OP_260 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("cmp", OP_IMM_REG_CMP, 0);
|
|
|
|
|
temp = SEXT5 (OP[0]);
|
1996-08-30 06:11:32 +02:00
|
|
|
|
op0 = temp;
|
|
|
|
|
op1 = State.regs[OP[1]];
|
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 06:11:32 +02:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 06:11:32 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG_CMP);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 06:11:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* setf cccc,reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:11:32 +02:00
|
|
|
|
OP_7E0 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("setf", OP_EX1, 0);
|
1996-08-30 06:11:32 +02:00
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
State.regs[ OP[1] ] = condition_met (OP[0]);
|
1996-08-30 06:11:32 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_EX1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 06:11:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 06:59:02 +02:00
|
|
|
|
/* satadd reg,reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:59:02 +02:00
|
|
|
|
OP_C0 ()
|
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
|
|
|
|
|
trace_input ("satadd", OP_REG_REG, 0);
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
|
|
|
|
result = op0 + op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (result < op0 || result < op1);
|
|
|
|
|
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
sat = ov;
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
|
|
|
|
if (sat && s)
|
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
|
|
|
|
trace_output (OP_REG_REG);
|
1996-08-30 06:59:02 +02:00
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
return 2;
|
1996-08-30 06:59:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* satadd sign_extend(imm5), reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:59:02 +02:00
|
|
|
|
OP_220 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
|
|
|
|
|
int temp;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("satadd", OP_IMM_REG, 0);
|
|
|
|
|
|
1996-08-30 06:59:02 +02:00
|
|
|
|
/* Compute the result. */
|
1996-09-11 22:54:21 +02:00
|
|
|
|
temp = SEXT5 (OP[0]);
|
1996-08-30 06:59:02 +02:00
|
|
|
|
op0 = temp;
|
|
|
|
|
op1 = State.regs[OP[1]];
|
|
|
|
|
result = op0 + op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (result < op0 || result < op1);
|
|
|
|
|
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
sat = ov;
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 06:59:02 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
1996-08-30 18:41:39 +02:00
|
|
|
|
if (sat && s)
|
1996-08-30 06:59:02 +02:00
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 06:59:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* satsub reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:59:02 +02:00
|
|
|
|
OP_A0 ()
|
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
|
|
|
|
|
trace_input ("satsub", OP_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 < op0);
|
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
sat = ov;
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
|
|
|
|
if (sat && s)
|
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
return 2;
|
1996-08-30 06:59:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* satsubi sign_extend(imm16), reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:59:02 +02:00
|
|
|
|
OP_660 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
int temp;
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("satsubi", OP_IMM_REG, 0);
|
|
|
|
|
|
1996-08-30 06:59:02 +02:00
|
|
|
|
/* Compute the result. */
|
1997-09-08 19:42:48 +02:00
|
|
|
|
temp = EXTEND16 (OP[2]);
|
1996-08-30 06:59:02 +02:00
|
|
|
|
op0 = temp;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-30 06:59:02 +02:00
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 06:59:02 +02:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
sat = ov;
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 06:59:02 +02:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
1996-08-30 18:41:39 +02:00
|
|
|
|
if (sat && s)
|
1996-08-30 06:59:02 +02:00
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 06:59:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
/* satsubr reg,reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:59:02 +02:00
|
|
|
|
OP_80 ()
|
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
|
|
|
|
|
trace_input ("satsubr", OP_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
|
|
|
|
result = op0 - op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (result < op0);
|
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
sat = ov;
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
|
|
|
|
if (sat && s)
|
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
|
|
|
|
trace_output (OP_REG_REG);
|
1996-08-30 06:59:02 +02:00
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
return 2;
|
1996-08-30 06:59:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 06:11:32 +02:00
|
|
|
|
/* tst reg,reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 06:11:32 +02:00
|
|
|
|
OP_160 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-30 06:11:32 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("tst", OP_REG_REG_CMP, 0);
|
|
|
|
|
|
1996-08-30 06:11:32 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 06:11:32 +02:00
|
|
|
|
result = op0 & op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the condition codes. */
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG_CMP);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 06:11:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-29 21:53:37 +02:00
|
|
|
|
/* mov sign_extend(imm5), reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_200 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
int value = SEXT5 (OP[0]);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("mov", OP_IMM_REG_MOVE, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
State.regs[ OP[1] ] = value;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_MOVE);
|
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-29 21:53:37 +02:00
|
|
|
|
/* movhi imm16, reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_640 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("movhi", OP_UIMM16_REG_REG, 16);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
State.regs[ OP[1] ] = State.regs[ OP[0] ] + (OP[2] << 16);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_UIMM16_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* sar zero_extend(imm5),reg1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 00:29:41 +02:00
|
|
|
|
OP_2A0 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("sar", OP_IMM_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = OP[0];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:23:36 +02:00
|
|
|
|
result = (signed)op1 >> op0;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (op0 - 1)));
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
State.regs[ OP[1] ] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-09-03 20:31:48 +02:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
}
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* sar reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 00:29:41 +02:00
|
|
|
|
OP_A007E0 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("sar", OP_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
op0 = State.regs[ OP[0] ] & 0x1f;
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:23:36 +02:00
|
|
|
|
result = (signed)op1 >> op0;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (op0 - 1)));
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:23:36 +02:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
}
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* shl zero_extend(imm5),reg1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 03:06:42 +02:00
|
|
|
|
OP_2C0 ()
|
1996-08-30 00:29:41 +02:00
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("shl", OP_IMM_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = OP[0];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:23:36 +02:00
|
|
|
|
result = op1 << op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (32 - op0)));
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:23:36 +02:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
}
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* shl reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 00:29:41 +02:00
|
|
|
|
OP_C007E0 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("shl", OP_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ] & 0x1f;
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:23:36 +02:00
|
|
|
|
result = op1 << op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (32 - op0)));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:23:36 +02:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
}
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* shr zero_extend(imm5),reg1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 00:29:41 +02:00
|
|
|
|
OP_280 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("shr", OP_IMM_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = OP[0];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:23:36 +02:00
|
|
|
|
result = op1 >> op0;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
|
1996-08-30 05:23:36 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (op0 - 1)));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:23:36 +02:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* shr reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 00:29:41 +02:00
|
|
|
|
OP_8007E0 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 05:23:36 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("shr", OP_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ] & 0x1f;
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 05:23:36 +02:00
|
|
|
|
result = op1 >> op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (op0 - 1)));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:23:36 +02:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 00:29:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* or reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_100 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("or", OP_REG_REG, 0);
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 | op1;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ori zero_extend(imm16), reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_680 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("ori", OP_UIMM16_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = OP[2];
|
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 | op1;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_UIMM16_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* and reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 03:06:42 +02:00
|
|
|
|
OP_140 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("and", OP_REG_REG, 0);
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 & op1;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* andi zero_extend(imm16), reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_6C0 ()
|
|
|
|
|
{
|
1997-08-20 22:57:05 +02:00
|
|
|
|
unsigned int result, z;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("andi", OP_UIMM16_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
result = OP[2] & State.regs[ OP[0] ];
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
State.regs[ OP[1] ] = result;
|
|
|
|
|
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= (z ? PSW_Z : 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_UIMM16_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* xor reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_120 ()
|
1996-08-29 03:06:42 +02:00
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("xor", OP_REG_REG, 0);
|
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 ^ op1;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* xori zero_extend(imm16), reg, reg */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 21:53:37 +02:00
|
|
|
|
OP_6A0 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_input ("xori", OP_UIMM16_REG_REG, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = OP[2];
|
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = op0 ^ op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1997-09-16 16:00:15 +02:00
|
|
|
|
trace_output (OP_UIMM16_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* not reg1, reg2 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-30 01:39:23 +02:00
|
|
|
|
OP_20 ()
|
|
|
|
|
{
|
1996-09-03 20:31:48 +02:00
|
|
|
|
unsigned int op0, result, z, s;
|
1996-08-30 01:39:23 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("not", OP_REG_REG_MOVE, 0);
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 01:39:23 +02:00
|
|
|
|
result = ~op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-08-29 21:53:37 +02:00
|
|
|
|
|
1996-08-30 01:39:23 +02:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_REG_REG_MOVE);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 03:06:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
/* set1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_7C0 ()
|
1996-08-29 21:53:37 +02:00
|
|
|
|
{
|
1996-08-30 18:35:10 +02:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 20:31:48 +02:00
|
|
|
|
int temp;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("set1", OP_BIT, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1997-09-08 19:42:48 +02:00
|
|
|
|
temp = EXTEND16 (OP[2]);
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op2 = temp;
|
1996-10-24 19:39:30 +02:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW |= PSW_Z;
|
1996-08-30 23:55:26 +02:00
|
|
|
|
temp |= (1 << op1);
|
1996-10-24 19:39:30 +02:00
|
|
|
|
store_mem (op0 + op2, 1, temp);
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
/* not1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_47C0 ()
|
1996-08-29 21:53:37 +02:00
|
|
|
|
{
|
1996-08-30 18:35:10 +02:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 20:31:48 +02:00
|
|
|
|
int temp;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("not1", OP_BIT, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1997-09-08 19:42:48 +02:00
|
|
|
|
temp = EXTEND16 (OP[2]);
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op2 = temp;
|
1996-10-24 19:39:30 +02:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW |= PSW_Z;
|
1996-08-30 23:55:26 +02:00
|
|
|
|
temp ^= (1 << op1);
|
1996-10-24 19:39:30 +02:00
|
|
|
|
store_mem (op0 + op2, 1, temp);
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
/* clr1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_87C0 ()
|
|
|
|
|
{
|
1996-08-30 18:35:10 +02:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 20:31:48 +02:00
|
|
|
|
int temp;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("clr1", OP_BIT, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1997-09-08 19:42:48 +02:00
|
|
|
|
temp = EXTEND16 (OP[2]);
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op2 = temp;
|
1996-10-24 19:39:30 +02:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW |= PSW_Z;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
temp &= ~(1 << op1);
|
1996-10-24 19:39:30 +02:00
|
|
|
|
store_mem (op0 + op2, 1, temp);
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* tst1 */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
* v850_sim.h: The V850 doesn't have split I&D spaces. Change
accordingly. Remove many unused definitions.
* interp.c: The V850 doesn't have split I&D spaces. Change
accordingly.
(get_longlong, get_longword, get_word): Deleted.
(write_longlong, write_longword, write_word): Deleted.
(get_operands): Deleted.
(get_byte, get_half, get_word): New functions.
(put_byte, put_half, put_word): New functions.
* simops.c: Remove unused functions. Rough cut at
"ld.b", "ld.h", "ld.w", "st.b", "st.h", "st.w" insns.
1996-08-30 07:41:10 +02:00
|
|
|
|
OP_C7C0 ()
|
1996-08-29 21:53:37 +02:00
|
|
|
|
{
|
1996-08-30 18:35:10 +02:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 20:31:48 +02:00
|
|
|
|
int temp;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("tst1", OP_BIT, 0);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1997-09-08 19:42:48 +02:00
|
|
|
|
temp = EXTEND16 (OP[2]);
|
1996-08-30 18:35:10 +02:00
|
|
|
|
op2 = temp;
|
1996-10-24 19:39:30 +02:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 18:35:10 +02:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW |= PSW_Z;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 21:53:37 +02:00
|
|
|
|
}
|
1996-08-29 22:08:37 +02:00
|
|
|
|
|
1996-08-30 06:11:32 +02:00
|
|
|
|
/* di */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_16007E0 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("di", OP_NONE, 0);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW |= PSW_ID;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_NONE);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 22:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 06:11:32 +02:00
|
|
|
|
/* ei */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_16087E0 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("ei", OP_NONE, 0);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
PSW &= ~PSW_ID;
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_NONE);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 22:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-27 20:50:03 +01:00
|
|
|
|
/* halt */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_12007E0 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("halt", OP_NONE, 0);
|
1996-12-27 20:50:03 +01:00
|
|
|
|
/* FIXME this should put processor into a mode where NMI still handled */
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_output (OP_NONE);
|
1997-09-08 19:42:48 +02:00
|
|
|
|
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
|
|
|
|
|
sim_stopped, SIGTRAP);
|
|
|
|
|
return 0;
|
1996-08-29 22:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-27 20:50:03 +01:00
|
|
|
|
/* trap */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
int
|
1996-08-29 22:08:37 +02:00
|
|
|
|
OP_10007E0 ()
|
|
|
|
|
{
|
1996-09-11 22:54:21 +02:00
|
|
|
|
trace_input ("trap", OP_TRAP, 0);
|
|
|
|
|
trace_output (OP_TRAP);
|
|
|
|
|
|
1996-10-24 19:39:30 +02:00
|
|
|
|
/* Trap 31 is used for simulating OS I/O functions */
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
1996-10-24 19:39:30 +02:00
|
|
|
|
if (OP[0] == 31)
|
1996-09-03 18:25:51 +02:00
|
|
|
|
{
|
|
|
|
|
int save_errno = errno;
|
|
|
|
|
errno = 0;
|
|
|
|
|
|
|
|
|
|
/* Registers passed to trap 0 */
|
|
|
|
|
|
|
|
|
|
#define FUNC State.regs[6] /* function number, return value */
|
|
|
|
|
#define PARM1 State.regs[7] /* optional parm 1 */
|
|
|
|
|
#define PARM2 State.regs[8] /* optional parm 2 */
|
|
|
|
|
#define PARM3 State.regs[9] /* optional parm 3 */
|
|
|
|
|
|
|
|
|
|
/* Registers set by trap 0 */
|
|
|
|
|
|
|
|
|
|
#define RETVAL State.regs[10] /* return value */
|
|
|
|
|
#define RETERR State.regs[11] /* return error code */
|
|
|
|
|
|
|
|
|
|
/* Turn a pointer in a register into a pointer into real memory. */
|
|
|
|
|
|
1996-10-24 19:39:30 +02:00
|
|
|
|
#define MEMPTR(x) (map (x))
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
|
|
|
|
switch (FUNC)
|
|
|
|
|
{
|
1997-09-01 05:43:56 +02:00
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#ifdef HAVE_FORK
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#ifdef SYS_fork
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_fork:
|
|
|
|
|
RETVAL = fork ();
|
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#ifdef HAVE_EXECVE
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#ifdef SYS_execv
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_execve:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
|
|
|
|
char **argv = fetch_argv (simulator, PARM2);
|
|
|
|
|
char **envp = fetch_argv (simulator, PARM3);
|
|
|
|
|
RETVAL = execve (path, argv, envp);
|
|
|
|
|
zfree (path);
|
|
|
|
|
freeargv (argv);
|
|
|
|
|
freeargv (envp);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#if HAVE_EXECV
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#ifdef SYS_execv
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_execv:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
|
|
|
|
char **argv = fetch_argv (simulator, PARM2);
|
|
|
|
|
RETVAL = execv (path, argv);
|
|
|
|
|
zfree (path);
|
|
|
|
|
freeargv (argv);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#endif
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
1996-09-10 04:51:07 +02:00
|
|
|
|
#if 0
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#ifdef SYS_pipe
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_pipe:
|
|
|
|
|
{
|
|
|
|
|
reg_t buf;
|
|
|
|
|
int host_fd[2];
|
|
|
|
|
|
|
|
|
|
buf = PARM1;
|
|
|
|
|
RETVAL = pipe (host_fd);
|
|
|
|
|
SW (buf, host_fd[0]);
|
|
|
|
|
buf += sizeof(uint16);
|
|
|
|
|
SW (buf, host_fd[1]);
|
|
|
|
|
}
|
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#if 0
|
|
|
|
|
#ifdef SYS_wait
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_wait:
|
|
|
|
|
{
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
RETVAL = wait (&status);
|
|
|
|
|
SW (PARM1, status);
|
|
|
|
|
}
|
|
|
|
|
break;
|
1996-09-10 04:51:07 +02:00
|
|
|
|
#endif
|
1996-09-03 18:25:51 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#ifdef SYS_read
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_read:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *buf = zalloc (PARM3);
|
|
|
|
|
RETVAL = sim_io_read (simulator, PARM1, buf, PARM3);
|
|
|
|
|
sim_write (simulator, PARM2, buf, PARM3);
|
|
|
|
|
zfree (buf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_write
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_write:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *buf = zalloc (PARM3);
|
|
|
|
|
sim_read (simulator, PARM2, buf, PARM3);
|
|
|
|
|
if (PARM1 == 1)
|
|
|
|
|
RETVAL = sim_io_write_stdout (simulator, buf, PARM3);
|
|
|
|
|
else
|
|
|
|
|
RETVAL = sim_io_write (simulator, PARM1, buf, PARM3);
|
|
|
|
|
zfree (buf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_lseek
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_lseek:
|
1997-09-03 06:10:33 +02:00
|
|
|
|
RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_close
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_close:
|
1997-09-03 06:10:33 +02:00
|
|
|
|
RETVAL = sim_io_close (simulator, PARM1);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_open
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_open:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *buf = fetch_str (simulator, PARM1);
|
|
|
|
|
RETVAL = sim_io_open (simulator, buf, PARM2);
|
|
|
|
|
zfree (buf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_exit
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_exit:
|
1997-01-01 00:18:55 +01:00
|
|
|
|
if ((PARM1 & 0xffff0000) == 0xdead0000 && (PARM1 & 0xffff) != 0)
|
1997-09-08 19:42:48 +02:00
|
|
|
|
/* get signal encoded by kill */
|
|
|
|
|
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
|
|
|
|
|
sim_signalled, PARM1 & 0xffff);
|
1997-01-01 00:18:55 +01:00
|
|
|
|
else if (PARM1 == 0xdead)
|
1997-09-08 19:42:48 +02:00
|
|
|
|
/* old libraries */
|
|
|
|
|
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
|
|
|
|
|
sim_exited, SIGABRT);
|
1997-01-01 00:18:55 +01:00
|
|
|
|
else
|
1997-09-08 19:42:48 +02:00
|
|
|
|
/* PARM1 has exit status */
|
|
|
|
|
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
|
|
|
|
|
sim_exited, PARM1);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#ifdef SYS_stat
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_stat: /* added at hmsi */
|
|
|
|
|
/* stat system call */
|
|
|
|
|
{
|
|
|
|
|
struct stat host_stat;
|
|
|
|
|
reg_t buf;
|
1997-09-04 12:10:02 +02:00
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
RETVAL = stat (path, &host_stat);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
zfree (path);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
buf = PARM2;
|
|
|
|
|
|
1996-10-29 22:24:01 +01:00
|
|
|
|
/* Just wild-assed guesses. */
|
|
|
|
|
store_mem (buf, 2, host_stat.st_dev);
|
|
|
|
|
store_mem (buf + 2, 2, host_stat.st_ino);
|
|
|
|
|
store_mem (buf + 4, 4, host_stat.st_mode);
|
|
|
|
|
store_mem (buf + 8, 2, host_stat.st_nlink);
|
|
|
|
|
store_mem (buf + 10, 2, host_stat.st_uid);
|
|
|
|
|
store_mem (buf + 12, 2, host_stat.st_gid);
|
|
|
|
|
store_mem (buf + 14, 2, host_stat.st_rdev);
|
|
|
|
|
store_mem (buf + 16, 4, host_stat.st_size);
|
|
|
|
|
store_mem (buf + 20, 4, host_stat.st_atime);
|
|
|
|
|
store_mem (buf + 28, 4, host_stat.st_mtime);
|
|
|
|
|
store_mem (buf + 36, 4, host_stat.st_ctime);
|
1996-09-03 18:25:51 +02:00
|
|
|
|
}
|
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1996-09-03 18:25:51 +02:00
|
|
|
|
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#ifdef HAVE_CHOWN
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#ifdef SYS_chown
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_chown:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
|
|
|
|
RETVAL = chown (path, PARM2, PARM3);
|
|
|
|
|
zfree (path);
|
|
|
|
|
}
|
1996-09-03 18:25:51 +02:00
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAVE_CHMOD
|
1997-09-04 12:10:02 +02:00
|
|
|
|
#ifdef SYS_chmod
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_chmod:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
|
|
|
|
RETVAL = chmod (path, PARM2);
|
|
|
|
|
zfree (path);
|
|
|
|
|
}
|
1996-09-03 18:25:51 +02:00
|
|
|
|
break;
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#ifdef SYS_time
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#if HAVE_TIME
|
1996-10-30 16:51:39 +01:00
|
|
|
|
case SYS_time:
|
1996-12-27 20:50:03 +01:00
|
|
|
|
{
|
|
|
|
|
time_t now;
|
|
|
|
|
RETVAL = time (&now);
|
|
|
|
|
store_mem (PARM1, 4, now);
|
|
|
|
|
}
|
1996-10-30 16:51:39 +01:00
|
|
|
|
break;
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#endif
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#ifdef SYS_times
|
1996-10-30 17:30:59 +01:00
|
|
|
|
case SYS_times:
|
|
|
|
|
{
|
|
|
|
|
struct tms tms;
|
|
|
|
|
RETVAL = times (&tms);
|
|
|
|
|
store_mem (PARM1, 4, tms.tms_utime);
|
|
|
|
|
store_mem (PARM1 + 4, 4, tms.tms_stime);
|
|
|
|
|
store_mem (PARM1 + 8, 4, tms.tms_cutime);
|
|
|
|
|
store_mem (PARM1 + 12, 4, tms.tms_cstime);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#endif
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_gettimeofday
|
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1996-10-30 17:30:59 +01:00
|
|
|
|
case SYS_gettimeofday:
|
|
|
|
|
{
|
|
|
|
|
struct timeval t;
|
|
|
|
|
struct timezone tz;
|
|
|
|
|
RETVAL = gettimeofday (&t, &tz);
|
|
|
|
|
store_mem (PARM1, 4, t.tv_sec);
|
|
|
|
|
store_mem (PARM1 + 4, 4, t.tv_usec);
|
|
|
|
|
store_mem (PARM2, 4, tz.tz_minuteswest);
|
|
|
|
|
store_mem (PARM2 + 4, 4, tz.tz_dsttime);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-09-01 05:43:56 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#ifdef SYS_utime
|
1997-09-03 06:10:33 +02:00
|
|
|
|
#if HAVE_UTIME
|
1996-09-03 18:25:51 +02:00
|
|
|
|
case SYS_utime:
|
1997-09-04 12:10:02 +02:00
|
|
|
|
{
|
|
|
|
|
/* Cast the second argument to void *, to avoid type mismatch
|
|
|
|
|
if a prototype is present. */
|
|
|
|
|
sim_io_error (simulator, "Utime not supported");
|
|
|
|
|
/* RETVAL = utime (path, (void *) MEMPTR (PARM2)); */
|
|
|
|
|
}
|
1996-09-03 18:25:51 +02:00
|
|
|
|
break;
|
1997-04-17 08:05:19 +02:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1997-09-01 05:43:56 +02:00
|
|
|
|
|
1996-09-03 18:25:51 +02:00
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
RETERR = errno;
|
|
|
|
|
errno = save_errno;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-09-03 18:25:51 +02:00
|
|
|
|
}
|
1996-10-24 19:39:30 +02:00
|
|
|
|
else
|
|
|
|
|
{ /* Trap 0 -> 30 */
|
1996-12-27 20:50:03 +01:00
|
|
|
|
EIPC = PC + 4;
|
|
|
|
|
EIPSW = PSW;
|
|
|
|
|
/* Mask out EICC */
|
|
|
|
|
ECR &= 0xffff0000;
|
|
|
|
|
ECR |= 0x40 + OP[0];
|
|
|
|
|
/* Flag that we are now doing exception processing. */
|
|
|
|
|
PSW |= PSW_EP | PSW_ID;
|
1996-10-24 19:39:30 +02:00
|
|
|
|
PC = ((OP[0] < 0x10) ? 0x40 : 0x50) - 4;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 0;
|
1996-09-03 18:25:51 +02:00
|
|
|
|
}
|
1996-08-29 22:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* tst1 reg2, [reg1] */
|
|
|
|
|
int
|
|
|
|
|
OP_E607E0 (void)
|
|
|
|
|
{
|
|
|
|
|
int temp;
|
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
trace_input ("tst1", OP_BIT, 1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
temp = load_mem (State.regs[ OP[0] ], 1);
|
|
|
|
|
|
|
|
|
|
PSW &= ~PSW_Z;
|
|
|
|
|
if ((temp & (1 << State.regs[ OP[1] & 0x7 ])) == 0)
|
|
|
|
|
PSW |= PSW_Z;
|
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-21 00:42:55 +02:00
|
|
|
|
/* mulu reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_22207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mulu", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
Multiply64 (false, State.regs[ OP[0] ]);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
|
|
|
|
|
#define BIT_CHANGE_OP( name, binop ) \
|
|
|
|
|
unsigned int bit; \
|
|
|
|
|
unsigned int temp; \
|
|
|
|
|
\
|
|
|
|
|
trace_input (name, OP_BIT_CHANGE, 0); \
|
|
|
|
|
\
|
|
|
|
|
bit = 1 << State.regs[ OP[1] & 0x7 ]; \
|
|
|
|
|
temp = load_mem (State.regs[ OP[0] ], 1); \
|
|
|
|
|
\
|
|
|
|
|
PSW &= ~PSW_Z; \
|
|
|
|
|
if ((temp & bit) == 0) \
|
|
|
|
|
PSW |= PSW_Z; \
|
|
|
|
|
temp binop bit; \
|
|
|
|
|
\
|
|
|
|
|
store_mem (State.regs[ OP[0] ], 1, temp); \
|
|
|
|
|
\
|
|
|
|
|
trace_output (OP_BIT_CHANGE); \
|
|
|
|
|
\
|
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
|
|
/* clr1 reg2, [reg1] */
|
|
|
|
|
int
|
|
|
|
|
OP_E407E0 (void)
|
|
|
|
|
{
|
|
|
|
|
BIT_CHANGE_OP ("clr1", &= ~ );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* not1 reg2, [reg1] */
|
|
|
|
|
int
|
|
|
|
|
OP_E207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
BIT_CHANGE_OP ("not1", ^= );
|
1996-08-29 22:08:37 +02:00
|
|
|
|
}
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
/* set1 */
|
|
|
|
|
int
|
|
|
|
|
OP_E007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
BIT_CHANGE_OP ("set1", |= );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sasf */
|
|
|
|
|
int
|
|
|
|
|
OP_20007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("sasf", OP_EX1, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = (State.regs[ OP[1] ] << 1) | condition_met (OP[0]);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_EX1);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850eq */
|
1997-08-21 00:42:55 +02:00
|
|
|
|
/* This function is courtesy of Sugimoto at NEC, via Seow Tan (Soew_Tan@el.nec.com) */
|
1997-09-15 16:42:51 +02:00
|
|
|
|
void
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divun
|
|
|
|
|
(
|
|
|
|
|
unsigned int N,
|
|
|
|
|
unsigned long int als,
|
|
|
|
|
unsigned long int sfi,
|
|
|
|
|
unsigned long int * quotient_ptr,
|
|
|
|
|
unsigned long int * remainder_ptr,
|
|
|
|
|
boolean * overflow_ptr
|
|
|
|
|
)
|
|
|
|
|
{
|
1997-09-03 06:10:33 +02:00
|
|
|
|
unsigned long ald = sfi >> (N - 1);
|
1997-08-21 00:42:55 +02:00
|
|
|
|
unsigned long alo = als;
|
|
|
|
|
unsigned int Q = 1;
|
|
|
|
|
unsigned int C;
|
|
|
|
|
unsigned int S = 0;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
unsigned int R1 = 1;
|
|
|
|
|
unsigned int DBZ = (als == 0) ? 1 : 0;
|
|
|
|
|
unsigned long alt = Q ? ~als : als;
|
|
|
|
|
|
|
|
|
|
/* 1st Loop */
|
|
|
|
|
alo = ald + alt + Q;
|
1997-09-03 06:10:33 +02:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-21 00:42:55 +02:00
|
|
|
|
C = C ^ Q;
|
|
|
|
|
Q = ~(C ^ S) & 1;
|
|
|
|
|
R1 = (alo == 0) ? 0 : (R1 & Q);
|
|
|
|
|
if ((S ^ (alo>>31)) && !C)
|
|
|
|
|
{
|
|
|
|
|
DBZ = 1;
|
|
|
|
|
}
|
|
|
|
|
S = alo >> 31;
|
|
|
|
|
sfi = (sfi << (32-N+1)) | Q;
|
|
|
|
|
ald = (alo << 1) | (sfi >> 31);
|
|
|
|
|
|
|
|
|
|
/* 2nd - N-1th Loop */
|
|
|
|
|
for (i = 2; i < N; i++)
|
|
|
|
|
{
|
|
|
|
|
alt = Q ? ~als : als;
|
|
|
|
|
alo = ald + alt + Q;
|
1997-09-03 06:10:33 +02:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-21 00:42:55 +02:00
|
|
|
|
C = C ^ Q;
|
|
|
|
|
Q = ~(C ^ S) & 1;
|
|
|
|
|
R1 = (alo == 0) ? 0 : (R1 & Q);
|
|
|
|
|
if ((S ^ (alo>>31)) && !C && !DBZ)
|
|
|
|
|
{
|
|
|
|
|
DBZ = 1;
|
|
|
|
|
}
|
|
|
|
|
S = alo >> 31;
|
|
|
|
|
sfi = (sfi << 1) | Q;
|
|
|
|
|
ald = (alo << 1) | (sfi >> 31);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Nth Loop */
|
|
|
|
|
alt = Q ? ~als : als;
|
|
|
|
|
alo = ald + alt + Q;
|
1997-09-03 06:10:33 +02:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-21 00:42:55 +02:00
|
|
|
|
C = C ^ Q;
|
|
|
|
|
Q = ~(C ^ S) & 1;
|
|
|
|
|
R1 = (alo == 0) ? 0 : (R1 & Q);
|
|
|
|
|
if ((S ^ (alo>>31)) && !C)
|
|
|
|
|
{
|
|
|
|
|
DBZ = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
* quotient_ptr = (sfi << 1) | Q;
|
|
|
|
|
* remainder_ptr = Q ? alo : (alo + als);
|
|
|
|
|
* overflow_ptr = DBZ | R1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function is courtesy of Sugimoto at NEC, via Seow Tan (Soew_Tan@el.nec.com) */
|
1997-09-15 16:42:51 +02:00
|
|
|
|
void
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divn
|
|
|
|
|
(
|
|
|
|
|
unsigned int N,
|
|
|
|
|
unsigned long int als,
|
|
|
|
|
unsigned long int sfi,
|
|
|
|
|
signed long int * quotient_ptr,
|
|
|
|
|
signed long int * remainder_ptr,
|
|
|
|
|
boolean * overflow_ptr
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
unsigned long ald = (signed long) sfi >> (N - 1);
|
|
|
|
|
unsigned long alo = als;
|
|
|
|
|
unsigned int SS = als >> 31;
|
|
|
|
|
unsigned int SD = sfi >> 31;
|
|
|
|
|
unsigned int R1 = 1;
|
|
|
|
|
unsigned int OV;
|
|
|
|
|
unsigned int DBZ = als == 0 ? 1 : 0;
|
|
|
|
|
unsigned int Q = ~(SS ^ SD) & 1;
|
|
|
|
|
unsigned int C;
|
|
|
|
|
unsigned int S;
|
|
|
|
|
unsigned int i;
|
|
|
|
|
unsigned long alt = Q ? ~als : als;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 1st Loop */
|
|
|
|
|
|
|
|
|
|
alo = ald + alt + Q;
|
1997-09-03 06:10:33 +02:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-21 00:42:55 +02:00
|
|
|
|
Q = C ^ SS;
|
|
|
|
|
R1 = (alo == 0) ? 0 : (R1 & (Q ^ (SS ^ SD)));
|
|
|
|
|
S = alo >> 31;
|
|
|
|
|
sfi = (sfi << (32-N+1)) | Q;
|
|
|
|
|
ald = (alo << 1) | (sfi >> 31);
|
|
|
|
|
if ((alo >> 31) ^ (ald >> 31))
|
|
|
|
|
{
|
|
|
|
|
DBZ = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2nd - N-1th Loop */
|
|
|
|
|
|
|
|
|
|
for (i = 2; i < N; i++)
|
|
|
|
|
{
|
|
|
|
|
alt = Q ? ~als : als;
|
|
|
|
|
alo = ald + alt + Q;
|
1997-09-03 06:10:33 +02:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-21 00:42:55 +02:00
|
|
|
|
Q = C ^ SS;
|
|
|
|
|
R1 = (alo == 0) ? 0 : (R1 & (Q ^ (SS ^ SD)));
|
|
|
|
|
S = alo >> 31;
|
|
|
|
|
sfi = (sfi << 1) | Q;
|
|
|
|
|
ald = (alo << 1) | (sfi >> 31);
|
|
|
|
|
if ((alo >> 31) ^ (ald >> 31))
|
|
|
|
|
{
|
|
|
|
|
DBZ = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Nth Loop */
|
|
|
|
|
alt = Q ? ~als : als;
|
|
|
|
|
alo = ald + alt + Q;
|
1997-09-03 06:10:33 +02:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-21 00:42:55 +02:00
|
|
|
|
Q = C ^ SS;
|
|
|
|
|
R1 = (alo == 0) ? 0 : (R1 & (Q ^ (SS ^ SD)));
|
|
|
|
|
sfi = (sfi << (32-N+1));
|
|
|
|
|
ald = alo;
|
|
|
|
|
|
|
|
|
|
/* End */
|
|
|
|
|
if (alo != 0)
|
|
|
|
|
{
|
|
|
|
|
alt = Q ? ~als : als;
|
|
|
|
|
alo = ald + alt + Q;
|
|
|
|
|
}
|
|
|
|
|
R1 = R1 & ((~alo >> 31) ^ SD);
|
|
|
|
|
if ((alo != 0) && ((Q ^ (SS ^ SD)) ^ R1)) alo = ald;
|
|
|
|
|
if (N != 32)
|
|
|
|
|
ald = sfi = (long) ((sfi >> 1) | (SS ^ SD) << 31) >> (32-N-1) | Q;
|
|
|
|
|
else
|
|
|
|
|
ald = sfi = sfi | Q;
|
|
|
|
|
|
|
|
|
|
OV = DBZ | ((alo == 0) ? 0 : R1);
|
|
|
|
|
|
|
|
|
|
* remainder_ptr = alo;
|
|
|
|
|
|
|
|
|
|
/* Adj */
|
1997-09-03 06:10:33 +02:00
|
|
|
|
if (((alo != 0) && ((SS ^ SD) ^ R1))
|
|
|
|
|
|| ((alo == 0) && (SS ^ R1)))
|
1997-08-21 00:42:55 +02:00
|
|
|
|
alo = ald + 1;
|
|
|
|
|
else
|
|
|
|
|
alo = ald;
|
|
|
|
|
|
|
|
|
|
OV = (DBZ | R1) ? OV : ((alo >> 31) & (~ald >> 31));
|
|
|
|
|
|
|
|
|
|
* quotient_ptr = alo;
|
|
|
|
|
* overflow_ptr = OV;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* sdivun imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_1C207E0 (void)
|
|
|
|
|
{
|
1997-08-21 00:42:55 +02:00
|
|
|
|
unsigned long int quotient;
|
|
|
|
|
unsigned long int remainder;
|
|
|
|
|
unsigned long int divide_by;
|
|
|
|
|
unsigned long int divide_this;
|
|
|
|
|
boolean overflow = false;
|
|
|
|
|
unsigned int imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivun", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divun (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
1997-08-22 19:41:20 +02:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sdivn imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_1C007E0 (void)
|
|
|
|
|
{
|
1997-08-21 00:42:55 +02:00
|
|
|
|
signed long int quotient;
|
|
|
|
|
signed long int remainder;
|
|
|
|
|
signed long int divide_by;
|
|
|
|
|
signed long int divide_this;
|
|
|
|
|
boolean overflow = false;
|
|
|
|
|
unsigned int imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivn", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
|
|
|
|
if (quotient < 0) PSW |= PSW_S;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sdivhun imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_18207E0 (void)
|
|
|
|
|
{
|
1997-08-21 00:42:55 +02:00
|
|
|
|
unsigned long int quotient;
|
|
|
|
|
unsigned long int remainder;
|
|
|
|
|
unsigned long int divide_by;
|
|
|
|
|
unsigned long int divide_this;
|
|
|
|
|
boolean overflow = false;
|
|
|
|
|
unsigned int imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivhun", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divide_by = State.regs[ OP[0] ] & 0xffff;
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divun (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
1997-08-22 19:41:20 +02:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sdivhn imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_18007E0 (void)
|
|
|
|
|
{
|
1997-08-21 00:42:55 +02:00
|
|
|
|
signed long int quotient;
|
|
|
|
|
signed long int remainder;
|
|
|
|
|
signed long int divide_by;
|
|
|
|
|
signed long int divide_this;
|
|
|
|
|
boolean overflow = false;
|
|
|
|
|
unsigned int imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivhn", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
divide_by = EXTEND16 (State.regs[ OP[0] ]);
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-08-21 00:42:55 +02:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
|
|
|
|
if (quotient < 0) PSW |= PSW_S;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850eq */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
/* divu reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_2C207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long int quotient;
|
|
|
|
|
unsigned long int remainder;
|
1997-08-21 00:42:55 +02:00
|
|
|
|
unsigned long int divide_by;
|
|
|
|
|
unsigned long int divide_this;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_input ("divu", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
|
|
|
|
|
|
|
|
|
if (divide_by == 0)
|
1997-08-20 22:57:05 +02:00
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
overflow = true;
|
|
|
|
|
divide_by = 1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
}
|
1997-09-15 16:42:51 +02:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* div reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_2C007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
signed long int quotient;
|
|
|
|
|
signed long int remainder;
|
1997-08-21 00:42:55 +02:00
|
|
|
|
signed long int divide_by;
|
|
|
|
|
signed long int divide_this;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_input ("div", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
|
|
|
|
|
|
|
|
|
if (divide_by == 0 || (divide_by == -1 && divide_this == (1 << 31)))
|
1997-08-20 22:57:05 +02:00
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
overflow = true;
|
|
|
|
|
divide_by = 1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
}
|
1997-09-15 16:42:51 +02:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
|
|
|
|
if (quotient < 0) PSW |= PSW_S;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* divhu reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_28207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long int quotient;
|
|
|
|
|
unsigned long int remainder;
|
1997-08-21 00:42:55 +02:00
|
|
|
|
unsigned long int divide_by;
|
|
|
|
|
unsigned long int divide_this;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_input ("divhu", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
|
|
|
|
divide_by = State.regs[ OP[0] ] & 0xffff;
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
|
|
|
|
|
|
|
|
|
if (divide_by == 0)
|
1997-08-20 22:57:05 +02:00
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
overflow = true;
|
|
|
|
|
divide_by = 1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
}
|
1997-09-15 16:42:51 +02:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* divh reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_28007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
signed long int quotient;
|
|
|
|
|
signed long int remainder;
|
1997-08-21 00:42:55 +02:00
|
|
|
|
signed long int divide_by;
|
|
|
|
|
signed long int divide_this;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_input ("divh", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = EXTEND16 (State.regs[ OP[1] ]);
|
|
|
|
|
|
|
|
|
|
if (divide_by == 0 || (divide_by == -1 && divide_this == (1 << 31)))
|
1997-08-20 22:57:05 +02:00
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
overflow = true;
|
|
|
|
|
divide_by = 1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
}
|
1997-09-15 16:42:51 +02:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (overflow) PSW |= PSW_OV;
|
|
|
|
|
if (quotient == 0) PSW |= PSW_Z;
|
|
|
|
|
if (quotient < 0) PSW |= PSW_S;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* mulu imm9, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_24207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mulu", OP_IMM_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
Multiply64 (false, (OP[3] & 0x1f) | ((OP[3] >> 13) & 0x1e0));
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* mul imm9, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_24007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mul", OP_IMM_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
Multiply64 (true, (OP[3] & 0x1f) | ((OP[3] >> 13) & 0x1e0));
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* ld.hu */
|
|
|
|
|
int
|
|
|
|
|
OP_107E0 (void)
|
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
int adr;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_input ("ld.hu", OP_LOAD32, 2);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
adr = State.regs[ OP[0] ] + EXTEND16 (OP[2] & ~1);
|
|
|
|
|
adr &= ~0x1;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
State.regs[ OP[1] ] = load_mem (adr, 2);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* ld.bu */
|
|
|
|
|
int
|
|
|
|
|
OP_10780 (void)
|
|
|
|
|
{
|
1997-09-15 16:42:51 +02:00
|
|
|
|
int adr;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_input ("ld.bu", OP_LOAD32, 1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
adr = (State.regs[ OP[0] ]
|
|
|
|
|
+ (EXTEND16 (OP[2] & ~1) | ((OP[3] >> 5) & 1)));
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
State.regs[ OP[1] ] = load_mem (adr, 1);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
1997-09-15 16:42:51 +02:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* prepare list12, imm5, imm32 */
|
|
|
|
|
int
|
|
|
|
|
OP_1B0780 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("prepare", OP_PUSHPOP1, 0);
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 22:57:05 +02:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP, 4, State.regs[ 20 + i ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP -= (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
|
|
|
|
EP = load_mem (PC + 4, 4);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP1);
|
|
|
|
|
|
|
|
|
|
return 8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* prepare list12, imm5, imm16-32 */
|
|
|
|
|
int
|
|
|
|
|
OP_130780 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("prepare", OP_PUSHPOP1, 0);
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 22:57:05 +02:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP, 4, State.regs[ 20 + i ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP -= (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
|
|
|
|
EP = load_mem (PC + 4, 2) << 16;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP1);
|
|
|
|
|
|
|
|
|
|
return 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* prepare list12, imm5, imm16 */
|
|
|
|
|
int
|
|
|
|
|
OP_B0780 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("prepare", OP_PUSHPOP1, 0);
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 22:57:05 +02:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP, 4, State.regs[ 20 + i ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP -= (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
1997-09-08 19:42:48 +02:00
|
|
|
|
EP = EXTEND16 (load_mem (PC + 4, 2));
|
1997-08-20 22:57:05 +02:00
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP1);
|
|
|
|
|
|
|
|
|
|
return 6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* prepare list12, imm5, sp */
|
|
|
|
|
int
|
|
|
|
|
OP_30780 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("prepare", OP_PUSHPOP1, 0);
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 22:57:05 +02:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP, 4, State.regs[ 20 + i ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP -= (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
|
|
|
|
EP = SP;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP1);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-15 10:18:20 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850e */
|
1997-08-21 00:42:55 +02:00
|
|
|
|
/* mul reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_22007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mul", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
Multiply64 (true, State.regs[ OP[0] ]);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
/* popmh list18 */
|
|
|
|
|
int
|
|
|
|
|
OP_307F0 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("popmh", OP_PUSHPOP2, 0);
|
|
|
|
|
|
|
|
|
|
if (OP[3] & (1 << 19))
|
|
|
|
|
{
|
|
|
|
|
if ((PSW & PSW_NP) && ((PSW & PSW_EP) == 0))
|
|
|
|
|
{
|
|
|
|
|
FEPSW = load_mem ( SP & ~ 3, 4);
|
|
|
|
|
FEPC = load_mem ((SP + 4) & ~ 3, 4);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
EIPSW = load_mem ( SP & ~ 3, 4);
|
|
|
|
|
EIPC = load_mem ((SP + 4) & ~ 3, 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP += 8;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
/* Load the registers with lower number registers being retrieved from higher addresses. */
|
|
|
|
|
for (i = 16; i--;)
|
|
|
|
|
if ((OP[3] & (1 << type2_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
State.regs[ i + 16 ] = load_mem (SP & ~ 3, 4);
|
|
|
|
|
SP += 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
trace_output (OP_PUSHPOP2);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* popml lsit18 */
|
|
|
|
|
int
|
|
|
|
|
OP_107F0 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("popml", OP_PUSHPOP3, 0);
|
|
|
|
|
|
|
|
|
|
if (OP[3] & (1 << 19))
|
|
|
|
|
{
|
|
|
|
|
if ((PSW & PSW_NP) && ((PSW & PSW_EP) == 0))
|
|
|
|
|
{
|
|
|
|
|
FEPSW = load_mem ( SP & ~ 3, 4);
|
|
|
|
|
FEPC = load_mem ((SP + 4) & ~ 3, 4);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
EIPSW = load_mem ( SP & ~ 3, 4);
|
|
|
|
|
EIPC = load_mem ((SP + 4) & ~ 3, 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP += 8;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
if (OP[3] & (1 << 3))
|
|
|
|
|
{
|
|
|
|
|
PSW = load_mem (SP & ~ 3, 4);
|
|
|
|
|
SP += 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Load the registers with lower number registers being retrieved from higher addresses. */
|
|
|
|
|
for (i = 15; i--;)
|
|
|
|
|
if ((OP[3] & (1 << type3_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
State.regs[ i + 1 ] = load_mem (SP & ~ 3, 4);
|
|
|
|
|
SP += 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
trace_output (OP_PUSHPOP2);
|
1997-09-03 06:10:33 +02:00
|
|
|
|
|
|
|
|
|
return 4;
|
1997-08-20 22:57:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* pushmh list18 */
|
|
|
|
|
int
|
|
|
|
|
OP_307E0 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("pushmh", OP_PUSHPOP2, 0);
|
|
|
|
|
|
1997-08-22 19:41:20 +02:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
|
if ((OP[3] & (1 << type2_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP & ~ 3, 4, State.regs[ i + 16 ]);
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:57:05 +02:00
|
|
|
|
if (OP[3] & (1 << 19))
|
|
|
|
|
{
|
|
|
|
|
SP -= 8;
|
|
|
|
|
|
|
|
|
|
if ((PSW & PSW_NP) && ((PSW & PSW_EP) == 0))
|
|
|
|
|
{
|
|
|
|
|
store_mem ((SP + 4) & ~ 3, 4, FEPC);
|
|
|
|
|
store_mem ( SP & ~ 3, 4, FEPSW);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
store_mem ((SP + 4) & ~ 3, 4, EIPC);
|
|
|
|
|
store_mem ( SP & ~ 3, 4, EIPSW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP2);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* end-sanitize-v850eq */
|