This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / sim / h8300 / compile.c
index 370fe4605b331bf8be94af6f426a5516400a813f..12f9d2910cdba8b0b03911ec5319d3f76e9c37fe 100644 (file)
 #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;
@@ -1269,7 +1275,10 @@ sim_resume (sd, step, siggnal)
          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;);
@@ -1714,9 +1723,9 @@ sim_resume (sd, step, siggnal)
       ;
       /*      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);
@@ -2009,6 +2018,9 @@ void
 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;
 }
 
@@ -2019,6 +2031,8 @@ sim_open (kind, ptr, abfd, argv)
      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;
@@ -2045,6 +2059,9 @@ sim_load (sd, prog, abfd, from_tty)
 {
   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).  */
@@ -2100,7 +2117,8 @@ sim_load (sd, prog, abfd, from_tty)
   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.  */
@@ -2109,7 +2127,6 @@ sim_load (sd, prog, abfd, from_tty)
       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);
@@ -2117,11 +2134,16 @@ sim_load (sd, prog, abfd, from_tty)
 }
 
 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;
 }
 
This page took 0.024569 seconds and 4 git commands to generate.