#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
#include "wait.h"
#include "ansidecl.h"
#include "bfd.h"
#include "callback.h"
#include "remote-sim.h"
+#ifndef SIGTRAP
+# define SIGTRAP 5
+#endif
+
int debug;
host_callback *sim_callback;
goto next;
case O (O_SYSCALL, SB):
- printf ("%c", cpu.regs[2]);
+ {
+ char c = cpu.regs[2];
+ sim_callback->write_stdout (sim_callback, &c, 1);
+ }
goto next;
ONOT (O_NOT, rd = ~rd; v = 0;);
;
/* if (cpu.regs[8] ) abort(); */
- if (poll_count++ > 100)
+ if (--poll_count < 0)
{
- poll_count = 0;
+ poll_count = 100;
if ((*sim_callback->poll_quit) != NULL
&& (*sim_callback->poll_quit) (sim_callback))
sim_stop (sd);
set_h8300h (flag)
int flag;
{
+ /* FIXME: Much of the code in sim_load can be moved to sim_open.
+ This function being replaced by a sim_open:ARGV configuration
+ option */
h8300hmode = flag;
}
struct _bfd *abfd;
char **argv;
{
+ /* FIXME: Much of the code in sim_load can be moved here */
+
sim_kind = kind;
myname = argv[0];
sim_callback = ptr;
{
bfd *prog_bfd;
+ /* FIXME: The code below that sets a specific variant of the h8/300
+ being simulated should be moved to sim_open(). */
+
/* See if the file is for the h8/300 or h8/300h. */
/* ??? This may not be the most efficient way. The z8k simulator
does this via a different mechanism (INIT_EXTRA_SYMTAB_INFO). */
cpu.mask = memory_size - 1;
if (sim_load_file (sd, myname, sim_callback, prog, prog_bfd,
- sim_kind == SIM_OPEN_DEBUG)
+ sim_kind == SIM_OPEN_DEBUG,
+ 0, sim_write)
== NULL)
{
/* Close the bfd if we opened it. */
return SIM_RC_FAIL;
}
- cpu.pc = bfd_get_start_address (prog_bfd);
/* Close the bfd if we opened it. */
if (abfd == NULL && prog_bfd != NULL)
bfd_close (prog_bfd);
}
SIM_RC
-sim_create_inferior (sd, argv, env)
+sim_create_inferior (sd, abfd, argv, env)
SIM_DESC sd;
+ struct _bfd *abfd;
char **argv;
char **env;
{
+ if (abfd != NULL)
+ cpu.pc = bfd_get_start_address (abfd);
+ else
+ cpu.pc = 0;
return SIM_RC_OK;
}