1996-08-29 01:06:42 +00:00
|
|
|
|
#include <signal.h>
|
1997-09-03 04:10:33 +00:00
|
|
|
|
#include "sim-main.h"
|
1996-08-29 01:06:42 +00:00
|
|
|
|
#include "v850_sim.h"
|
|
|
|
|
#include "simops.h"
|
1997-09-03 04:10:33 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UTIME_H
|
|
|
|
|
#include <utime.h>
|
1997-09-03 07:30:17 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_TIME_H
|
|
|
|
|
#include <time.h>
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
|
#include <unistd.h>
|
1997-09-03 04:10:33 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-01 03:43:56 +00: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 04:10:33 +00:00
|
|
|
|
|
1996-09-12 16:06:02 +00:00
|
|
|
|
#include "bfd.h"
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#include "libiberty.h"
|
|
|
|
|
|
1996-10-24 17:39:30 +00:00
|
|
|
|
#include <errno.h>
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1996-10-29 21:24:01 +00:00
|
|
|
|
#include <sys/stat.h>
|
1996-10-30 16:30:59 +00:00
|
|
|
|
#include <sys/times.h>
|
1996-10-31 19:58:14 +00:00
|
|
|
|
#include <sys/time.h>
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#endif
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
enum op_types
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
OP_UNKNOWN,
|
|
|
|
|
OP_NONE,
|
|
|
|
|
OP_TRAP,
|
|
|
|
|
OP_REG,
|
|
|
|
|
OP_REG_REG,
|
|
|
|
|
OP_REG_REG_CMP,
|
|
|
|
|
OP_REG_REG_MOVE,
|
|
|
|
|
OP_IMM_REG,
|
|
|
|
|
OP_IMM_REG_CMP,
|
|
|
|
|
OP_IMM_REG_MOVE,
|
|
|
|
|
OP_COND_BR,
|
|
|
|
|
OP_LOAD16,
|
|
|
|
|
OP_STORE16,
|
|
|
|
|
OP_LOAD32,
|
|
|
|
|
OP_STORE32,
|
|
|
|
|
OP_JUMP,
|
|
|
|
|
OP_IMM_REG_REG,
|
|
|
|
|
OP_UIMM_REG_REG,
|
|
|
|
|
OP_BIT,
|
|
|
|
|
OP_EX1,
|
|
|
|
|
OP_EX2,
|
|
|
|
|
OP_LDSR,
|
1997-08-20 20:57:05 +00:00
|
|
|
|
OP_STSR,
|
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
OP_BIT_CHANGE,
|
|
|
|
|
OP_REG_REG_REG,
|
|
|
|
|
OP_REG_REG3,
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
OP_IMM_REG_REG_REG,
|
|
|
|
|
OP_PUSHPOP1,
|
|
|
|
|
OP_PUSHPOP2,
|
|
|
|
|
OP_PUSHPOP3,
|
|
|
|
|
/* end-sanitize-v850eq */
|
1996-09-11 20:54:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
/* This is an array of the bit positions of registers r20 .. r31 in that order in a prepare/dispose instruction. */
|
|
|
|
|
static int type1_regs[12] = { 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 0, 21 };
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
/* This is an array of the bit positions of registers r16 .. r31 in that order in a push/pop instruction. */
|
|
|
|
|
static 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. */
|
|
|
|
|
static int type3_regs[15] = { 2, 1, 0, 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 20, 21};
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
static void trace_input PARAMS ((char *name, enum op_types type, int size));
|
|
|
|
|
static void trace_output PARAMS ((enum op_types result));
|
1996-09-12 16:06:02 +00:00
|
|
|
|
static int init_text_p = 0;
|
|
|
|
|
static asection *text;
|
|
|
|
|
static bfd_vma text_start;
|
|
|
|
|
static bfd_vma text_end;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
extern bfd *prog_bfd;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
|
|
|
|
|
#ifndef SIZE_INSTRUCTION
|
|
|
|
|
#define SIZE_INSTRUCTION 6
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SIZE_OPERANDS
|
|
|
|
|
#define SIZE_OPERANDS 16
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef SIZE_VALUES
|
|
|
|
|
#define SIZE_VALUES 11
|
|
|
|
|
#endif
|
|
|
|
|
|
1996-09-12 16:06:02 +00:00
|
|
|
|
#ifndef SIZE_LOCATION
|
|
|
|
|
#define SIZE_LOCATION 40
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
static void
|
|
|
|
|
trace_input (name, type, size)
|
|
|
|
|
char *name;
|
|
|
|
|
enum op_types type;
|
|
|
|
|
int size;
|
|
|
|
|
{
|
1996-09-12 16:06:02 +00:00
|
|
|
|
char buf[1024];
|
|
|
|
|
char *p;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
uint32 values[3];
|
|
|
|
|
int num_values, i;
|
|
|
|
|
char *cond;
|
1996-09-12 16:06:02 +00:00
|
|
|
|
asection *s;
|
|
|
|
|
const char *filename;
|
|
|
|
|
const char *functionname;
|
|
|
|
|
unsigned int linenumber;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
|
|
|
|
|
if ((v850_debug & DEBUG_TRACE) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
1996-09-12 16:06:02 +00:00
|
|
|
|
buf[0] = '\0';
|
|
|
|
|
if (!init_text_p)
|
|
|
|
|
{
|
|
|
|
|
init_text_p = 1;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
for (s = prog_bfd->sections; s; s = s->next)
|
|
|
|
|
if (strcmp (bfd_get_section_name (prog_bfd, s), ".text") == 0)
|
1996-09-12 16:06:02 +00:00
|
|
|
|
{
|
|
|
|
|
text = s;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
text_start = bfd_get_section_vma (prog_bfd, s);
|
|
|
|
|
text_end = text_start + bfd_section_size (prog_bfd, s);
|
1996-09-12 16:06:02 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (text && PC >= text_start && PC < text_end)
|
|
|
|
|
{
|
|
|
|
|
filename = (const char *)0;
|
|
|
|
|
functionname = (const char *)0;
|
|
|
|
|
linenumber = 0;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if (bfd_find_nearest_line (prog_bfd, text, (struct symbol_cache_entry **)0, PC - text_start,
|
1996-09-12 16:06:02 +00:00
|
|
|
|
&filename, &functionname, &linenumber))
|
|
|
|
|
{
|
|
|
|
|
p = buf;
|
|
|
|
|
if (linenumber)
|
|
|
|
|
{
|
|
|
|
|
sprintf (p, "Line %5d ", linenumber);
|
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (functionname)
|
|
|
|
|
{
|
|
|
|
|
sprintf (p, "Func %s ", functionname);
|
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
else if (filename)
|
|
|
|
|
{
|
|
|
|
|
char *q = (char *) strrchr (filename, '/');
|
|
|
|
|
sprintf (p, "File %s ", (q) ? q+1 : filename);
|
|
|
|
|
p += strlen (p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*p == ' ')
|
|
|
|
|
*p = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "0x%.8x: %-*.*s %-*s",
|
1996-09-11 20:54:21 +00:00
|
|
|
|
(unsigned)PC,
|
1996-09-12 16:06:02 +00:00
|
|
|
|
SIZE_LOCATION, SIZE_LOCATION, buf,
|
1996-09-11 20:54:21 +00:00
|
|
|
|
SIZE_INSTRUCTION, name);
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case OP_UNKNOWN:
|
|
|
|
|
case OP_NONE:
|
|
|
|
|
strcpy (buf, "unknown");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_TRAP:
|
|
|
|
|
sprintf (buf, "%d", OP[0]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_REG:
|
|
|
|
|
sprintf (buf, "r%d", OP[0]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_REG_REG:
|
|
|
|
|
case OP_REG_REG_CMP:
|
|
|
|
|
case OP_REG_REG_MOVE:
|
|
|
|
|
sprintf (buf, "r%d,r%d", OP[0], OP[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG:
|
|
|
|
|
case OP_IMM_REG_CMP:
|
|
|
|
|
case OP_IMM_REG_MOVE:
|
1996-10-24 17:39:30 +00:00
|
|
|
|
sprintf (buf, "%d,r%d", OP[0], OP[1]);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_COND_BR:
|
|
|
|
|
sprintf (buf, "%d", SEXT9 (OP[0]));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LOAD16:
|
1996-10-24 18:28:43 +00:00
|
|
|
|
sprintf (buf, "%d[r30],r%d", OP[1] * size, OP[0]);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_STORE16:
|
1996-10-24 18:28:43 +00:00
|
|
|
|
sprintf (buf, "r%d,%d[r30]", OP[0], OP[1] * size);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LOAD32:
|
1996-10-24 17:39:30 +00:00
|
|
|
|
sprintf (buf, "%d[r%d],r%d", SEXT16 (OP[2]) & ~0x1, OP[0], OP[1]);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_STORE32:
|
1996-10-24 17:39:30 +00:00
|
|
|
|
sprintf (buf, "r%d,%d[r%d]", OP[1], SEXT16 (OP[2] & ~0x1), OP[0]);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_JUMP:
|
|
|
|
|
sprintf (buf, "%d,r%d", SEXT22 (OP[0]), OP[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG_REG:
|
|
|
|
|
sprintf (buf, "%d,r%d,r%d", SEXT16 (OP[0]), OP[1], OP[2]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_UIMM_REG_REG:
|
|
|
|
|
sprintf (buf, "%d,r%d,r%d", OP[0] & 0xffff, OP[1], OP[2]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_BIT:
|
|
|
|
|
sprintf (buf, "%d,%d[r%d]", OP[1] & 0x7, SEXT16 (OP[2]), OP[0]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_EX1:
|
|
|
|
|
switch (OP[0] & 0xf)
|
|
|
|
|
{
|
|
|
|
|
default: cond = "?"; break;
|
|
|
|
|
case 0x0: cond = "v"; break;
|
|
|
|
|
case 0x1: cond = "c"; break;
|
|
|
|
|
case 0x2: cond = "z"; break;
|
|
|
|
|
case 0x3: cond = "nh"; break;
|
|
|
|
|
case 0x4: cond = "s"; break;
|
|
|
|
|
case 0x5: cond = "t"; break;
|
|
|
|
|
case 0x6: cond = "lt"; break;
|
|
|
|
|
case 0x7: cond = "le"; break;
|
|
|
|
|
case 0x8: cond = "nv"; break;
|
|
|
|
|
case 0x9: cond = "nc"; break;
|
|
|
|
|
case 0xa: cond = "nz"; break;
|
|
|
|
|
case 0xb: cond = "h"; break;
|
|
|
|
|
case 0xc: cond = "ns"; break;
|
|
|
|
|
case 0xd: cond = "sa"; break;
|
|
|
|
|
case 0xe: cond = "ge"; break;
|
|
|
|
|
case 0xf: cond = "gt"; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf (buf, "%s,r%d", cond, OP[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_EX2:
|
|
|
|
|
strcpy (buf, "EX2");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LDSR:
|
|
|
|
|
case OP_STSR:
|
|
|
|
|
sprintf (buf, "r%d,s%d", OP[0], OP[1]);
|
|
|
|
|
break;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
case OP_PUSHPOP1:
|
|
|
|
|
for (i = 0; i < 12; i++)
|
|
|
|
|
if (OP[3] & (1 << type1_regs[i]))
|
|
|
|
|
strcat (buf, "r%d ", i + 20);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_PUSHPOP2:
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
|
if (OP[3] & (1 << type2_regs[i]))
|
|
|
|
|
strcat (buf, "r%d ", i + 16);
|
|
|
|
|
if (OP[3] & (1 << 19))
|
|
|
|
|
strcat (buf, "F/EIPC, F/EIPSW " );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_PUSHPOP3:
|
|
|
|
|
for (i = 0; i < 15; i++)
|
|
|
|
|
if (OP[3] & (1 << type3_regs[i]))
|
|
|
|
|
strcat (buf, "r%d ", i + 1);
|
|
|
|
|
if (OP[3] & (1 << 3))
|
|
|
|
|
strcat (buf, "PSW " );
|
|
|
|
|
if (OP[3] & (1 << 19))
|
|
|
|
|
strcat (buf, "F/EIPC, F/EIPSW " );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_BIT_CHANGE:
|
|
|
|
|
sprintf (buf, "r%d, [r%d]", OP[1], OP[0] );
|
|
|
|
|
break;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((v850_debug & DEBUG_VALUES) == 0)
|
|
|
|
|
{
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "%s\n", buf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "%-*s", SIZE_OPERANDS, buf);
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case OP_UNKNOWN:
|
|
|
|
|
case OP_NONE:
|
|
|
|
|
case OP_TRAP:
|
|
|
|
|
num_values = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_REG:
|
|
|
|
|
case OP_REG_REG_MOVE:
|
|
|
|
|
values[0] = State.regs[OP[0]];
|
|
|
|
|
num_values = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
case OP_BIT_CHANGE:
|
1996-09-11 20:54:21 +00:00
|
|
|
|
case OP_REG_REG:
|
|
|
|
|
case OP_REG_REG_CMP:
|
|
|
|
|
values[0] = State.regs[OP[1]];
|
|
|
|
|
values[1] = State.regs[OP[0]];
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG:
|
|
|
|
|
case OP_IMM_REG_CMP:
|
|
|
|
|
values[0] = SEXT5 (OP[0]);
|
|
|
|
|
values[1] = OP[1];
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG_MOVE:
|
|
|
|
|
values[0] = SEXT5 (OP[0]);
|
|
|
|
|
num_values = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_COND_BR:
|
|
|
|
|
values[0] = State.pc;
|
|
|
|
|
values[1] = SEXT9 (OP[0]);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
values[2] = PSW;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
num_values = 3;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LOAD16:
|
1996-10-24 18:28:43 +00:00
|
|
|
|
values[0] = OP[1] * size;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
values[1] = State.regs[30];
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_STORE16:
|
|
|
|
|
values[0] = State.regs[OP[0]];
|
1996-10-24 18:28:43 +00:00
|
|
|
|
values[1] = OP[1] * size;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
values[2] = State.regs[30];
|
|
|
|
|
num_values = 3;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LOAD32:
|
|
|
|
|
values[0] = SEXT16 (OP[2]);
|
|
|
|
|
values[1] = State.regs[OP[0]];
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_STORE32:
|
|
|
|
|
values[0] = State.regs[OP[1]];
|
|
|
|
|
values[1] = SEXT16 (OP[2]);
|
|
|
|
|
values[2] = State.regs[OP[0]];
|
|
|
|
|
num_values = 3;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_JUMP:
|
|
|
|
|
values[0] = SEXT22 (OP[0]);
|
|
|
|
|
values[1] = State.pc;
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG_REG:
|
|
|
|
|
values[0] = SEXT16 (OP[0]) << size;
|
|
|
|
|
values[1] = State.regs[OP[1]];
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_UIMM_REG_REG:
|
|
|
|
|
values[0] = (OP[0] & 0xffff) << size;
|
|
|
|
|
values[1] = State.regs[OP[1]];
|
|
|
|
|
num_values = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_BIT:
|
|
|
|
|
num_values = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_EX1:
|
1996-12-27 19:50:03 +00:00
|
|
|
|
values[0] = PSW;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
num_values = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_EX2:
|
|
|
|
|
num_values = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LDSR:
|
|
|
|
|
values[0] = State.regs[OP[0]];
|
|
|
|
|
num_values = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_STSR:
|
|
|
|
|
values[0] = State.sregs[OP[1]];
|
|
|
|
|
num_values = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_values; i++)
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "%*s0x%.8lx", SIZE_VALUES - 10, "", values[i]);
|
|
|
|
|
|
|
|
|
|
while (i++ < 3)
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "%*s", SIZE_VALUES, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
trace_output (result)
|
|
|
|
|
enum op_types result;
|
|
|
|
|
{
|
|
|
|
|
if ((v850_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
|
|
|
|
|
{
|
|
|
|
|
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:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LOAD16:
|
|
|
|
|
case OP_STSR:
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, " :: 0x%.8lx",
|
|
|
|
|
(unsigned long)State.regs[OP[0]]);
|
|
|
|
|
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:
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, " :: 0x%.8lx",
|
|
|
|
|
(unsigned long)State.regs[OP[1]]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_IMM_REG_REG:
|
|
|
|
|
case OP_UIMM_REG_REG:
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, " :: 0x%.8lx",
|
|
|
|
|
(unsigned long)State.regs[OP[2]]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_JUMP:
|
|
|
|
|
if (OP[1] != 0)
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, " :: 0x%.8lx",
|
|
|
|
|
(unsigned long)State.regs[OP[1]]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OP_LDSR:
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, " :: 0x%.8lx",
|
|
|
|
|
(unsigned long)State.sregs[OP[1]]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*v850_callback->printf_filtered) (v850_callback, "\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
1996-09-27 23:41:12 +00:00
|
|
|
|
#define trace_input(NAME, IN1, IN2)
|
1996-09-11 20:54:21 +00:00
|
|
|
|
#define trace_output(RESULT)
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
//#define trace_input(NAME, IN1, IN2) fprintf (stderr, NAME "\n" );
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
/* Returns 1 if the specific condition is met, returns 0 otherwise. */
|
|
|
|
|
static unsigned int
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = RdLo;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = RdHi;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
1997-09-04 10:10:02 +00: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 20:54:21 +00: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 05:41:10 +00:00
|
|
|
|
/* sld.b */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_300 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
unsigned long result;
|
|
|
|
|
|
|
|
|
|
result = load_mem (State.regs[30] + (OP[3] & 0x7f), 1);
|
1996-08-30 05:49:07 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#ifdef ARCH_v850eq
|
|
|
|
|
trace_input ("sld.bu", OP_LOAD16, 1);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = result;
|
|
|
|
|
#else
|
|
|
|
|
/* end-sanitize-v850eq */
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sld.b", OP_LOAD16, 1);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT8 (result);
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#endif
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LOAD16);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 01:06:42 +00: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 05:41:10 +00:00
|
|
|
|
/* sld.h */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_400 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
unsigned long result;
|
|
|
|
|
|
|
|
|
|
result = load_mem (State.regs[30] + ((OP[3] & 0x7f) << 1), 2);
|
1996-08-30 05:49:07 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#ifdef ARCH_v850eq
|
|
|
|
|
trace_input ("sld.hu", OP_LOAD16, 2);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = result;
|
|
|
|
|
#else
|
|
|
|
|
/* end-sanitize-v850eq */
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sld.h", OP_LOAD16, 2);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT16 (result);
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#endif
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LOAD16);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sld.w */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_500 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sld.w", OP_LOAD16, 4);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = load_mem (State.regs[30] + ((OP[3] & 0x7f) << 1), 4);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LOAD16);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 01:06:42 +00: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 05:41:10 +00:00
|
|
|
|
/* sst.b */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_380 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sst.b", OP_STORE16, 1);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[30] + (OP[3] & 0x7f), 1, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STORE16);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sst.h */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_480 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sst.h", OP_STORE16, 2);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[30] + ((OP[3] & 0x7f) << 1), 2, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STORE16);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sst.w */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_501 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sst.w", OP_STORE16, 4);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[30] + ((OP[3] & 0x7e) << 1), 4, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STORE16);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ld.b */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_700 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("ld.b", OP_LOAD32, 1);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
adr = State.regs[ OP[0] ] + SEXT16 (OP[2]);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT8 (load_mem (adr, 1));
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ld.h */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_720 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("ld.h", OP_LOAD32, 2);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
adr = State.regs[ OP[0] ] + SEXT16 (OP[2]);
|
|
|
|
|
adr &= ~0x1;
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT16 (load_mem (adr, 2));
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ld.w */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_10720 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("ld.w", OP_LOAD32, 4);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
adr = State.regs[ OP[0] ] + SEXT16 (OP[2] & ~1);
|
|
|
|
|
adr &= ~0x3;
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = load_mem (adr, 4);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LOAD32);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* st.b */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_740 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("st.b", OP_STORE32, 1);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
store_mem (State.regs[ OP[0] ] + SEXT16 (OP[2]), 1, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STORE32);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* st.h */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_760 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int adr;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("st.h", OP_STORE32, 2);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
adr = State.regs[ OP[0] ] + SEXT16 (OP[2]);
|
|
|
|
|
adr &= ~1;
|
|
|
|
|
|
|
|
|
|
store_mem (adr, 2, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STORE32);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* st.w */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_10760 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int adr;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("st.w", OP_STORE32, 4);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
adr = State.regs[ OP[0] ] + SEXT16 (OP[2] & ~1);
|
|
|
|
|
adr &= ~3;
|
|
|
|
|
|
|
|
|
|
store_mem (adr, 4, State.regs[ OP[1] ]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STORE32);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
static int
|
|
|
|
|
branch (int code)
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_input ("Bcond", OP_COND_BR, 0);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_COND_BR);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
if (condition_met (code))
|
|
|
|
|
return SEXT9 (((OP[3] & 0x70) >> 3) | ((OP[3] & 0xf800) >> 7));
|
|
|
|
|
else
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bv disp9 */
|
|
|
|
|
int
|
|
|
|
|
OP_580 ()
|
|
|
|
|
{
|
|
|
|
|
return branch (0);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bl disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_581 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (1);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* be disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_582 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (2);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bnh disp 9*/
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_583 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (3);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bn disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_584 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (4);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* br disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_585 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (5);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* blt disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_586 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (6);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* ble disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_587 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (7);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bnv disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_588 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (8);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bnl disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_589 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (9);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bne disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_58A ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (10);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bh disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_58B ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (11);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bp disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 03:48:13 +00:00
|
|
|
|
OP_58C ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (12);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bsa disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_58D ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (13);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bge disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_58E ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (14);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:48:13 +00:00
|
|
|
|
/* bgt disp9 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_58F ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return branch (15);
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 04:27:48 +00:00
|
|
|
|
/* jmp [reg1] */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* sld.bu disp4[ep], reg2 */
|
|
|
|
|
int
|
1996-08-30 04:27:48 +00:00
|
|
|
|
OP_60 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("jmp", OP_REG, 0);
|
|
|
|
|
|
|
|
|
|
PC = State.regs[ OP[0] ];
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG);
|
|
|
|
|
|
|
|
|
|
return 0; /* Add nothing to the PC, we have already done it. */
|
|
|
|
|
}
|
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned long result;
|
|
|
|
|
|
|
|
|
|
result = load_mem (State.regs[30] + (OP[3] & 0xf), 1);
|
|
|
|
|
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#ifdef ARCH_v850eq
|
|
|
|
|
trace_input ("sld.b", OP_LOAD16, 1);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT8 (result);
|
|
|
|
|
#else
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
trace_input ("sld.bu", OP_LOAD16, 1);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = result;
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#endif
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
trace_output (OP_LOAD16);
|
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850e */
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* jarl/jr disp22, reg */
|
|
|
|
|
int
|
1996-08-30 04:27:48 +00:00
|
|
|
|
OP_780 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_input ("jarl/jr", OP_JUMP, 0);
|
1996-08-30 04:27:48 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if (OP[ 1 ] != 0)
|
|
|
|
|
State.regs[ OP[1] ] = PC + 4;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_JUMP);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return SEXT22 (((OP[3] & 0x3f) << 16) | OP[2]);
|
1996-08-30 04:27:48 +00:00
|
|
|
|
}
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* add reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_1C0 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("add", OP_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = op0 + op1;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 05:09:08 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add sign_extend(imm5), reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_240 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
int temp;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("add", OP_IMM_REG, 0);
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1996-09-11 20:54:21 +00:00
|
|
|
|
temp = SEXT5 (OP[0]);
|
1996-08-29 23:39:23 +00: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 01:06:42 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-29 23:39:23 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* addi sign_extend(imm16), reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_600 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-08-29 23:39:23 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("addi", OP_IMM_REG_REG, 0);
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
op0 = SEXT16 (OP[2]);
|
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-29 23:39:23 +00: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 20:57:05 +00:00
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-29 23:39:23 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* sub reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_1A0 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-08-30 03:07:24 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sub", OP_REG_REG, 0);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:07:24 +00:00
|
|
|
|
result = op1 - op0;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:07:24 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 03:07:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* subr reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_180 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-08-30 03:07:24 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("subr", OP_REG_REG, 0);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:07:24 +00:00
|
|
|
|
result = op0 - op1;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
cy = (op0 < op1);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
ov = ((op0 & 0x80000000) != (op1 & 0x80000000)
|
|
|
|
|
&& (op0 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:07:24 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 03:07:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* sxh reg1 */
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* mulh reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_E0 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("sxh", OP_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[0] ] = SEXT16 (State.regs[ OP[0] ]);
|
1996-08-29 20:08:37 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_output (OP_REG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mulh", OP_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = (SEXT16 (State.regs[ OP[1] ]) * SEXT16 (State.regs[ OP[0] ]));
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* mulh sign_extend(imm5), reg2 */
|
|
|
|
|
int
|
|
|
|
|
OP_2E0 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("mulh", OP_IMM_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT16 (State.regs[ OP[1] ]) * SEXT5 (OP[0]);
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* mulhi imm16, reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_6E0 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mulhi", OP_IMM_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT16 (State.regs[ OP[0] ]) * SEXT16 (OP[2]);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:07:24 +00:00
|
|
|
|
/* divh reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* switch reg1 */
|
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_40 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned long adr;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_input ("switch", OP_REG, 0);
|
|
|
|
|
|
|
|
|
|
adr = State.pc + 2 + (State.regs[ OP[0] ] << 1);
|
|
|
|
|
State.pc = State.pc + 2 + (SEXT16 (load_mem (adr, 2)) << 1);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_output (OP_REG);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* end-sanitize-v850e */
|
1996-09-03 18:31:48 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
unsigned int op0, op1, result, ov, s, z;
|
|
|
|
|
int temp;
|
1996-08-30 03:07:24 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_input ("divh", OP_REG_REG, 0);
|
1996-08-30 03:07:24 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* Compute the result. */
|
|
|
|
|
temp = SEXT16 (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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = 0x0;
|
|
|
|
|
ov = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 04:11:32 +00:00
|
|
|
|
/* cmp reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:11:32 +00:00
|
|
|
|
OP_1E0 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("cmp", OP_REG_REG_CMP, 0);
|
1996-08-30 04:11:32 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 04:11:32 +00:00
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 04:11:32 +00:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 04:11:32 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG_CMP);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 04:11:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cmp sign_extend(imm5), reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:11:32 +00:00
|
|
|
|
OP_260 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov;
|
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("cmp", OP_IMM_REG_CMP, 0);
|
|
|
|
|
temp = SEXT5 (OP[0]);
|
1996-08-30 04:11:32 +00:00
|
|
|
|
op0 = temp;
|
|
|
|
|
op1 = State.regs[OP[1]];
|
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 04:11:32 +00:00
|
|
|
|
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
|
|
|
|
|
&& (op1 & 0x80000000) != (result & 0x80000000));
|
|
|
|
|
|
|
|
|
|
/* Set condition codes. */
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 04:11:32 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG_CMP);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 04:11:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* setf cccc,reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:11:32 +00:00
|
|
|
|
OP_7E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("setf", OP_EX1, 0);
|
1996-08-30 04:11:32 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[ OP[1] ] = condition_met (OP[0]);
|
1996-08-30 04:11:32 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_EX1);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 04:11:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* zxh reg1 */
|
1996-08-30 04:59:02 +00:00
|
|
|
|
/* satadd reg,reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:59:02 +00:00
|
|
|
|
OP_C0 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("zxh", OP_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[0] ] &= 0xffff;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_output (OP_REG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
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 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return 2;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* satadd sign_extend(imm5), reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:59:02 +00:00
|
|
|
|
OP_220 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
|
|
|
|
|
int temp;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("satadd", OP_IMM_REG, 0);
|
|
|
|
|
|
1996-08-30 04:59:02 +00:00
|
|
|
|
/* Compute the result. */
|
1996-09-11 20:54:21 +00:00
|
|
|
|
temp = SEXT5 (OP[0]);
|
1996-08-30 04:59:02 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 04:59:02 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
1996-08-30 16:41:39 +00:00
|
|
|
|
if (sat && s)
|
1996-08-30 04:59:02 +00:00
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* satsub reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* sxb reg1 */
|
|
|
|
|
int
|
1996-08-30 04:59:02 +00:00
|
|
|
|
OP_A0 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("sxb", OP_REG, 0);
|
1996-08-30 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[ OP[0] ] = SEXT8 (State.regs[ OP[0] ]);
|
1996-08-30 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_output (OP_REG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
1996-08-30 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return 2;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* satsubi sign_extend(imm16), reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:59:02 +00:00
|
|
|
|
OP_660 ()
|
|
|
|
|
{
|
|
|
|
|
unsigned int op0, op1, result, z, s, cy, ov, sat;
|
|
|
|
|
int temp;
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("satsubi", OP_IMM_REG, 0);
|
|
|
|
|
|
1996-08-30 04:59:02 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
temp = SEXT16 (OP[2]);
|
1996-08-30 04:59:02 +00:00
|
|
|
|
op0 = temp;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-30 04:59:02 +00:00
|
|
|
|
result = op1 - op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
cy = (op1 < op0);
|
1996-08-30 04:59:02 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 04:59:02 +00:00
|
|
|
|
| (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0)
|
|
|
|
|
| (sat ? PSW_SAT : 0));
|
|
|
|
|
|
|
|
|
|
/* Handle saturated results. */
|
1996-08-30 16:41:39 +00:00
|
|
|
|
if (sat && s)
|
1996-08-30 04:59:02 +00:00
|
|
|
|
State.regs[OP[1]] = 0x80000000;
|
|
|
|
|
else if (sat)
|
|
|
|
|
State.regs[OP[1]] = 0x7fffffff;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
/* satsubr reg,reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* zxb reg1 */
|
|
|
|
|
int
|
1996-08-30 04:59:02 +00:00
|
|
|
|
OP_80 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("zxb", OP_REG, 0);
|
1996-08-30 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[ OP[0] ] &= 0xff;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_output (OP_REG);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
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 04:59:02 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return 2;
|
1996-08-30 04:59:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 04:11:32 +00:00
|
|
|
|
/* tst reg,reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-30 04:11:32 +00:00
|
|
|
|
OP_160 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-30 04:11:32 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("tst", OP_REG_REG_CMP, 0);
|
|
|
|
|
|
1996-08-30 04:11:32 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 04:11:32 +00:00
|
|
|
|
result = op0 & op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the condition codes. */
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG_CMP);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 04:11:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-29 19:53:37 +00:00
|
|
|
|
/* mov reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("mov", OP_REG_REG_MOVE, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = State.regs[ OP[0] ];
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG_MOVE);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-29 19:53:37 +00:00
|
|
|
|
/* mov sign_extend(imm5), reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* callt imm6 */
|
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_200 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
unsigned long adr;
|
|
|
|
|
|
|
|
|
|
trace_input ("callt", OP_LOAD16, 1);
|
|
|
|
|
|
|
|
|
|
CTPC = PC + 2;
|
|
|
|
|
CTPSW = PSW;
|
|
|
|
|
|
|
|
|
|
adr = CTBP + ((OP[3] & 0x3f) << 1);
|
|
|
|
|
|
|
|
|
|
PC = CTBP + load_mem (adr, 1);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_LOAD16);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
int value = SEXT5 (OP[0]);
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
trace_input ("mov", OP_IMM_REG_MOVE, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = value;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_MOVE);
|
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* mov imm32, reg1 */
|
1996-08-29 19:53:37 +00:00
|
|
|
|
/* movea sign_extend(imm16), reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_620 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("mov", OP_IMM32_REG, 4);
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[ OP[0] ] = load_mem (PC + 2, 4);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM32_REG);
|
|
|
|
|
|
|
|
|
|
return 6;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
trace_input ("movea", OP_IMM_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = State.regs[ OP[0] ] + SEXT16 (OP[2]);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* dispose imm5, list12 [, reg1] */
|
1996-08-29 19:53:37 +00:00
|
|
|
|
/* movhi imm16, reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_640 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* start-sanitize-v850e */
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if (OP[1] == 0)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("dispose", OP_PUSHPOP1, 0);
|
|
|
|
|
|
|
|
|
|
SP += (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
1997-08-22 17:41:20 +00:00
|
|
|
|
/* Load the registers with lower number registers being retrieved from higher addresses. */
|
|
|
|
|
for (i = 12; i--;)
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
State.regs[ 20 + i ] = load_mem (SP, 4);
|
|
|
|
|
SP += 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((OP[3] & 0x1f0000) != 0)
|
|
|
|
|
{
|
|
|
|
|
PC = State.regs[ (OP[3] >> 16) & 0x1f];
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* end-sanitize-v850e */
|
|
|
|
|
{
|
|
|
|
|
trace_input ("movhi", OP_UIMM_REG_REG, 16);
|
|
|
|
|
|
1997-09-03 04:10:33 +00:00
|
|
|
|
State.regs[ OP[1] ] = State.regs[ OP[0] ] + (OP[2] << 16);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_UIMM_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* sar zero_extend(imm5),reg1 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 22:29:41 +00:00
|
|
|
|
OP_2A0 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sar", OP_IMM_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = OP[0];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:23:36 +00:00
|
|
|
|
result = (signed)op1 >> op0;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (op0 - 1)));
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[ OP[1] ] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-09-03 18:31:48 +00:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
}
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* sar reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 22:29:41 +00:00
|
|
|
|
OP_A007E0 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("sar", OP_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
op0 = State.regs[ OP[0] ] & 0x1f;
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:23:36 +00:00
|
|
|
|
result = (signed)op1 >> op0;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (op0 - 1)));
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:23:36 +00:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
}
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* shl zero_extend(imm5),reg1 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_2C0 ()
|
1996-08-29 22:29:41 +00:00
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("shl", OP_IMM_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = OP[0];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:23:36 +00:00
|
|
|
|
result = op1 << op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
cy = (op1 & (1 << (32 - op0)));
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:23:36 +00:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
}
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* shl reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 22:29:41 +00:00
|
|
|
|
OP_C007E0 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("shl", OP_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ] & 0x1f;
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:23:36 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:23:36 +00:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
}
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00:00
|
|
|
|
/* shr zero_extend(imm5),reg1 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 22:29:41 +00:00
|
|
|
|
OP_280 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("shr", OP_IMM_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = OP[0];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:23:36 +00:00
|
|
|
|
result = op1 >> op0;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
|
1996-08-30 03:23:36 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:23:36 +00:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_IMM_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* shr reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 22:29:41 +00:00
|
|
|
|
OP_8007E0 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s, cy;
|
1996-08-30 03:23:36 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("shr", OP_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ] & 0x1f;
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-30 03:23:36 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV | PSW_CY);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
|
1996-08-30 03:23:36 +00:00
|
|
|
|
| (cy ? PSW_CY : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 22:29:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* or reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_100 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("or", OP_REG_REG, 0);
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = op0 | op1;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ori zero_extend(imm16), reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_680 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("ori", OP_UIMM_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = OP[2];
|
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = op0 | op1;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_UIMM_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* and reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 01:06:42 +00:00
|
|
|
|
OP_140 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 01:06:42 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("and", OP_REG_REG, 0);
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = op0 & op1;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* andi zero_extend(imm16), reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_6C0 ()
|
|
|
|
|
{
|
1997-08-20 20:57:05 +00:00
|
|
|
|
unsigned int result, z;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("andi", OP_UIMM_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
result = OP[2] & State.regs[ OP[0] ];
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[ OP[1] ] = result;
|
|
|
|
|
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= (z ? PSW_Z : 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_UIMM_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* xor reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_120 ()
|
1996-08-29 01:06:42 +00:00
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("xor", OP_REG_REG, 0);
|
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
|
|
|
|
op1 = State.regs[ OP[1] ];
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = op0 ^ op1;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00: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 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* xori zero_extend(imm16), reg, reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 19:53:37 +00:00
|
|
|
|
OP_6A0 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, op1, result, z, s;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("xori", OP_UIMM_REG_REG, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = OP[2];
|
|
|
|
|
op1 = State.regs[ OP[0] ];
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = op0 ^ op1;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
|
|
|
|
|
|
|
|
|
/* Store the result and condition codes. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_UIMM_REG_REG);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* not reg1, reg2 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 23:39:23 +00:00
|
|
|
|
OP_20 ()
|
|
|
|
|
{
|
1996-09-03 18:31:48 +00:00
|
|
|
|
unsigned int op0, result, z, s;
|
1996-08-29 23:39:23 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("not", OP_REG_REG_MOVE, 0);
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Compute the result. */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-29 23:39:23 +00:00
|
|
|
|
result = ~op0;
|
|
|
|
|
|
|
|
|
|
/* Compute the condition codes. */
|
|
|
|
|
z = (result == 0);
|
|
|
|
|
s = (result & 0x80000000);
|
1996-08-29 19:53:37 +00:00
|
|
|
|
|
1996-08-29 23:39:23 +00:00
|
|
|
|
/* Store the result and condition codes. */
|
|
|
|
|
State.regs[OP[1]] = result;
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_OV);
|
|
|
|
|
PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_REG_REG_MOVE);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 2;
|
1996-08-29 01:06:42 +00: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 05:41:10 +00:00
|
|
|
|
/* set1 */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_7C0 ()
|
1996-08-29 19:53:37 +00:00
|
|
|
|
{
|
1996-08-30 16:35:10 +00:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 18:31:48 +00:00
|
|
|
|
int temp;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("set1", OP_BIT, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
temp = SEXT16 (OP[2]);
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op2 = temp;
|
1996-10-24 17:39:30 +00:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW |= PSW_Z;
|
1996-08-30 21:55:26 +00:00
|
|
|
|
temp |= (1 << op1);
|
1996-10-24 17:39:30 +00:00
|
|
|
|
store_mem (op0 + op2, 1, temp);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 19:53:37 +00: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 05:41:10 +00:00
|
|
|
|
/* not1 */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_47C0 ()
|
1996-08-29 19:53:37 +00:00
|
|
|
|
{
|
1996-08-30 16:35:10 +00:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 18:31:48 +00:00
|
|
|
|
int temp;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("not1", OP_BIT, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
temp = SEXT16 (OP[2]);
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op2 = temp;
|
1996-10-24 17:39:30 +00:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW |= PSW_Z;
|
1996-08-30 21:55:26 +00:00
|
|
|
|
temp ^= (1 << op1);
|
1996-10-24 17:39:30 +00:00
|
|
|
|
store_mem (op0 + op2, 1, temp);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 19:53:37 +00: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 05:41:10 +00:00
|
|
|
|
/* clr1 */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_87C0 ()
|
|
|
|
|
{
|
1996-08-30 16:35:10 +00:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 18:31:48 +00:00
|
|
|
|
int temp;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("clr1", OP_BIT, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
temp = SEXT16 (OP[2]);
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op2 = temp;
|
1996-10-24 17:39:30 +00:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW |= PSW_Z;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
temp &= ~(1 << op1);
|
1996-10-24 17:39:30 +00:00
|
|
|
|
store_mem (op0 + op2, 1, temp);
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* tst1 */
|
1997-08-20 20:57:05 +00: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 05:41:10 +00:00
|
|
|
|
OP_C7C0 ()
|
1996-08-29 19:53:37 +00:00
|
|
|
|
{
|
1996-08-30 16:35:10 +00:00
|
|
|
|
unsigned int op0, op1, op2;
|
1996-09-03 18:31:48 +00:00
|
|
|
|
int temp;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("tst1", OP_BIT, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
op0 = State.regs[ OP[0] ];
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op1 = OP[1] & 0x7;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
temp = SEXT16 (OP[2]);
|
1996-08-30 16:35:10 +00:00
|
|
|
|
op2 = temp;
|
1996-10-24 17:39:30 +00:00
|
|
|
|
temp = load_mem (op0 + op2, 1);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~PSW_Z;
|
1996-08-30 16:35:10 +00:00
|
|
|
|
if ((temp & (1 << op1)) == 0)
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW |= PSW_Z;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_BIT);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 19:53:37 +00:00
|
|
|
|
}
|
1996-08-29 20:08:37 +00:00
|
|
|
|
|
1996-09-28 01:38:45 +00:00
|
|
|
|
/* breakpoint */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-09-28 01:38:45 +00:00
|
|
|
|
OP_FFFF ()
|
|
|
|
|
{
|
|
|
|
|
State.exception = SIGTRAP;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
return -4;
|
1996-09-28 01:38:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 04:11:32 +00:00
|
|
|
|
/* di */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_16007E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("di", OP_NONE, 0);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW |= PSW_ID;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_NONE);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 04:11:32 +00:00
|
|
|
|
/* ei */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_16087E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("ei", OP_NONE, 0);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PSW &= ~PSW_ID;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_NONE);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-27 19:50:03 +00:00
|
|
|
|
/* halt */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_12007E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("halt", OP_NONE, 0);
|
1996-12-27 19:50:03 +00:00
|
|
|
|
/* FIXME this should put processor into a mode where NMI still handled */
|
1996-09-03 16:25:51 +00:00
|
|
|
|
State.exception = SIGQUIT;
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_NONE);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-27 19:50:03 +00:00
|
|
|
|
/* reti */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_14007E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("reti", OP_NONE, 0);
|
|
|
|
|
trace_output (OP_NONE);
|
1996-10-24 17:39:30 +00:00
|
|
|
|
|
1996-12-27 19:50:03 +00:00
|
|
|
|
/* Restore for NMI if only NP on, otherwise is interrupt or exception. */
|
|
|
|
|
if ((PSW & (PSW_NP | PSW_EP)) == PSW_NP)
|
|
|
|
|
{
|
|
|
|
|
PC = FEPC - 4;
|
|
|
|
|
PSW = FEPSW;
|
1996-10-24 17:39:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1996-12-27 19:50:03 +00:00
|
|
|
|
PC = EIPC - 4;
|
|
|
|
|
PSW = EIPSW;
|
1996-10-24 17:39:30 +00:00
|
|
|
|
}
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-27 19:50:03 +00:00
|
|
|
|
/* trap */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_10007E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("trap", OP_TRAP, 0);
|
|
|
|
|
trace_output (OP_TRAP);
|
|
|
|
|
|
1996-10-24 17:39:30 +00:00
|
|
|
|
/* Trap 31 is used for simulating OS I/O functions */
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
1996-10-24 17:39:30 +00:00
|
|
|
|
if (OP[0] == 31)
|
1996-09-03 16:25:51 +00: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 17:39:30 +00:00
|
|
|
|
#define MEMPTR(x) (map (x))
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
|
|
|
|
switch (FUNC)
|
|
|
|
|
{
|
1997-09-01 03:43:56 +00:00
|
|
|
|
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#ifdef HAVE_FORK
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#ifdef SYS_fork
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_fork:
|
|
|
|
|
RETVAL = fork ();
|
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#ifdef HAVE_EXECVE
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#ifdef SYS_execv
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_execve:
|
1997-09-04 10:10:02 +00: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 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#if HAVE_EXECV
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#ifdef SYS_execv
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_execv:
|
1997-09-04 10:10:02 +00: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 06:05:19 +00:00
|
|
|
|
#endif
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1996-09-10 02:51:07 +00:00
|
|
|
|
#if 0
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#ifdef SYS_pipe
|
1996-09-03 16:25:51 +00: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 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#if 0
|
|
|
|
|
#ifdef SYS_wait
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_wait:
|
|
|
|
|
{
|
|
|
|
|
int status;
|
|
|
|
|
|
|
|
|
|
RETVAL = wait (&status);
|
|
|
|
|
SW (PARM1, status);
|
|
|
|
|
}
|
|
|
|
|
break;
|
1996-09-10 02:51:07 +00:00
|
|
|
|
#endif
|
1996-09-03 16:25:51 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#ifdef SYS_read
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_read:
|
1997-09-04 10:10:02 +00: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 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_write
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_write:
|
1997-09-04 10:10:02 +00: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 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_lseek
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_lseek:
|
1997-09-03 04:10:33 +00:00
|
|
|
|
RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_close
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_close:
|
1997-09-03 04:10:33 +00:00
|
|
|
|
RETVAL = sim_io_close (simulator, PARM1);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_open
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_open:
|
1997-09-04 10:10:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *buf = fetch_str (simulator, PARM1);
|
|
|
|
|
RETVAL = sim_io_open (simulator, buf, PARM2);
|
|
|
|
|
zfree (buf);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_exit
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_exit:
|
1996-12-31 23:18:55 +00:00
|
|
|
|
if ((PARM1 & 0xffff0000) == 0xdead0000 && (PARM1 & 0xffff) != 0)
|
|
|
|
|
State.exception = PARM1 & 0xffff; /* get signal encoded by kill */
|
|
|
|
|
else if (PARM1 == 0xdead)
|
|
|
|
|
State.exception = SIGABRT; /* old libraries */
|
|
|
|
|
else
|
|
|
|
|
State.exception = SIG_V850_EXIT; /* PARM1 has exit status encoded */
|
1996-09-03 16:25:51 +00:00
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#ifdef SYS_stat
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_stat: /* added at hmsi */
|
|
|
|
|
/* stat system call */
|
|
|
|
|
{
|
|
|
|
|
struct stat host_stat;
|
|
|
|
|
reg_t buf;
|
1997-09-04 10:10:02 +00:00
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
1997-09-04 10:10:02 +00:00
|
|
|
|
RETVAL = stat (path, &host_stat);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
1997-09-04 10:10:02 +00:00
|
|
|
|
zfree (path);
|
1996-09-03 16:25:51 +00:00
|
|
|
|
buf = PARM2;
|
|
|
|
|
|
1996-10-29 21:24:01 +00: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 16:25:51 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1996-09-03 16:25:51 +00:00
|
|
|
|
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#ifdef HAVE_CHOWN
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#ifdef SYS_chown
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_chown:
|
1997-09-04 10:10:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
|
|
|
|
RETVAL = chown (path, PARM2, PARM3);
|
|
|
|
|
zfree (path);
|
|
|
|
|
}
|
1996-09-03 16:25:51 +00:00
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if HAVE_CHMOD
|
1997-09-04 10:10:02 +00:00
|
|
|
|
#ifdef SYS_chmod
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_chmod:
|
1997-09-04 10:10:02 +00:00
|
|
|
|
{
|
|
|
|
|
char *path = fetch_str (simulator, PARM1);
|
|
|
|
|
RETVAL = chmod (path, PARM2);
|
|
|
|
|
zfree (path);
|
|
|
|
|
}
|
1996-09-03 16:25:51 +00:00
|
|
|
|
break;
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#ifdef SYS_time
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#if HAVE_TIME
|
1996-10-30 15:51:39 +00:00
|
|
|
|
case SYS_time:
|
1996-12-27 19:50:03 +00:00
|
|
|
|
{
|
|
|
|
|
time_t now;
|
|
|
|
|
RETVAL = time (&now);
|
|
|
|
|
store_mem (PARM1, 4, now);
|
|
|
|
|
}
|
1996-10-30 15:51:39 +00:00
|
|
|
|
break;
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#endif
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#ifdef SYS_times
|
1996-10-30 16:30:59 +00: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 06:05:19 +00:00
|
|
|
|
#endif
|
1997-09-01 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SYS_gettimeofday
|
|
|
|
|
#if !defined(__GO32__) && !defined(_WIN32)
|
1996-10-30 16:30:59 +00: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 03:43:56 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#ifdef SYS_utime
|
1997-09-03 04:10:33 +00:00
|
|
|
|
#if HAVE_UTIME
|
1996-09-03 16:25:51 +00:00
|
|
|
|
case SYS_utime:
|
1997-09-04 10:10:02 +00: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 16:25:51 +00:00
|
|
|
|
break;
|
1997-04-17 06:05:19 +00:00
|
|
|
|
#endif
|
|
|
|
|
#endif
|
1997-09-01 03:43:56 +00:00
|
|
|
|
|
1996-09-03 16:25:51 +00:00
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
RETERR = errno;
|
|
|
|
|
errno = save_errno;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-09-03 16:25:51 +00:00
|
|
|
|
}
|
1996-10-24 17:39:30 +00:00
|
|
|
|
else
|
|
|
|
|
{ /* Trap 0 -> 30 */
|
1996-12-27 19:50:03 +00: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 17:39:30 +00:00
|
|
|
|
PC = ((OP[0] < 0x10) ? 0x40 : 0x50) - 4;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
1996-09-03 16:25:51 +00:00
|
|
|
|
}
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-08-30 05:09:08 +00:00
|
|
|
|
/* ldsr, reg,reg */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_2007E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("ldsr", OP_LDSR, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.sregs[ OP[1] ] = State.regs[ OP[0] ];
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_LDSR);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1996-08-29 20:08:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-12-27 19:50:03 +00:00
|
|
|
|
/* stsr */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
int
|
1996-08-29 20:08:37 +00:00
|
|
|
|
OP_4007E0 ()
|
|
|
|
|
{
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_input ("stsr", OP_STSR, 0);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = State.sregs[ OP[0] ];
|
|
|
|
|
|
1996-09-11 20:54:21 +00:00
|
|
|
|
trace_output (OP_STSR);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* tst1 reg2, [reg1] */
|
|
|
|
|
int
|
|
|
|
|
OP_E607E0 (void)
|
|
|
|
|
{
|
|
|
|
|
int temp;
|
|
|
|
|
|
|
|
|
|
trace_input ("tst1", OP_BIT_LOAD, 1);
|
|
|
|
|
|
|
|
|
|
temp = load_mem (State.regs[ OP[0] ], 1);
|
|
|
|
|
|
|
|
|
|
PSW &= ~PSW_Z;
|
|
|
|
|
if ((temp & (1 << State.regs[ OP[1] & 0x7 ])) == 0)
|
|
|
|
|
PSW |= PSW_Z;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_BIT_LOAD);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:42:55 +00: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-08-20 20:57:05 +00: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 20:08:37 +00:00
|
|
|
|
}
|
1997-08-20 20:57:05 +00: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-20 22:42:55 +00:00
|
|
|
|
/* This function is courtesy of Sugimoto at NEC, via Seow Tan (Soew_Tan@el.nec.com) */
|
|
|
|
|
static void
|
|
|
|
|
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 04:10:33 +00:00
|
|
|
|
unsigned long ald = sfi >> (N - 1);
|
1997-08-20 22:42:55 +00: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 04:10:33 +00:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-20 22:42:55 +00: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 04:10:33 +00:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-20 22:42:55 +00: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 04:10:33 +00:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-20 22:42:55 +00: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) */
|
|
|
|
|
static void
|
|
|
|
|
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 04:10:33 +00:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-20 22:42:55 +00: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 04:10:33 +00:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-20 22:42:55 +00: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 04:10:33 +00:00
|
|
|
|
C = (((alt >> 31) & (ald >> 31))
|
|
|
|
|
| (((alt >> 31) ^ (ald >> 31)) & (~alo >> 31)));
|
1997-08-20 22:42:55 +00: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 04:10:33 +00:00
|
|
|
|
if (((alo != 0) && ((SS ^ SD) ^ R1))
|
|
|
|
|
|| ((alo == 0) && (SS ^ R1)))
|
1997-08-20 22:42:55 +00:00
|
|
|
|
alo = ald + 1;
|
|
|
|
|
else
|
|
|
|
|
alo = ald;
|
|
|
|
|
|
|
|
|
|
OV = (DBZ | R1) ? OV : ((alo >> 31) & (~ald >> 31));
|
|
|
|
|
|
|
|
|
|
* quotient_ptr = alo;
|
|
|
|
|
* overflow_ptr = OV;
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00:00
|
|
|
|
/* sdivun imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_1C207E0 (void)
|
|
|
|
|
{
|
1997-08-20 22:42:55 +00: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 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivun", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divun (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sdivn imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_1C007E0 (void)
|
|
|
|
|
{
|
1997-08-20 22:42:55 +00: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 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivn", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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-20 22:42:55 +00: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 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivhun", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ] & 0xffff;
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divun (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* sdivhn imm5, reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_18007E0 (void)
|
|
|
|
|
{
|
1997-08-20 22:42:55 +00: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 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_input ("sdivhn", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = SEXT16 (State.regs[ OP[0] ]);
|
|
|
|
|
divide_this = State.regs[ OP[1] ] << imm5;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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;
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
/* start-sanitize-v850e */
|
|
|
|
|
/* divu reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_2C207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long int quotient;
|
|
|
|
|
unsigned long int remainder;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
unsigned long int divide_by;
|
|
|
|
|
unsigned long int divide_this;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
|
|
|
|
if ((OP[3] & 0x3c0000) == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("divu", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
if (divide_by == 0)
|
1997-08-20 20:57:05 +00:00
|
|
|
|
{
|
|
|
|
|
overflow = true;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = 1;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
/* start-sanitize-v850eq */
|
1997-08-20 22:42:55 +00:00
|
|
|
|
/* divun imm5, reg1, reg2, reg3 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned int imm5;
|
|
|
|
|
|
|
|
|
|
trace_input ("divun", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divun (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* div reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_2C007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
signed long int quotient;
|
|
|
|
|
signed long int remainder;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
signed long int divide_by;
|
|
|
|
|
signed long int divide_this;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
|
|
|
|
if ((OP[3] & 0x3c0000) == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("div", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
if (divide_by == 0 || (divide_by == -1 && divide_this == (1 << 31)))
|
1997-08-20 20:57:05 +00:00
|
|
|
|
{
|
1997-08-20 22:42:55 +00:00
|
|
|
|
overflow = true;
|
|
|
|
|
divide_by = 1;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
1997-08-20 20:57:05 +00: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_REG_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
/* start-sanitize-v850eq */
|
1997-08-20 22:42:55 +00:00
|
|
|
|
/* divn imm5, reg1, reg2, reg3 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned int imm5;
|
|
|
|
|
|
|
|
|
|
trace_input ("divn", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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);
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* divhu reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_28207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long int quotient;
|
|
|
|
|
unsigned long int remainder;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
unsigned long int divide_by;
|
|
|
|
|
unsigned long int divide_this;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
|
|
|
|
if ((OP[3] & 0x3c0000) == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("divhu", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ] & 0xffff;
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
if (divide_by == 0)
|
1997-08-20 20:57:05 +00:00
|
|
|
|
{
|
|
|
|
|
overflow = true;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = 1;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
/* start-sanitize-v850eq */
|
1997-08-20 22:42:55 +00:00
|
|
|
|
/* divhun imm5, reg1, reg2, reg3 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned int imm5;
|
|
|
|
|
|
|
|
|
|
trace_input ("divhun", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ] & 0xffff;
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divun (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
if (quotient & 0x80000000) PSW |= PSW_S;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* divh reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_28007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
signed long int quotient;
|
|
|
|
|
signed long int remainder;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
signed long int divide_by;
|
|
|
|
|
signed long int divide_this;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
boolean overflow = false;
|
|
|
|
|
|
|
|
|
|
if ((OP[3] & 0x3c0000) == 0)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("divh", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
/* Compute the result. */
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = State.regs[ OP[0] ];
|
|
|
|
|
divide_this = SEXT16 (State.regs[ OP[1] ]);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
if (divide_by == 0 || (divide_by == -1 && divide_this == (1 << 31)))
|
1997-08-20 20:57:05 +00:00
|
|
|
|
{
|
|
|
|
|
overflow = true;
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = 1;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient = divide_this / divide_by;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder = divide_this % divide_by;
|
1997-08-20 20:57:05 +00: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_REG_REG_REG);
|
|
|
|
|
}
|
|
|
|
|
/* start-sanitize-v850eq */
|
1997-08-20 22:42:55 +00:00
|
|
|
|
/* divhn imm5, reg1, reg2, reg3 */
|
1997-08-20 20:57:05 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
unsigned int imm5;
|
|
|
|
|
|
|
|
|
|
trace_input ("divhn", OP_IMM_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
imm5 = 32 - ((OP[3] & 0x3c0000) >> 17);
|
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divide_by = SEXT16 (State.regs[ OP[0] ]);
|
|
|
|
|
divide_this = State.regs[ OP[1] ];
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
divn (imm5, divide_by, divide_this, & quotient, & remainder, & overflow);
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
1997-08-20 22:42:55 +00:00
|
|
|
|
State.regs[ OP[1] ] = quotient;
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = remainder;
|
1997-08-20 20:57:05 +00: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);
|
|
|
|
|
}
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cmov imm5, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_30007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("cmov", OP_IMM_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = condition_met (OP[0]) ? SEXT5( OP[0] ) : State.regs[ OP[1] ];
|
|
|
|
|
|
|
|
|
|
trace_output (OP_IMM_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ctret */
|
|
|
|
|
int
|
|
|
|
|
OP_14407E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("ctret", OP_NONE, 0);
|
|
|
|
|
|
|
|
|
|
PC = CTPC;
|
|
|
|
|
PSW = CTPSW;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_NONE);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* hsw */
|
|
|
|
|
int
|
|
|
|
|
OP_34407E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long value;
|
|
|
|
|
|
|
|
|
|
trace_input ("hsw", OP_REG_REG3, 0);
|
|
|
|
|
|
|
|
|
|
value = State.regs[ OP[ 1 ] ];
|
|
|
|
|
value >>= 16;
|
|
|
|
|
value |= (State.regs[ OP[ 1 ] ] << 16);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = value;
|
|
|
|
|
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (value == 0) PSW |= PSW_Z;
|
|
|
|
|
if (value & 0x80000000) PSW |= PSW_S;
|
|
|
|
|
if (((value & 0xffff) == 0) || (value & 0xffff0000) == 0) PSW |= PSW_CY;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG3);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define WORDHASNULLBYTE(x) (((x) - 0x01010101) & ~(x)&0x80808080)
|
|
|
|
|
|
|
|
|
|
/* bsw */
|
|
|
|
|
int
|
|
|
|
|
OP_34007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long value;
|
|
|
|
|
|
|
|
|
|
trace_input ("bsw", OP_REG_REG3, 0);
|
|
|
|
|
|
|
|
|
|
value = State.regs[ OP[ 1 ] ];
|
|
|
|
|
value >>= 24;
|
|
|
|
|
value |= (State.regs[ OP[ 1 ] ] << 24);
|
|
|
|
|
value |= ((State.regs[ OP[ 1 ] ] << 8) & 0x00ff0000);
|
|
|
|
|
value |= ((State.regs[ OP[ 1 ] ] >> 8) & 0x0000ff00);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = value;
|
|
|
|
|
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (value == 0) PSW |= PSW_Z;
|
|
|
|
|
if (value & 0x80000000) PSW |= PSW_S;
|
|
|
|
|
if (WORDHASNULLBYTE (value)) PSW |= PSW_CY;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG3);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* bsh */
|
|
|
|
|
int
|
|
|
|
|
OP_34207E0 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long value;
|
|
|
|
|
|
|
|
|
|
trace_input ("bsh", OP_REG_REG3, 0);
|
|
|
|
|
|
|
|
|
|
value = State.regs[ OP[ 1 ] ];
|
|
|
|
|
value >>= 8;
|
|
|
|
|
value |= ((State.regs[ OP[ 1 ] ] << 8) & 0xff00ff00);
|
|
|
|
|
value |= ((State.regs[ OP[ 1 ] ] >> 8) & 0x000000ff);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = value;
|
|
|
|
|
|
|
|
|
|
PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
|
|
|
|
|
|
|
|
|
|
if (value == 0) PSW |= PSW_Z;
|
|
|
|
|
if (value & 0x80000000) PSW |= PSW_S;
|
1997-08-22 17:41:20 +00:00
|
|
|
|
if (((value & 0xff) == 0) || (value & 0x00ff) == 0) PSW |= PSW_CY;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG3);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* pushml list18 */
|
|
|
|
|
/* ld.hu */
|
|
|
|
|
int
|
|
|
|
|
OP_107E0 (void)
|
|
|
|
|
{
|
|
|
|
|
if (OP[ 1 ] == 0)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("pushml", OP_PUSHPOP3, 0);
|
|
|
|
|
|
1997-08-22 17:41:20 +00:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 15; i++)
|
|
|
|
|
if ((OP[3] & (1 << type3_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP & ~ 3, 4, State.regs[ i + 1 ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (OP[3] & (1 << 3))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
|
|
|
|
|
store_mem (SP & ~ 3, 4, PSW);
|
|
|
|
|
}
|
|
|
|
|
|
1997-08-20 20:57:05 +00: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);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int adr;
|
|
|
|
|
|
|
|
|
|
trace_input ("ld.hu", OP_LOAD32, 2);
|
|
|
|
|
|
|
|
|
|
adr = State.regs[ OP[0] ] + SEXT16 (OP[2] & ~1);
|
|
|
|
|
adr &= ~0x1;
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = load_mem (adr, 2);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_LOAD32);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* prepare list12, imm5 */
|
|
|
|
|
/* ld.bu */
|
|
|
|
|
int
|
|
|
|
|
OP_10780 (void)
|
|
|
|
|
{
|
|
|
|
|
if (OP[ 1 ] == 0)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("prepare", OP_PUSHPOP1, 0);
|
|
|
|
|
|
1997-08-22 17:41:20 +00:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP, 4, State.regs[ 20 + i ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP -= (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
|
|
|
|
trace_output (OP_PUSHPOP1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int adr;
|
|
|
|
|
|
|
|
|
|
trace_input ("ld.bu", OP_LOAD32, 1);
|
|
|
|
|
|
1997-09-03 04:10:33 +00:00
|
|
|
|
adr = (State.regs[ OP[0] ]
|
|
|
|
|
+ (SEXT16 (OP[2] & ~1) | ((OP[3] >> 5) & 1)));
|
1997-08-20 20:57:05 +00:00
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = load_mem (adr, 1);
|
|
|
|
|
|
|
|
|
|
trace_output (OP_LOAD32);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* prepare list12, imm5, imm32 */
|
|
|
|
|
int
|
|
|
|
|
OP_1B0780 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("prepare", OP_PUSHPOP1, 0);
|
|
|
|
|
|
1997-08-22 17:41:20 +00:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 20:57:05 +00: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 17:41:20 +00:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 20:57:05 +00:00
|
|
|
|
if ((OP[3] & (1 << type1_regs[ i ])))
|
|
|
|
|
{
|
|
|
|
|
SP -= 4;
|
|
|
|
|
store_mem (SP, 4, State.regs[ 20 + i ]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SP -= (OP[3] & 0x3e) << 1;
|
|
|
|
|
|
|
|
|
|
EP = SEXT16 (load_mem (PC + 4, 2));
|
|
|
|
|
|
|
|
|
|
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 17:41:20 +00:00
|
|
|
|
/* Store the registers with lower number registers being placed at higher addresses. */
|
|
|
|
|
for (i = 0; i < 12; i++)
|
1997-08-20 20:57:05 +00: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-08-20 22:42:55 +00:00
|
|
|
|
/* sld.hu */
|
|
|
|
|
int
|
|
|
|
|
OP_70 (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned long result;
|
|
|
|
|
|
|
|
|
|
result = load_mem (State.regs[30] + ((OP[3] & 0xf) << 1), 2);
|
|
|
|
|
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#ifdef ARCH_v850eq
|
|
|
|
|
trace_input ("sld.h", OP_LOAD16, 2);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = SEXT16 (result);
|
|
|
|
|
#else
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
trace_input ("sld.hu", OP_LOAD16, 2);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[1] ] = result;
|
|
|
|
|
/* start-sanitize-v850eq */
|
|
|
|
|
#endif
|
|
|
|
|
/* end-sanitize-v850eq */
|
|
|
|
|
|
|
|
|
|
trace_output (OP_LOAD16);
|
|
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* cmov reg1, reg2, reg3 */
|
|
|
|
|
int
|
|
|
|
|
OP_32007E0 (void)
|
|
|
|
|
{
|
|
|
|
|
trace_input ("cmov", OP_REG_REG_REG, 0);
|
|
|
|
|
|
|
|
|
|
State.regs[ OP[2] >> 11 ] = condition_met (OP[0]) ? State.regs[ OP[0] ] : State.regs[ OP[1] ];
|
|
|
|
|
|
|
|
|
|
trace_output (OP_REG_REG_REG);
|
|
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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 20:57:05 +00: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 17:41:20 +00: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 20:57:05 +00: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 17:41:20 +00: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 20:57:05 +00:00
|
|
|
|
trace_output (OP_PUSHPOP2);
|
1997-09-03 04:10:33 +00:00
|
|
|
|
|
|
|
|
|
return 4;
|
1997-08-20 20:57:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* pushmh list18 */
|
|
|
|
|
int
|
|
|
|
|
OP_307E0 (void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
trace_input ("pushmh", OP_PUSHPOP2, 0);
|
|
|
|
|
|
1997-08-22 17:41:20 +00: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 20:57:05 +00: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 */
|