#include "v850_sim.h"
+#ifndef INLINE
+#ifdef __GNUC__
+#define INLINE inline
+#else
+#define INLINE
+#endif
+#endif
+
#define MEM_SIZE 18 /* V850 memory size is 18 bits XXX */
host_callback *v850_callback;
uint32 OP[4];
static struct hash_entry *lookup_hash PARAMS ((uint32 ins));
+static long hash PARAMS ((long));
+static void do_format_1_2 PARAMS ((uint32));
+static void do_format_3 PARAMS ((uint32));
+static void do_format_4 PARAMS ((uint32));
+static void do_format_5 PARAMS ((uint32));
+static void do_format_6 PARAMS ((uint32));
+static void do_format_7 PARAMS ((uint32));
+static void do_format_8 PARAMS ((uint32));
+static void do_format_9_10 PARAMS ((uint32));
+static void init_system PARAMS ((void));
#define MAX_HASH 63
struct hash_entry
struct hash_entry hash_table[MAX_HASH+1];
-static long
+
+static INLINE long
hash(insn)
long insn;
{
if ((insn & 0x0600) == 0
- || (insn & 0x0700) == 0x0200)
+ || (insn & 0x0700) == 0x0200
+ || (insn & 0x0700) == 0x0600
+ || (insn & 0x0780) == 0x0700)
return (insn & 0x07e0) >> 5;
if ((insn & 0x0700) == 0x0300
|| (insn & 0x0700) == 0x0400
|| (insn & 0x0700) == 0x0500)
return (insn & 0x0780) >> 7;
- if ((insn & 0x0700) == 0x0600)
- return (insn & 0x07e0) >> 5;
- if ((insn & 0x0780) == 0x0700)
- return (insn & 0x07e0) >> 5;
if ((insn & 0x07c0) == 0x0780)
return (insn & 0x07c0) >> 6;
- if ((insn & 0x07E0) == 0x07C0)
- return (insn & 0x07e0) >> 5;
return (insn & 0x07e0) >> 5;
}
h = &hash_table[hash(ins)];
- while ( (ins & h->mask) != h->opcode)
+ while ((ins & h->mask) != h->opcode)
{
if (h->next == NULL)
{
}
static void
-do_formats_9_10 (insn)
+do_format_9_10 (insn)
uint32 insn;
{
struct hash_entry *h;
char *args;
{
struct simops *s;
- struct hash_entry *h, *prev;
+ struct hash_entry *h;
if (args != NULL)
printf ("sim_open %s\n",args);
int step, siggnal;
{
uint32 inst, opcode;
- int i;
reg_t oldpc;
-
if (step)
State.exception = SIGTRAP;
else
}
else
{
- do_formats_9_10 (inst);
+ do_format_9_10 (inst);
PC += 4;
}
}
State.regs[rn]= *(uint32 *)memory;
}
+int
sim_read (addr, buffer, size)
SIM_ADDR addr;
unsigned char *buffer;
#include <signal.h>
#include "v850_sim.h"
#include "simops.h"
+#include "sys/syscall.h"
/* sld.b */
void
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
&& (op0 & 0x80000000) != (result & 0x80000000));
- /* According to the manual, 's' is inverted if 'ov'
- is set. */
- s = ov ? !s : s;
-
/* Store the result and condition codes. */
State.regs[OP[1]] = result;
State.sregs[5] &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
&& (op0 & 0x80000000) != (result & 0x80000000));
- /* According to the manual, 's' is inverted if 'ov'
- is set. */
- s = ov ? !s : s;
-
/* Store the result and condition codes. */
State.regs[OP[1]] = result;
State.sregs[5] &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
&& (op0 & 0x80000000) != (result & 0x80000000));
- /* According to the manual, 's' is inverted if 'ov'
- is set. */
- s = ov ? !s : s;
-
/* Store the result and condition codes. */
State.regs[OP[2]] = result;
State.sregs[5] &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
ov = ((op1 & 0x80000000) != (op0 & 0x80000000)
&& (op1 & 0x80000000) != (result & 0x80000000));
- /* According to the manual, 's' is inverted if 'ov'
- is set. */
- s = ov ? !s : s;
-
/* Store the result and condition codes. */
State.regs[OP[1]] = result;
State.sregs[5] &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
ov = ((op0 & 0x80000000) != (op1 & 0x80000000)
&& (op0 & 0x80000000) != (result & 0x80000000));
- /* According to the manual, 's' is inverted if 'ov'
- is set. */
- s = ov ? !s : s;
-
/* Store the result and condition codes. */
State.regs[OP[1]] = result;
State.sregs[5] &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
if (OP[0] == 0)
{
-#if 0
- char *fstr = State.regs[2] + State.imem;
- printf (fstr,State.regs[3],State.regs[4],State.regs[5]);
-#else
int save_errno = errno;
errno = 0;
switch (FUNC)
{
-#if 0
#if !defined(__GO32__) && !defined(_WIN32)
case SYS_fork:
RETVAL = fork ();
case SYS_execv:
RETVAL = execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL);
break;
+#if 0
case SYS_pipe:
{
reg_t buf;
SW (PARM1, status);
}
break;
+#endif
#endif
case SYS_read:
RETVAL = v850_callback->read (v850_callback, PARM1, MEMPTR (PARM2),
PARM3);
break;
-#endif
case SYS_write:
if (PARM1 == 1)
RETVAL = (int)v850_callback->write_stdout (v850_callback,
RETVAL = (int)v850_callback->write (v850_callback, PARM1,
MEMPTR (PARM2), PARM3);
break;
-#if 0
case SYS_lseek:
RETVAL = v850_callback->lseek (v850_callback, PARM1, PARM2, PARM3);
break;
case SYS_open:
RETVAL = v850_callback->open (v850_callback, MEMPTR (PARM1), PARM2);
break;
-#endif
case SYS_exit:
/* EXIT - caller can look in PARM1 to work out the
reason */
SLW (buf+28, host_stat.st_mtime);
SLW (buf+36, host_stat.st_ctime);
}
+#endif
break;
case SYS_chown:
if a prototype is present. */
RETVAL = utime (MEMPTR (PARM1), (void *) MEMPTR (PARM2));
break;
-#endif
default:
abort ();
}
RETERR = errno;
errno = save_errno;
-#endif
}
else if (OP[0] == 1 )
{