* interp.c (BUSERROR): New macro.
[deliverable/binutils-gdb.git] / sim / sh / run.c
1 /* run front end support for H8/500
2 Copyright (C) 1987, 1992 Free Software Foundation, Inc.
3
4 This file is part of H8300 SIM
5
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21 /* Steve Chamberlain
22 sac@cygnus.com */
23
24 #include <stdio.h>
25 #include <varargs.h>
26 #include "bfd.h"
27 #include "sysdep.h"
28 #include "remote-sim.h"
29
30 int target_byte_order;
31
32 int
33 main (ac, av)
34 int ac;
35 char **av;
36 {
37 bfd *abfd;
38 bfd_vma start_address;
39 asection *s;
40 int i;
41 int verbose = 0;
42 int trace = 0;
43 char *name = "";
44
45 for (i = 1; i < ac; i++)
46 {
47 if (strcmp (av[i], "-v") == 0)
48 {
49 verbose = 1;
50 }
51 else if (strcmp (av[i], "-t") == 0)
52 {
53 trace = 1;
54 }
55 else if (strcmp (av[i], "-p") == 0)
56 {
57 sim_set_profile (atoi (av[i + 1]));
58 i++;
59 }
60 else if (strcmp (av[i], "-s") == 0)
61 {
62 sim_set_profile_size (atoi (av[i + 1]));
63 i++;
64 }
65 else if (strcmp (av[i], "-m") == 0)
66 {
67 sim_size (atoi (av[i + 1]));
68 i++;
69 }
70 else
71 {
72 name = av[i];
73 }
74 }
75 if (verbose)
76 {
77 printf ("run %s\n", name);
78 }
79 abfd = bfd_openr (name, 0);
80 if (abfd)
81 {
82 if (bfd_check_format (abfd, bfd_object))
83 {
84
85 for (s = abfd->sections; s; s = s->next)
86 {
87 unsigned char *buffer = malloc (bfd_section_size (abfd, s));
88 bfd_get_section_contents (abfd,
89 s,
90 buffer,
91 0,
92 bfd_section_size (abfd, s));
93 sim_write (s->vma, buffer, bfd_section_size (abfd, s));
94 }
95
96 start_address = bfd_get_start_address (abfd);
97 sim_create_inferior (start_address, NULL, NULL);
98
99 target_byte_order = abfd->xvec->byteorder_big_p ? 4321 : 1234;
100
101 if (trace)
102 {
103 int done = 0;
104 while (!done)
105 {
106 done = sim_trace ();
107 }
108 }
109 else
110 {
111 sim_resume (0, 0);
112 }
113 if (verbose)
114 sim_info (0);
115
116 /* Assume we left through the exit system call,
117 in which case r5 has the exit code */
118 {
119 unsigned char b[4];
120 sim_fetch_register (5, b);
121 return b[3];
122 }
123
124 }
125 }
126
127 return 1;
128 }
129 \f
130 /* Callbacks used by the simulator proper. */
131
132 void
133 printf_filtered (va_alist)
134 va_dcl
135 {
136 va_list args;
137 char *format;
138
139 va_start (args);
140 format = va_arg (args, char *);
141
142 vfprintf (stdout, format, args);
143 va_end (args);
144 }
This page took 0.032252 seconds and 5 git commands to generate.