aboutsummaryrefslogtreecommitdiff
path: root/sim/v850/interp.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>1996-08-30 05:41:10 +0000
committerJeff Law <law@redhat.com>1996-08-30 05:41:10 +0000
commit28647e4c0c74b2426a530b2b9ec3c95b92944662 (patch)
tree553811bc975ea0ed40d410cea372ae15154662d5 /sim/v850/interp.c
parent614f1c68ed22305a0f0d9cadec899e39fa52fbb2 (diff)
downloadgdb-28647e4c0c74b2426a530b2b9ec3c95b92944662.zip
gdb-28647e4c0c74b2426a530b2b9ec3c95b92944662.tar.gz
gdb-28647e4c0c74b2426a530b2b9ec3c95b92944662.tar.bz2
* 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.
Diffstat (limited to 'sim/v850/interp.c')
-rw-r--r--sim/v850/interp.c101
1 files changed, 40 insertions, 61 deletions
diff --git a/sim/v850/interp.c b/sim/v850/interp.c
index d824590..fbd808d 100644
--- a/sim/v850/interp.c
+++ b/sim/v850/interp.c
@@ -6,8 +6,7 @@
#include "v850_sim.h"
-#define IMEM_SIZE 18 /* V850 instruction memory size is 18 bits */
-#define DMEM_SIZE 16 /* Data memory */
+#define MEM_SIZE 18 /* V850 memory size is 18 bits XXX */
uint16 OP[4];
@@ -72,82 +71,58 @@ lookup_hash (ins)
return (h);
}
-uint32
-get_longword (x)
- uint8 *x;
+uint8
+get_byte (x)
+ uint8 *x;
{
- uint8 *a = x;
- return (a[3]<<24) + (a[2]<<16) + (a[1]<<8) + (a[0]);
+ return *x;
}
-int64
-get_longlong (x)
- uint8 *x;
+uint16
+get_half (x)
+ uint8 *x;
{
uint8 *a = x;
- return ((int64)a[0]<<56) + ((int64)a[1]<<48) + ((int64)a[2]<<40) + ((int64)a[3]<<32) +
- ((int64)a[4]<< 24) + ((int64)a[5]<<16) + ((int64)a[6]<<8) + (int64)a[7];
+ return (a[1] << 8) + (a[0]);
}
-uint16
+uint32
get_word (x)
uint8 *x;
{
uint8 *a = x;
- return ((uint16)a[0]<<8) + a[1];
+ return (a[3]<<24) + (a[2]<<16) + (a[1]<<8) + (a[0]);
}
-
void
-write_word (addr, data)
+put_byte (addr, data)
uint8 *addr;
- uint16 data;
+ uint8 data;
{
uint8 *a = addr;
- a[0] = data >> 8;
- a[1] = data & 0xff;
+ a[0] = data;
}
void
-write_longword (addr, data)
+put_half (addr, data)
uint8 *addr;
- uint32 data;
+ uint16 data;
{
- addr[0] = (data >> 24) & 0xff;
- addr[1] = (data >> 16) & 0xff;
- addr[2] = (data >> 8) & 0xff;
- addr[3] = data & 0xff;
+ uint8 *a = addr;
+ a[0] = data & 0xff;
+ a[1] = (data >> 8) & 0xff;
}
void
-write_longlong (addr, data)
+put_word (addr, data)
uint8 *addr;
- int64 data;
+ uint32 data;
{
uint8 *a = addr;
- a[0] = data >> 56;
- a[1] = (data >> 48) & 0xff;
- a[2] = (data >> 40) & 0xff;
- a[3] = (data >> 32) & 0xff;
- a[4] = (data >> 24) & 0xff;
- a[5] = (data >> 16) & 0xff;
- a[6] = (data >> 8) & 0xff;
- a[7] = data & 0xff;
-}
-
-static void
-get_operands (struct simops *s, uint32 ins)
-{
- int i, shift, bits, flags;
- uint32 mask;
- for (i=0; i < s->numops; i++)
- {
- shift = s->operands[3*i];
- bits = s->operands[3*i+1];
- flags = s->operands[3*i+2];
- mask = 0x7FFFFFFF >> (31 - bits);
- OP[i] = (ins >> shift) & mask;
- }
+ a[0] = data & 0xff;
+ a[1] = (data >> 8) & 0xff;
+ a[2] = (data >> 16) & 0xff;
+ a[3] = (data >> 24) & 0xff;
}
static void
@@ -213,7 +188,14 @@ static void
do_format_7 (insn)
uint32 insn;
{
+ struct hash_entry *h;
printf("format 7 0x%x\n", insn);
+
+ h = lookup_hash (insn);
+ OP[0] = insn & 0x1f;
+ OP[1] = (insn >> 11) & 0x1f;
+ OP[2] = (insn >> 16) & 0xffff;
+ (h->ops->func) ();
}
static void
@@ -241,27 +223,24 @@ sim_size (power)
int power;
{
- if (State.imem)
+ if (State.mem)
{
- free (State.imem);
- free (State.dmem);
+ free (State.mem);
}
- State.imem = (uint8 *)calloc(1,1<<IMEM_SIZE);
- State.dmem = (uint8 *)calloc(1,1<<DMEM_SIZE);
- if (!State.imem || !State.dmem )
+ State.mem = (uint8 *)calloc(1,1<<MEM_SIZE);
+ if (!State.mem)
{
fprintf (stderr,"Memory allocation failed.\n");
exit(1);
}
- printf ("Allocated %d bytes instruction memory and\n",1<<IMEM_SIZE);
- printf (" %d bytes data memory.\n",1<<DMEM_SIZE);
+ printf ("Allocated %d bytes memory and\n",1<<MEM_SIZE);
}
static void
init_system ()
{
- if (!State.imem)
+ if (!State.mem)
sim_size(1);
}
@@ -277,7 +256,7 @@ sim_write (addr, buffer, size)
/* printf ("sim_write %d bytes to 0x%x\n",size,addr); */
for (i = 0; i < size; i++)
{
- State.imem[i+addr] = buffer[i];
+ State.mem[i+addr] = buffer[i];
}
return size;
}
@@ -486,7 +465,7 @@ sim_read (addr, buffer, size)
int i;
for (i = 0; i < size; i++)
{
- buffer[i] = State.imem[addr + i];
+ buffer[i] = State.mem[addr + i];
}
return size;
}