aboutsummaryrefslogtreecommitdiff
path: root/sim/w65/run.c
diff options
context:
space:
mode:
authorSteve Chamberlain <sac@cygnus>1995-01-16 00:53:05 +0000
committerSteve Chamberlain <sac@cygnus>1995-01-16 00:53:05 +0000
commit321a78a5a059e2769166ccbb3de8233dfb0d33dc (patch)
treeac5e3410c3edb1161fffd7709a2699d16c199b26 /sim/w65/run.c
parent506f4ede9c1e5ae444a496854fdec7db869a2f53 (diff)
downloadgdb-321a78a5a059e2769166ccbb3de8233dfb0d33dc.zip
gdb-321a78a5a059e2769166ccbb3de8233dfb0d33dc.tar.gz
gdb-321a78a5a059e2769166ccbb3de8233dfb0d33dc.tar.bz2
New files.
Diffstat (limited to 'sim/w65/run.c')
-rw-r--r--sim/w65/run.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/sim/w65/run.c b/sim/w65/run.c
new file mode 100644
index 0000000..da81dd2
--- /dev/null
+++ b/sim/w65/run.c
@@ -0,0 +1,109 @@
+/* run front end support for W65
+ Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of W65 SIM
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+
+/* Steve Chamberlain
+ sac@cygnus.com */
+
+#include <stdio.h>
+#include "bfd.h"
+#include "sysdep.h"
+
+extern printf();
+
+int
+main (ac, av)
+ int ac;
+ char **av;
+{
+ bfd *abfd;
+ bfd_vma start_address;
+ asection *s;
+ int i;
+ int verbose = 0;
+ int trace = 0;
+ char *name = "";
+
+ for (i = 1; i < ac; i++)
+ {
+ if (strcmp (av[i], "-v") == 0)
+ {
+ verbose = 1;
+ }
+ else if (strcmp (av[i], "-t") == 0)
+ {
+ trace = 1;
+ }
+ else
+ {
+ name = av[i];
+ }
+ }
+ if (verbose)
+ {
+ printf ("run %s\n", name);
+ }
+ abfd = bfd_openr (name, "coff-w65");
+ if (abfd)
+ {
+
+ if (bfd_check_format (abfd, bfd_object))
+ {
+
+ for (s = abfd->sections; s; s = s->next)
+ {
+ unsigned char *buffer = malloc (bfd_section_size (abfd, s));
+ bfd_get_section_contents (abfd,
+ s,
+ buffer,
+ 0,
+ bfd_section_size (abfd, s));
+ sim_write (s->vma, buffer, bfd_section_size (abfd, s));
+ free (buffer);
+ }
+
+ start_address = bfd_get_start_address (abfd);
+ sim_set_pc (start_address);
+ if (trace)
+ {
+ int done = 0;
+ while (!done)
+ {
+ done = sim_trace ();
+ }
+ }
+ else
+ {
+ sim_resume (0, 0);
+ }
+ if (verbose)
+ sim_info (printf, 0);
+
+ /* Find out what was in r0 and return that */
+ {
+ unsigned char b[4];
+ sim_fetch_register(0, b);
+ return b[3];
+ }
+
+ }
+ }
+
+ return 1;
+}