1996-11-25 19:52:08 +00:00
|
|
|
#include <signal.h>
|
1998-03-24 20:26:06 +00:00
|
|
|
|
|
|
|
#if WITH_COMMON
|
|
|
|
#include "sim-main.h"
|
1998-03-25 00:08:52 +00:00
|
|
|
#include "sim-options.h"
|
1998-03-27 03:10:53 +00:00
|
|
|
/* start-sanitize-am30 */
|
1998-03-25 04:15:38 +00:00
|
|
|
#include "sim-hw.h"
|
1998-03-27 03:10:53 +00:00
|
|
|
/* end-sanitize-am30 */
|
1998-03-24 20:26:06 +00:00
|
|
|
#else
|
|
|
|
#include "mn10300_sim.h"
|
|
|
|
#endif
|
|
|
|
|
1996-11-25 19:52:08 +00:00
|
|
|
#include "sysdep.h"
|
|
|
|
#include "bfd.h"
|
1998-03-24 20:26:06 +00:00
|
|
|
#include "sim-assert.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#else
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "bfd.h"
|
|
|
|
|
|
|
|
#ifndef INLINE
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define INLINE inline
|
|
|
|
#else
|
|
|
|
#define INLINE
|
|
|
|
#endif
|
|
|
|
#endif
|
1996-11-25 19:52:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
host_callback *mn10300_callback;
|
|
|
|
int mn10300_debug;
|
|
|
|
|
1998-03-24 20:26:06 +00:00
|
|
|
#if WITH_COMMON
|
|
|
|
#else
|
1997-05-06 19:27:22 +00:00
|
|
|
static void dispatch PARAMS ((uint32, uint32, int));
|
1996-11-25 19:52:08 +00:00
|
|
|
static long hash PARAMS ((long));
|
|
|
|
static void init_system PARAMS ((void));
|
1998-03-25 00:08:52 +00:00
|
|
|
|
|
|
|
static SIM_OPEN_KIND sim_kind;
|
|
|
|
static char *myname;
|
1997-05-06 19:27:22 +00:00
|
|
|
#define MAX_HASH 127
|
1996-11-25 19:52:08 +00:00
|
|
|
|
|
|
|
struct hash_entry
|
|
|
|
{
|
|
|
|
struct hash_entry *next;
|
|
|
|
long opcode;
|
|
|
|
long mask;
|
|
|
|
struct simops *ops;
|
1997-05-06 19:27:22 +00:00
|
|
|
#ifdef HASH_STAT
|
|
|
|
unsigned long count;
|
|
|
|
#endif
|
1996-11-25 19:52:08 +00:00
|
|
|
};
|
|
|
|
|
1997-05-16 22:37:02 +00:00
|
|
|
static int max_mem = 0;
|
1996-11-25 19:52:08 +00:00
|
|
|
struct hash_entry hash_table[MAX_HASH+1];
|
|
|
|
|
|
|
|
|
1996-12-06 21:19:37 +00:00
|
|
|
/* This probably doesn't do a very good job at bucket filling, but
|
|
|
|
it's simple... */
|
1996-11-25 19:52:08 +00:00
|
|
|
static INLINE long
|
|
|
|
hash(insn)
|
|
|
|
long insn;
|
|
|
|
{
|
1997-05-06 19:27:22 +00:00
|
|
|
/* These are one byte insns, we special case these since, in theory,
|
|
|
|
they should be the most heavily used. */
|
1996-12-06 21:19:37 +00:00
|
|
|
if ((insn & 0xffffff00) == 0)
|
|
|
|
{
|
1997-05-06 19:27:22 +00:00
|
|
|
switch (insn & 0xf0)
|
|
|
|
{
|
|
|
|
case 0x00:
|
|
|
|
return 0x70;
|
|
|
|
|
|
|
|
case 0x40:
|
|
|
|
return 0x71;
|
|
|
|
|
|
|
|
case 0x10:
|
|
|
|
return 0x72;
|
|
|
|
|
|
|
|
case 0x30:
|
|
|
|
return 0x73;
|
|
|
|
|
|
|
|
case 0x50:
|
|
|
|
return 0x74;
|
|
|
|
|
|
|
|
case 0x60:
|
|
|
|
return 0x75;
|
|
|
|
|
|
|
|
case 0x70:
|
|
|
|
return 0x76;
|
|
|
|
|
|
|
|
case 0x80:
|
|
|
|
return 0x77;
|
|
|
|
|
|
|
|
case 0x90:
|
|
|
|
return 0x78;
|
|
|
|
|
|
|
|
case 0xa0:
|
|
|
|
return 0x79;
|
|
|
|
|
|
|
|
case 0xb0:
|
|
|
|
return 0x7a;
|
|
|
|
|
|
|
|
case 0xe0:
|
|
|
|
return 0x7b;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0x7c;
|
|
|
|
}
|
1996-12-06 21:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* These are two byte insns */
|
|
|
|
if ((insn & 0xffff0000) == 0)
|
|
|
|
{
|
|
|
|
if ((insn & 0xf000) == 0x2000
|
|
|
|
|| (insn & 0xf000) == 0x5000)
|
1997-05-06 19:27:22 +00:00
|
|
|
return ((insn & 0xfc00) >> 8) & 0x7f;
|
1996-12-06 21:19:37 +00:00
|
|
|
|
|
|
|
if ((insn & 0xf000) == 0x4000)
|
1997-05-06 19:27:22 +00:00
|
|
|
return ((insn & 0xf300) >> 8) & 0x7f;
|
1996-12-06 21:19:37 +00:00
|
|
|
|
|
|
|
if ((insn & 0xf000) == 0x8000
|
|
|
|
|| (insn & 0xf000) == 0x9000
|
|
|
|
|| (insn & 0xf000) == 0xa000
|
|
|
|
|| (insn & 0xf000) == 0xb000)
|
1997-05-06 19:27:22 +00:00
|
|
|
return ((insn & 0xf000) >> 8) & 0x7f;
|
|
|
|
|
|
|
|
if ((insn & 0xff00) == 0xf000
|
|
|
|
|| (insn & 0xff00) == 0xf100
|
|
|
|
|| (insn & 0xff00) == 0xf200
|
|
|
|
|| (insn & 0xff00) == 0xf500
|
|
|
|
|| (insn & 0xff00) == 0xf600)
|
|
|
|
return ((insn & 0xfff0) >> 4) & 0x7f;
|
|
|
|
|
|
|
|
if ((insn & 0xf000) == 0xc000)
|
|
|
|
return ((insn & 0xff00) >> 8) & 0x7f;
|
|
|
|
|
|
|
|
return ((insn & 0xffc0) >> 6) & 0x7f;
|
1996-12-06 21:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* These are three byte insns. */
|
|
|
|
if ((insn & 0xff000000) == 0)
|
|
|
|
{
|
|
|
|
if ((insn & 0xf00000) == 0x000000)
|
1997-05-06 19:27:22 +00:00
|
|
|
return ((insn & 0xf30000) >> 16) & 0x7f;
|
1996-12-06 21:19:37 +00:00
|
|
|
|
|
|
|
if ((insn & 0xf00000) == 0x200000
|
|
|
|
|| (insn & 0xf00000) == 0x300000)
|
1997-05-06 19:27:22 +00:00
|
|
|
return ((insn & 0xfc0000) >> 16) & 0x7f;
|
|
|
|
|
|
|
|
if ((insn & 0xff0000) == 0xf80000)
|
|
|
|
return ((insn & 0xfff000) >> 12) & 0x7f;
|
1996-12-06 21:19:37 +00:00
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
if ((insn & 0xff0000) == 0xf90000)
|
|
|
|
return ((insn & 0xfffc00) >> 10) & 0x7f;
|
|
|
|
|
|
|
|
return ((insn & 0xff0000) >> 16) & 0x7f;
|
1996-12-06 21:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* These are four byte or larger insns. */
|
1997-05-06 19:27:22 +00:00
|
|
|
if ((insn & 0xf0000000) == 0xf0000000)
|
|
|
|
return ((insn & 0xfff00000) >> 20) & 0x7f;
|
|
|
|
|
|
|
|
return ((insn & 0xff000000) >> 24) & 0x7f;
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
1997-05-19 19:55:31 +00:00
|
|
|
static INLINE void
|
1997-05-06 19:27:22 +00:00
|
|
|
dispatch (insn, extension, length)
|
|
|
|
uint32 insn;
|
|
|
|
uint32 extension;
|
1996-12-06 21:19:37 +00:00
|
|
|
int length;
|
1996-11-25 19:52:08 +00:00
|
|
|
{
|
|
|
|
struct hash_entry *h;
|
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
h = &hash_table[hash(insn)];
|
1996-11-25 19:52:08 +00:00
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
while ((insn & h->mask) != h->opcode
|
|
|
|
|| (length != h->ops->length))
|
1996-11-25 19:52:08 +00:00
|
|
|
{
|
1997-05-06 19:27:22 +00:00
|
|
|
if (!h->next)
|
1996-11-25 19:52:08 +00:00
|
|
|
{
|
1997-05-06 19:27:22 +00:00
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback,
|
|
|
|
"ERROR looking up hash for 0x%x, PC=0x%x\n", insn, PC);
|
1996-11-25 19:52:08 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
h = h->next;
|
|
|
|
}
|
1997-05-06 19:27:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef HASH_STAT
|
|
|
|
h->count++;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Now call the right function. */
|
|
|
|
(h->ops->func)(insn, extension);
|
|
|
|
PC += length;
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_size (power)
|
|
|
|
int power;
|
|
|
|
|
|
|
|
{
|
|
|
|
if (State.mem)
|
|
|
|
free (State.mem);
|
|
|
|
|
1997-05-16 22:37:02 +00:00
|
|
|
max_mem = 1 << power;
|
1996-11-25 19:52:08 +00:00
|
|
|
State.mem = (uint8 *) calloc (1, 1 << power);
|
|
|
|
if (!State.mem)
|
|
|
|
{
|
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback, "Allocation of main memory failed.\n");
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_system ()
|
|
|
|
{
|
|
|
|
if (!State.mem)
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_size(19);
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_write (sd, addr, buffer, size)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
init_system ();
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++)
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
store_byte (addr + i, buffer[i]);
|
1996-11-25 19:52:08 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
1997-05-18 22:57:49 +00:00
|
|
|
/* Compare two opcode table entries for qsort. */
|
|
|
|
static int
|
|
|
|
compare_simops (arg1, arg2)
|
|
|
|
const PTR arg1;
|
|
|
|
const PTR arg2;
|
|
|
|
{
|
|
|
|
unsigned long code1 = ((struct simops *)arg1)->opcode;
|
|
|
|
unsigned long code2 = ((struct simops *)arg2)->opcode;
|
|
|
|
|
|
|
|
if (code1 < code2)
|
|
|
|
return -1;
|
|
|
|
if (code2 < code1)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-03-24 20:26:06 +00:00
|
|
|
|
1997-04-17 10:27:47 +00:00
|
|
|
SIM_DESC
|
1997-08-25 23:14:25 +00:00
|
|
|
sim_open (kind, cb, abfd, argv)
|
1997-04-17 10:27:47 +00:00
|
|
|
SIM_OPEN_KIND kind;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
host_callback *cb;
|
1997-08-25 23:14:25 +00:00
|
|
|
struct _bfd *abfd;
|
1997-04-17 10:27:47 +00:00
|
|
|
char **argv;
|
1996-11-25 19:52:08 +00:00
|
|
|
{
|
|
|
|
struct simops *s;
|
|
|
|
struct hash_entry *h;
|
1997-04-17 10:27:47 +00:00
|
|
|
char **p;
|
1997-05-18 22:57:49 +00:00
|
|
|
int i;
|
|
|
|
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
mn10300_callback = cb;
|
|
|
|
|
1997-05-18 22:57:49 +00:00
|
|
|
/* Sort the opcode array from smallest opcode to largest.
|
|
|
|
This will generally improve simulator performance as the smaller
|
|
|
|
opcodes are generally preferred to the larger opcodes. */
|
|
|
|
for (i = 0, s = Simops; s->func; s++, i++)
|
|
|
|
;
|
|
|
|
qsort (Simops, i, sizeof (Simops[0]), compare_simops);
|
1997-04-17 10:27:47 +00:00
|
|
|
|
|
|
|
sim_kind = kind;
|
|
|
|
myname = argv[0];
|
|
|
|
|
|
|
|
for (p = argv + 1; *p; ++p)
|
1996-11-25 19:52:08 +00:00
|
|
|
{
|
1997-04-17 10:27:47 +00:00
|
|
|
if (strcmp (*p, "-E") == 0)
|
|
|
|
++p; /* ignore endian spec */
|
|
|
|
else
|
1996-11-25 19:52:08 +00:00
|
|
|
#ifdef DEBUG
|
1997-04-17 10:27:47 +00:00
|
|
|
if (strcmp (*p, "-t") == 0)
|
1996-11-25 19:52:08 +00:00
|
|
|
mn10300_debug = DEBUG;
|
|
|
|
else
|
|
|
|
#endif
|
1997-04-17 10:27:47 +00:00
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback, "ERROR: unsupported option(s): %s\n",*p);
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
/* put all the opcodes in the hash table */
|
1996-11-25 19:52:08 +00:00
|
|
|
for (s = Simops; s->func; s++)
|
|
|
|
{
|
|
|
|
h = &hash_table[hash(s->opcode)];
|
1997-05-06 19:27:22 +00:00
|
|
|
|
1996-11-25 19:52:08 +00:00
|
|
|
/* go to the last entry in the chain */
|
|
|
|
while (h->next)
|
1997-05-06 19:27:22 +00:00
|
|
|
{
|
|
|
|
/* Don't insert the same opcode more than once. */
|
|
|
|
if (h->opcode == s->opcode
|
|
|
|
&& h->mask == s->mask
|
|
|
|
&& h->ops == s)
|
1997-08-25 23:14:25 +00:00
|
|
|
break;
|
1997-05-06 19:27:22 +00:00
|
|
|
else
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't insert the same opcode more than once. */
|
|
|
|
if (h->opcode == s->opcode
|
|
|
|
&& h->mask == s->mask
|
|
|
|
&& h->ops == s)
|
|
|
|
continue;
|
1996-11-25 19:52:08 +00:00
|
|
|
|
|
|
|
if (h->ops)
|
|
|
|
{
|
|
|
|
h->next = calloc(1,sizeof(struct hash_entry));
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
h->ops = s;
|
|
|
|
h->mask = s->mask;
|
|
|
|
h->opcode = s->opcode;
|
1997-05-06 19:27:22 +00:00
|
|
|
#if HASH_STAT
|
|
|
|
h->count = 0;
|
|
|
|
#endif
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
1997-04-17 10:27:47 +00:00
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
|
1997-04-17 10:27:47 +00:00
|
|
|
/* fudge our descriptor for now */
|
|
|
|
return (SIM_DESC) 1;
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_close (sd, quitting)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
int quitting;
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile (n)
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback, "sim_set_profile %d\n", n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_set_profile_size (n)
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback, "sim_set_profile_size %d\n", n);
|
|
|
|
}
|
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
int
|
|
|
|
sim_stop (sd)
|
|
|
|
SIM_DESC sd;
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1996-11-25 19:52:08 +00:00
|
|
|
void
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_resume (sd, step, siggnal)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
int step, siggnal;
|
|
|
|
{
|
1996-12-06 21:33:48 +00:00
|
|
|
uint32 inst;
|
1996-11-25 19:52:08 +00:00
|
|
|
reg_t oldpc;
|
1996-12-06 21:19:37 +00:00
|
|
|
struct hash_entry *h;
|
1996-11-25 19:52:08 +00:00
|
|
|
|
|
|
|
if (step)
|
|
|
|
State.exception = SIGTRAP;
|
|
|
|
else
|
|
|
|
State.exception = 0;
|
|
|
|
|
1997-08-25 23:14:25 +00:00
|
|
|
State.exited = 0;
|
|
|
|
|
1996-11-25 19:52:08 +00:00
|
|
|
do
|
|
|
|
{
|
1996-12-06 21:19:37 +00:00
|
|
|
unsigned long insn, extension;
|
|
|
|
|
1996-11-25 19:52:08 +00:00
|
|
|
/* Fetch the current instruction. */
|
1997-05-06 19:27:22 +00:00
|
|
|
inst = load_mem_big (PC, 2);
|
1996-11-25 19:52:08 +00:00
|
|
|
oldpc = PC;
|
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
/* Using a giant case statement may seem like a waste because of the
|
|
|
|
code/rodata size the table itself will consume. However, using
|
|
|
|
a giant case statement speeds up the simulator by 10-15% by avoiding
|
|
|
|
cascading if/else statements or cascading case statements. */
|
1996-12-06 21:19:37 +00:00
|
|
|
|
1997-05-06 19:27:22 +00:00
|
|
|
switch ((inst >> 8) & 0xff)
|
1996-12-06 21:19:37 +00:00
|
|
|
{
|
1997-05-06 19:27:22 +00:00
|
|
|
/* All the single byte insns except 0x80, 0x90, 0xa0, 0xb0
|
|
|
|
which must be handled specially. */
|
|
|
|
case 0x00:
|
|
|
|
case 0x04:
|
|
|
|
case 0x08:
|
|
|
|
case 0x0c:
|
1997-05-22 05:28:34 +00:00
|
|
|
case 0x10:
|
1997-05-06 19:27:22 +00:00
|
|
|
case 0x11:
|
|
|
|
case 0x12:
|
|
|
|
case 0x13:
|
|
|
|
case 0x14:
|
|
|
|
case 0x15:
|
|
|
|
case 0x16:
|
|
|
|
case 0x17:
|
|
|
|
case 0x18:
|
|
|
|
case 0x19:
|
|
|
|
case 0x1a:
|
|
|
|
case 0x1b:
|
|
|
|
case 0x1c:
|
|
|
|
case 0x1d:
|
|
|
|
case 0x1e:
|
|
|
|
case 0x1f:
|
|
|
|
case 0x3c:
|
|
|
|
case 0x3d:
|
|
|
|
case 0x3e:
|
|
|
|
case 0x3f:
|
|
|
|
case 0x40:
|
|
|
|
case 0x41:
|
|
|
|
case 0x44:
|
|
|
|
case 0x45:
|
|
|
|
case 0x48:
|
|
|
|
case 0x49:
|
|
|
|
case 0x4c:
|
|
|
|
case 0x4d:
|
|
|
|
case 0x50:
|
|
|
|
case 0x51:
|
|
|
|
case 0x52:
|
|
|
|
case 0x53:
|
|
|
|
case 0x54:
|
|
|
|
case 0x55:
|
|
|
|
case 0x56:
|
|
|
|
case 0x57:
|
|
|
|
case 0x60:
|
|
|
|
case 0x61:
|
|
|
|
case 0x62:
|
|
|
|
case 0x63:
|
|
|
|
case 0x64:
|
|
|
|
case 0x65:
|
|
|
|
case 0x66:
|
|
|
|
case 0x67:
|
|
|
|
case 0x68:
|
|
|
|
case 0x69:
|
|
|
|
case 0x6a:
|
|
|
|
case 0x6b:
|
|
|
|
case 0x6c:
|
|
|
|
case 0x6d:
|
|
|
|
case 0x6e:
|
|
|
|
case 0x6f:
|
|
|
|
case 0x70:
|
|
|
|
case 0x71:
|
|
|
|
case 0x72:
|
|
|
|
case 0x73:
|
|
|
|
case 0x74:
|
|
|
|
case 0x75:
|
|
|
|
case 0x76:
|
|
|
|
case 0x77:
|
|
|
|
case 0x78:
|
|
|
|
case 0x79:
|
|
|
|
case 0x7a:
|
|
|
|
case 0x7b:
|
|
|
|
case 0x7c:
|
|
|
|
case 0x7d:
|
|
|
|
case 0x7e:
|
|
|
|
case 0x7f:
|
|
|
|
case 0xcb:
|
|
|
|
case 0xd0:
|
|
|
|
case 0xd1:
|
|
|
|
case 0xd2:
|
|
|
|
case 0xd3:
|
|
|
|
case 0xd4:
|
|
|
|
case 0xd5:
|
|
|
|
case 0xd6:
|
|
|
|
case 0xd7:
|
|
|
|
case 0xd8:
|
|
|
|
case 0xd9:
|
|
|
|
case 0xda:
|
|
|
|
case 0xdb:
|
|
|
|
case 0xe0:
|
|
|
|
case 0xe1:
|
|
|
|
case 0xe2:
|
|
|
|
case 0xe3:
|
|
|
|
case 0xe4:
|
|
|
|
case 0xe5:
|
|
|
|
case 0xe6:
|
|
|
|
case 0xe7:
|
|
|
|
case 0xe8:
|
|
|
|
case 0xe9:
|
|
|
|
case 0xea:
|
|
|
|
case 0xeb:
|
|
|
|
case 0xec:
|
|
|
|
case 0xed:
|
|
|
|
case 0xee:
|
|
|
|
case 0xef:
|
|
|
|
case 0xff:
|
|
|
|
insn = (inst >> 8) & 0xff;
|
|
|
|
extension = 0;
|
|
|
|
dispatch (insn, extension, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Special cases where dm == dn is used to encode a different
|
|
|
|
instruction. */
|
|
|
|
case 0x80:
|
|
|
|
case 0x85:
|
|
|
|
case 0x8a:
|
|
|
|
case 0x8f:
|
|
|
|
case 0x90:
|
|
|
|
case 0x95:
|
|
|
|
case 0x9a:
|
|
|
|
case 0x9f:
|
|
|
|
case 0xa0:
|
|
|
|
case 0xa5:
|
|
|
|
case 0xaa:
|
|
|
|
case 0xaf:
|
|
|
|
case 0xb0:
|
|
|
|
case 0xb5:
|
|
|
|
case 0xba:
|
|
|
|
case 0xbf:
|
|
|
|
insn = inst;
|
|
|
|
extension = 0;
|
|
|
|
dispatch (insn, extension, 2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x81:
|
|
|
|
case 0x82:
|
|
|
|
case 0x83:
|
|
|
|
case 0x84:
|
|
|
|
case 0x86:
|
|
|
|
case 0x87:
|
|
|
|
case 0x88:
|
|
|
|
case 0x89:
|
|
|
|
case 0x8b:
|
|
|
|
case 0x8c:
|
|
|
|
case 0x8d:
|
|
|
|
case 0x8e:
|
|
|
|
case 0x91:
|
|
|
|
case 0x92:
|
|
|
|
case 0x93:
|
|
|
|
case 0x94:
|
|
|
|
case 0x96:
|
|
|
|
case 0x97:
|
|
|
|
case 0x98:
|
|
|
|
case 0x99:
|
|
|
|
case 0x9b:
|
|
|
|
case 0x9c:
|
|
|
|
case 0x9d:
|
|
|
|
case 0x9e:
|
|
|
|
case 0xa1:
|
|
|
|
case 0xa2:
|
|
|
|
case 0xa3:
|
|
|
|
case 0xa4:
|
|
|
|
case 0xa6:
|
|
|
|
case 0xa7:
|
|
|
|
case 0xa8:
|
|
|
|
case 0xa9:
|
|
|
|
case 0xab:
|
|
|
|
case 0xac:
|
|
|
|
case 0xad:
|
|
|
|
case 0xae:
|
|
|
|
case 0xb1:
|
|
|
|
case 0xb2:
|
|
|
|
case 0xb3:
|
|
|
|
case 0xb4:
|
|
|
|
case 0xb6:
|
|
|
|
case 0xb7:
|
|
|
|
case 0xb8:
|
|
|
|
case 0xb9:
|
|
|
|
case 0xbb:
|
|
|
|
case 0xbc:
|
|
|
|
case 0xbd:
|
|
|
|
case 0xbe:
|
|
|
|
insn = (inst >> 8) & 0xff;
|
|
|
|
extension = 0;
|
|
|
|
dispatch (insn, extension, 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* The two byte instructions. */
|
|
|
|
case 0x20:
|
|
|
|
case 0x21:
|
|
|
|
case 0x22:
|
|
|
|
case 0x23:
|
|
|
|
case 0x28:
|
|
|
|
case 0x29:
|
|
|
|
case 0x2a:
|
|
|
|
case 0x2b:
|
|
|
|
case 0x42:
|
|
|
|
case 0x43:
|
|
|
|
case 0x46:
|
|
|
|
case 0x47:
|
|
|
|
case 0x4a:
|
|
|
|
case 0x4b:
|
|
|
|
case 0x4e:
|
|
|
|
case 0x4f:
|
|
|
|
case 0x58:
|
|
|
|
case 0x59:
|
|
|
|
case 0x5a:
|
|
|
|
case 0x5b:
|
|
|
|
case 0x5c:
|
|
|
|
case 0x5d:
|
|
|
|
case 0x5e:
|
|
|
|
case 0x5f:
|
|
|
|
case 0xc0:
|
|
|
|
case 0xc1:
|
|
|
|
case 0xc2:
|
|
|
|
case 0xc3:
|
|
|
|
case 0xc4:
|
|
|
|
case 0xc5:
|
|
|
|
case 0xc6:
|
|
|
|
case 0xc7:
|
|
|
|
case 0xc8:
|
|
|
|
case 0xc9:
|
|
|
|
case 0xca:
|
|
|
|
case 0xce:
|
|
|
|
case 0xcf:
|
|
|
|
case 0xf0:
|
|
|
|
case 0xf1:
|
|
|
|
case 0xf2:
|
|
|
|
case 0xf3:
|
|
|
|
case 0xf4:
|
|
|
|
case 0xf5:
|
|
|
|
case 0xf6:
|
|
|
|
insn = inst;
|
|
|
|
extension = 0;
|
|
|
|
dispatch (insn, extension, 2);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* The three byte insns with a 16bit operand in little endian
|
|
|
|
format. */
|
|
|
|
case 0x01:
|
|
|
|
case 0x02:
|
|
|
|
case 0x03:
|
|
|
|
case 0x05:
|
|
|
|
case 0x06:
|
|
|
|
case 0x07:
|
|
|
|
case 0x09:
|
|
|
|
case 0x0a:
|
|
|
|
case 0x0b:
|
|
|
|
case 0x0d:
|
|
|
|
case 0x0e:
|
|
|
|
case 0x0f:
|
|
|
|
case 0x24:
|
|
|
|
case 0x25:
|
|
|
|
case 0x26:
|
|
|
|
case 0x27:
|
|
|
|
case 0x2c:
|
|
|
|
case 0x2d:
|
|
|
|
case 0x2e:
|
|
|
|
case 0x2f:
|
|
|
|
case 0x30:
|
|
|
|
case 0x31:
|
|
|
|
case 0x32:
|
|
|
|
case 0x33:
|
|
|
|
case 0x34:
|
|
|
|
case 0x35:
|
|
|
|
case 0x36:
|
|
|
|
case 0x37:
|
|
|
|
case 0x38:
|
|
|
|
case 0x39:
|
|
|
|
case 0x3a:
|
|
|
|
case 0x3b:
|
|
|
|
case 0xcc:
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn = load_byte (PC);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn <<= 16;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn |= load_half (PC + 1);
|
1997-05-06 19:27:22 +00:00
|
|
|
extension = 0;
|
|
|
|
dispatch (insn, extension, 3);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* The three byte insns without 16bit operand. */
|
|
|
|
case 0xde:
|
|
|
|
case 0xdf:
|
|
|
|
case 0xf8:
|
|
|
|
case 0xf9:
|
|
|
|
insn = load_mem_big (PC, 3);
|
|
|
|
extension = 0;
|
|
|
|
dispatch (insn, extension, 3);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Four byte insns. */
|
|
|
|
case 0xfa:
|
|
|
|
case 0xfb:
|
|
|
|
if ((inst & 0xfffc) == 0xfaf0
|
|
|
|
|| (inst & 0xfffc) == 0xfaf4
|
|
|
|
|| (inst & 0xfffc) == 0xfaf8)
|
|
|
|
insn = load_mem_big (PC, 4);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
insn = inst;
|
|
|
|
insn <<= 16;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn |= load_half (PC + 2);
|
1997-05-06 19:27:22 +00:00
|
|
|
extension = 0;
|
|
|
|
}
|
|
|
|
dispatch (insn, extension, 4);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Five byte insns. */
|
|
|
|
case 0xcd:
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn = load_byte (PC);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn <<= 24;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn |= (load_half (PC + 1) << 8);
|
|
|
|
insn |= load_byte (PC + 3);
|
|
|
|
extension = load_byte (PC + 4);
|
1997-05-06 19:27:22 +00:00
|
|
|
dispatch (insn, extension, 5);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xdc:
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn = load_byte (PC);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn <<= 24;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
extension = load_word (PC + 1);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn |= (extension & 0xffffff00) >> 8;
|
|
|
|
extension &= 0xff;
|
|
|
|
dispatch (insn, extension, 5);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Six byte insns. */
|
|
|
|
case 0xfc:
|
|
|
|
case 0xfd:
|
|
|
|
insn = (inst << 16);
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
extension = load_word (PC + 2);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn |= ((extension & 0xffff0000) >> 16);
|
|
|
|
extension &= 0xffff;
|
|
|
|
dispatch (insn, extension, 6);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xdd:
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
insn = load_byte (PC) << 24;
|
|
|
|
extension = load_word (PC + 1);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn |= ((extension >> 8) & 0xffffff);
|
|
|
|
extension = (extension & 0xff) << 16;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
extension |= load_byte (PC + 5) << 8;
|
|
|
|
extension |= load_byte (PC + 6);
|
1997-05-06 19:27:22 +00:00
|
|
|
dispatch (insn, extension, 7);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0xfe:
|
|
|
|
insn = inst << 16;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
extension = load_word (PC + 2);
|
1997-05-06 19:27:22 +00:00
|
|
|
insn |= ((extension >> 16) & 0xffff);
|
|
|
|
extension <<= 8;
|
|
|
|
extension &= 0xffff00;
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
extension |= load_byte (PC + 6);
|
1997-05-06 19:27:22 +00:00
|
|
|
dispatch (insn, extension, 7);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
abort ();
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!State.exception);
|
1997-05-06 19:27:22 +00:00
|
|
|
|
|
|
|
#ifdef HASH_STAT
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < MAX_HASH; i++)
|
|
|
|
{
|
|
|
|
struct hash_entry *h;
|
|
|
|
h = &hash_table[i];
|
|
|
|
|
|
|
|
printf("hash 0x%x:\n", i);
|
|
|
|
|
|
|
|
while (h)
|
|
|
|
{
|
|
|
|
printf("h->opcode = 0x%x, count = 0x%x\n", h->opcode, h->count);
|
|
|
|
h = h->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
}
|
|
|
|
fflush (stdout);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_trace (sd)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
mn10300_debug = DEBUG;
|
|
|
|
#endif
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_resume (sd, 0, 0);
|
1996-11-25 19:52:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_info (sd, verbose)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
int verbose;
|
|
|
|
{
|
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback, "sim_info\n");
|
|
|
|
}
|
|
|
|
|
1997-04-17 10:27:47 +00:00
|
|
|
SIM_RC
|
1998-03-24 20:26:06 +00:00
|
|
|
sim_create_inferior (sd, abfd, argv, env)
|
1997-04-17 10:27:47 +00:00
|
|
|
SIM_DESC sd;
|
1998-03-24 20:26:06 +00:00
|
|
|
struct _bfd *abfd;
|
1996-11-25 19:52:08 +00:00
|
|
|
char **argv;
|
|
|
|
char **env;
|
|
|
|
{
|
1998-03-24 20:26:06 +00:00
|
|
|
if (abfd != NULL)
|
|
|
|
PC = bfd_get_start_address (abfd);
|
|
|
|
else
|
|
|
|
PC = 0;
|
1997-04-17 10:27:47 +00:00
|
|
|
return SIM_RC_OK;
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
sim_set_callbacks (p)
|
1996-11-25 19:52:08 +00:00
|
|
|
host_callback *p;
|
|
|
|
{
|
|
|
|
mn10300_callback = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All the code for exiting, signals, etc needs to be revamped.
|
|
|
|
|
|
|
|
This is enough to get c-torture limping though. */
|
|
|
|
|
|
|
|
void
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_stop_reason (sd, reason, sigrc)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
enum sim_stop *reason;
|
|
|
|
int *sigrc;
|
|
|
|
{
|
1997-08-25 23:14:25 +00:00
|
|
|
if (State.exited)
|
|
|
|
*reason = sim_exited;
|
|
|
|
else
|
|
|
|
*reason = sim_stopped;
|
1996-11-25 19:52:08 +00:00
|
|
|
if (State.exception == SIGQUIT)
|
|
|
|
*sigrc = 0;
|
|
|
|
else
|
|
|
|
*sigrc = State.exception;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_read (sd, addr, buffer, size)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
SIM_ADDR addr;
|
|
|
|
unsigned char *buffer;
|
|
|
|
int size;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < size; i++)
|
* interp.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
(INLINE): Delete definition.
(load_mem_big): Likewise.
(max_mem): Make it global.
(dispatch): Make this function inline.
(load_mem, store_mem): Delete functions.
* mn10300_sim.h (INLINE): Define.
(RLW): Delete unused definition.
(load_mem, store_mem): Delete declarations.
(load_mem_big): New definition.
(load_byte, load_half, load_3_byte, load_word): New functions.
(store_byte, store_half, store_3_byte, store_word): New functions.
* simops.c: Replace all references to load_mem and store_mem
with references to load_byte, load_half, load_3_byte, load_word
and store_byte, store_half, store_3_byte, store_word.
1997-05-20 23:53:47 +00:00
|
|
|
buffer[i] = load_byte (addr + i);
|
1996-11-25 19:52:08 +00:00
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1997-04-17 10:27:47 +00:00
|
|
|
sim_do_command (sd, cmd)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
char *cmd;
|
|
|
|
{
|
|
|
|
(*mn10300_callback->printf_filtered) (mn10300_callback, "\"%s\" is not a valid mn10300 simulator command.\n", cmd);
|
|
|
|
}
|
|
|
|
|
1997-04-17 10:27:47 +00:00
|
|
|
SIM_RC
|
|
|
|
sim_load (sd, prog, abfd, from_tty)
|
|
|
|
SIM_DESC sd;
|
1996-11-25 19:52:08 +00:00
|
|
|
char *prog;
|
1997-04-17 10:27:47 +00:00
|
|
|
bfd *abfd;
|
1996-11-25 19:52:08 +00:00
|
|
|
int from_tty;
|
|
|
|
{
|
1997-04-17 10:27:47 +00:00
|
|
|
extern bfd *sim_load_file (); /* ??? Don't know where this should live. */
|
|
|
|
bfd *prog_bfd;
|
|
|
|
|
|
|
|
prog_bfd = sim_load_file (sd, myname, mn10300_callback, prog, abfd,
|
1998-03-24 20:26:06 +00:00
|
|
|
sim_kind == SIM_OPEN_DEBUG,
|
|
|
|
0, sim_write);
|
1997-04-17 10:27:47 +00:00
|
|
|
if (prog_bfd == NULL)
|
|
|
|
return SIM_RC_FAIL;
|
|
|
|
if (abfd == NULL)
|
|
|
|
bfd_close (prog_bfd);
|
|
|
|
return SIM_RC_OK;
|
1996-11-25 19:52:08 +00:00
|
|
|
}
|
1998-03-24 20:26:06 +00:00
|
|
|
#endif /* not WITH_COMMON */
|
|
|
|
|
|
|
|
|
|
|
|
#if WITH_COMMON
|
|
|
|
|
|
|
|
/* For compatibility */
|
|
|
|
SIM_DESC simulator;
|
1998-03-27 03:10:53 +00:00
|
|
|
/* start-sanitize-am30 */
|
|
|
|
/* Until the tree root gets moved somewhere else */
|
|
|
|
struct hw *hw;
|
|
|
|
/* end-sanitize-am30 */
|
1998-03-24 20:26:06 +00:00
|
|
|
|
|
|
|
/* These default values correspond to expected usage for the chip. */
|
|
|
|
|
|
|
|
SIM_DESC
|
|
|
|
sim_open (kind, cb, abfd, argv)
|
|
|
|
SIM_OPEN_KIND kind;
|
|
|
|
host_callback *cb;
|
|
|
|
struct _bfd *abfd;
|
|
|
|
char **argv;
|
|
|
|
{
|
|
|
|
SIM_DESC sd = sim_state_alloc (kind, cb);
|
|
|
|
mn10300_callback = cb;
|
|
|
|
|
|
|
|
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
|
|
|
|
|
|
|
|
/* for compatibility */
|
|
|
|
simulator = sd;
|
|
|
|
|
1998-03-25 04:15:38 +00:00
|
|
|
/* FIXME: should be better way of setting up interrupts. For
|
|
|
|
moment, only support watchpoints causing a breakpoint (gdb
|
|
|
|
halt). */
|
1998-03-24 20:26:06 +00:00
|
|
|
STATE_WATCHPOINTS (sd)->pc = &(PC);
|
|
|
|
STATE_WATCHPOINTS (sd)->sizeof_pc = sizeof (PC);
|
1998-03-25 04:15:38 +00:00
|
|
|
STATE_WATCHPOINTS (sd)->interrupt_handler = NULL;
|
|
|
|
STATE_WATCHPOINTS (sd)->interrupt_names = NULL;
|
1998-03-24 20:26:06 +00:00
|
|
|
|
|
|
|
if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Allocate core managed memory */
|
|
|
|
sim_do_command (sd, "memory region 0,0x100000");
|
1998-03-25 04:15:38 +00:00
|
|
|
sim_do_command (sd, "memory region 0x40000000,0x100000");
|
1998-03-24 20:26:06 +00:00
|
|
|
|
|
|
|
/* getopt will print the error message so we just have to exit if this fails.
|
|
|
|
FIXME: Hmmm... in the case of gdb we need getopt to call
|
|
|
|
print_filtered. */
|
|
|
|
if (sim_parse_args (sd, argv) != SIM_RC_OK)
|
|
|
|
{
|
|
|
|
/* Uninstall the modules to avoid memory leaks,
|
|
|
|
file descriptor leaks, etc. */
|
|
|
|
sim_module_uninstall (sd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* start-sanitize-am30 */
|
1998-03-25 04:15:38 +00:00
|
|
|
hw = hw_tree_create (sd, "core");
|
|
|
|
hw_tree_parse (hw, "/");
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/trace? true");
|
|
|
|
|
|
|
|
|
|
|
|
/* interrupt controller */
|
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
hw_tree_parse (hw, "/mn103int@0x34000100/reg 0x34000100 0x68 0x34000200 0x8 0x3400280 0x8");
|
1998-03-25 04:15:38 +00:00
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/mn103int/trace? true");
|
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* DEBUG: NMI input's */
|
|
|
|
hw_tree_parse (hw, "/glue@0x30000000/reg 0x30000000 12");
|
1998-03-25 04:15:38 +00:00
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x30000000/trace? true");
|
1998-03-27 03:10:53 +00:00
|
|
|
hw_tree_parse (hw, "/glue@0x30000000 > int0 nmirq /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30000000 > int1 watchdog /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30000000 > int2 syserr /mn103int");
|
1998-03-25 04:15:38 +00:00
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* DEBUG: ACK input */
|
|
|
|
hw_tree_parse (hw, "/glue@0x30002000/reg 0x30002000 4");
|
1998-03-25 04:15:38 +00:00
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x30002000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30002000 > int ack /mn103int");
|
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* DEBUG: LEVEL output */
|
|
|
|
hw_tree_parse (hw, "/glue@0x30004000/reg 0x30004000 8");
|
1998-03-25 04:15:38 +00:00
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x30004000/trace? true");
|
1998-03-27 03:10:53 +00:00
|
|
|
hw_tree_parse (hw, "/mn103int > nmi int0 /glue@0x30004000");
|
|
|
|
hw_tree_parse (hw, "/mn103int > level int1 /glue@0x30004000");
|
1998-03-25 04:15:38 +00:00
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* DEBUG: A bunch of interrupt inputs */
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000/reg 0x30006000 32");
|
1998-03-25 04:15:38 +00:00
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int0 irq-0 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int1 irq-1 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int2 irq-2 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int3 irq-3 /mn103int");
|
1998-03-27 03:10:53 +00:00
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int4 irq-4 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int5 irq-5 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int6 irq-6 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/glue@0x30006000 > int7 irq-7 /mn103int");
|
1998-03-25 04:15:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* processor interrupt device */
|
|
|
|
|
|
|
|
/* the device */
|
|
|
|
hw_tree_parse (hw, "/mn103cpu@0x20000000");
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/mn103cpu@0x20000000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/mn103cpu@0x20000000/reg 0x20000000 0x42");
|
|
|
|
|
|
|
|
/* DEBUG: ACK output wired upto a glue device */
|
|
|
|
hw_tree_parse (hw, "/glue@0x20002000");
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x20002000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/glue@0x20002000/reg 0x20002000 4");
|
|
|
|
hw_tree_parse (hw, "/mn103cpu > ack int0 /glue@0x20002000");
|
|
|
|
|
|
|
|
/* DEBUG: RESET/NMI/LEVEL wired up to a glue device */
|
|
|
|
hw_tree_parse (hw, "/glue@0x20004000");
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x20004000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/glue@0x20004000/reg 0x20004000 12");
|
|
|
|
hw_tree_parse (hw, "/glue@0x20004000 > int0 reset /mn103cpu");
|
|
|
|
hw_tree_parse (hw, "/glue@0x20004000 > int1 nmi /mn103cpu");
|
|
|
|
hw_tree_parse (hw, "/glue@0x20004000 > int2 level /mn103cpu");
|
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* REAL: The processor wired up to the real interrupt controller */
|
|
|
|
#if 1
|
1998-03-25 04:15:38 +00:00
|
|
|
hw_tree_parse (hw, "/mn103cpu > ack ack /mn103int");
|
|
|
|
hw_tree_parse (hw, "/mn103int > level level /mn103cpu");
|
|
|
|
hw_tree_parse (hw, "/mn103int > nmi nmi /mn103cpu");
|
1998-03-27 03:10:53 +00:00
|
|
|
#endif
|
1998-03-25 04:15:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* PAL */
|
|
|
|
|
|
|
|
/* the device */
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000");
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000/reg 0x31000000 64");
|
|
|
|
|
|
|
|
/* DEBUG: PAL wired up to a glue device */
|
|
|
|
hw_tree_parse (hw, "/glue@0x31002000");
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_parse (hw, "/glue@0x31002000/trace? true");
|
|
|
|
hw_tree_parse (hw, "/glue@0x31002000/reg 0x31002000 16");
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000 > countdown int0 /glue@0x31002000");
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000 > timer int1 /glue@0x31002000");
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000 > int int2 /glue@0x31002000");
|
|
|
|
hw_tree_parse (hw, "/glue@0x31002000 > int0 int3 /glue@0x31002000");
|
|
|
|
hw_tree_parse (hw, "/glue@0x31002000 > int1 int3 /glue@0x31002000");
|
|
|
|
hw_tree_parse (hw, "/glue@0x31002000 > int2 int3 /glue@0x31002000");
|
|
|
|
|
1998-03-27 03:10:53 +00:00
|
|
|
/* REAL: The PAL wired up to the real interrupt controller */
|
1998-03-25 04:15:38 +00:00
|
|
|
hw_tree_parse (hw, "/pal@0x31000000 > countdown irq-0 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000 > timer irq-1 /mn103int");
|
|
|
|
hw_tree_parse (hw, "/pal@0x31000000 > int irq-2 /mn103int");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hw_tree_finish (hw);
|
|
|
|
if (STATE_VERBOSE_P (sd))
|
|
|
|
hw_tree_print (hw);
|
1998-03-27 03:10:53 +00:00
|
|
|
/* end-sanitize-am30 */
|
1998-03-25 04:15:38 +00:00
|
|
|
|
1998-03-24 20:26:06 +00:00
|
|
|
/* check for/establish the a reference program image */
|
|
|
|
if (sim_analyze_program (sd,
|
|
|
|
(STATE_PROG_ARGV (sd) != NULL
|
|
|
|
? *STATE_PROG_ARGV (sd)
|
|
|
|
: NULL),
|
|
|
|
abfd) != SIM_RC_OK)
|
|
|
|
{
|
|
|
|
sim_module_uninstall (sd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* establish any remaining configuration options */
|
|
|
|
if (sim_config (sd) != SIM_RC_OK)
|
|
|
|
{
|
|
|
|
sim_module_uninstall (sd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sim_post_argv_init (sd) != SIM_RC_OK)
|
|
|
|
{
|
|
|
|
/* Uninstall the modules to avoid memory leaks,
|
|
|
|
file descriptor leaks, etc. */
|
|
|
|
sim_module_uninstall (sd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* set machine specific configuration */
|
|
|
|
/* STATE_CPU (sd, 0)->psw_mask = (PSW_NP | PSW_EP | PSW_ID | PSW_SAT */
|
|
|
|
/* | PSW_CY | PSW_OV | PSW_S | PSW_Z); */
|
|
|
|
|
|
|
|
return sd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_close (sd, quitting)
|
|
|
|
SIM_DESC sd;
|
|
|
|
int quitting;
|
|
|
|
{
|
|
|
|
sim_module_uninstall (sd);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SIM_RC
|
|
|
|
sim_create_inferior (sd, prog_bfd, argv, env)
|
|
|
|
SIM_DESC sd;
|
|
|
|
struct _bfd *prog_bfd;
|
|
|
|
char **argv;
|
|
|
|
char **env;
|
|
|
|
{
|
|
|
|
memset (&State, 0, sizeof (State));
|
|
|
|
if (prog_bfd != NULL) {
|
|
|
|
PC = bfd_get_start_address (prog_bfd);
|
|
|
|
} else {
|
|
|
|
PC = 0;
|
|
|
|
}
|
|
|
|
CIA_SET (STATE_CPU (sd, 0), (unsigned64) PC);
|
|
|
|
|
|
|
|
return SIM_RC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sim_do_command (sd, cmd)
|
|
|
|
SIM_DESC sd;
|
|
|
|
char *cmd;
|
|
|
|
{
|
|
|
|
char *mm_cmd = "memory-map";
|
|
|
|
char *int_cmd = "interrupt";
|
|
|
|
|
|
|
|
if (sim_args_command (sd, cmd) != SIM_RC_OK)
|
|
|
|
{
|
|
|
|
if (strncmp (cmd, mm_cmd, strlen (mm_cmd) == 0))
|
|
|
|
sim_io_eprintf (sd, "`memory-map' command replaced by `sim memory'\n");
|
|
|
|
else if (strncmp (cmd, int_cmd, strlen (int_cmd)) == 0)
|
|
|
|
sim_io_eprintf (sd, "`interrupt' command replaced by `sim watch'\n");
|
|
|
|
else
|
|
|
|
sim_io_eprintf (sd, "Unknown command `%s'\n", cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* WITH_COMMON */
|
|
|
|
|
|
|
|
/* FIXME These would more efficient to use than load_mem/store_mem,
|
|
|
|
but need to be changed to use the memory map. */
|
|
|
|
|
|
|
|
uint8
|
|
|
|
get_byte (x)
|
|
|
|
uint8 *x;
|
|
|
|
{
|
|
|
|
return *x;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16
|
|
|
|
get_half (x)
|
|
|
|
uint8 *x;
|
|
|
|
{
|
|
|
|
uint8 *a = x;
|
|
|
|
return (a[1] << 8) + (a[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32
|
|
|
|
get_word (x)
|
|
|
|
uint8 *x;
|
|
|
|
{
|
|
|
|
uint8 *a = x;
|
|
|
|
return (a[3]<<24) + (a[2]<<16) + (a[1]<<8) + (a[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
put_byte (addr, data)
|
|
|
|
uint8 *addr;
|
|
|
|
uint8 data;
|
|
|
|
{
|
|
|
|
uint8 *a = addr;
|
|
|
|
a[0] = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
put_half (addr, data)
|
|
|
|
uint8 *addr;
|
|
|
|
uint16 data;
|
|
|
|
{
|
|
|
|
uint8 *a = addr;
|
|
|
|
a[0] = data & 0xff;
|
|
|
|
a[1] = (data >> 8) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
put_word (addr, data)
|
|
|
|
uint8 *addr;
|
|
|
|
uint32 data;
|
|
|
|
{
|
|
|
|
uint8 *a = addr;
|
|
|
|
a[0] = data & 0xff;
|
|
|
|
a[1] = (data >> 8) & 0xff;
|
|
|
|
a[2] = (data >> 16) & 0xff;
|
|
|
|
a[3] = (data >> 24) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_fetch_register (sd, rn, memory, length)
|
|
|
|
SIM_DESC sd;
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
int length;
|
|
|
|
{
|
|
|
|
put_word (memory, State.regs[rn]);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sim_store_register (sd, rn, memory, length)
|
|
|
|
SIM_DESC sd;
|
|
|
|
int rn;
|
|
|
|
unsigned char *memory;
|
|
|
|
int length;
|
|
|
|
{
|
|
|
|
State.regs[rn] = get_word (memory);
|
|
|
|
return -1;
|
|
|
|
}
|