* h8300.mt: Removed.
[deliverable/binutils-gdb.git] / sim / h8300 / run.c
CommitLineData
ea6bbfba 1/* front end to the simulator.
a154eea7 2
ea6bbfba
SC
3 Written by Steve Chamberlain of Cygnus Support.
4 sac@cygnus.com
a154eea7 5
ea6bbfba 6 This file is part of H8/300 sim
a154eea7 7
a154eea7 8
ea6bbfba 9 THIS SOFTWARE IS NOT COPYRIGHTED
a154eea7 10
ea6bbfba
SC
11 Cygnus offers the following for use in the public domain. Cygnus
12 makes no warranty with regard to the software or it's performance
13 and the user accepts the software "AS IS" with all faults.
a154eea7 14
ea6bbfba
SC
15 CYGNUS DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD TO
16 THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18
19*/
a154eea7 20
3a1d485d 21#include <varargs.h>
a415cf0a 22#include <stdio.h>
a154eea7
SC
23#include "bfd.h"
24#include "sysdep.h"
3a1d485d 25#include "remote-sim.h"
a154eea7 26
057af5c9
C
27void usage();
28extern int optind;
29extern char *optarg;
30
a154eea7 31int
1cec8dae
SC
32main (ac, av)
33 int ac;
34 char **av;
a154eea7
SC
35{
36 bfd *abfd;
37 bfd_vma start_address;
38 asection *s;
39 int i;
40 int verbose = 0;
41 int trace = 0;
42 char *name = "";
3a1d485d 43
057af5c9
C
44 while ((i = getopt (ac, av, "c:htv")) != EOF)
45 switch (i)
46 {
47 case 'c':
48 sim_csize (atoi (optarg));
49 break;
50 case 'h':
3a1d485d 51 set_h8300h (1);
057af5c9
C
52 break;
53 case 't':
54 trace = 1;
55 break;
56 case 'v':
57 verbose = 1;
58 break;
59 default:
60 usage();
61 }
62 ac -= optind;
63 av += optind;
64
65 if (ac != 1)
66 usage();
67
68 name = *av;
7ecaa5af 69
1835992e
DE
70 if (verbose)
71 printf ("run %s\n", name);
ce38539a 72
cf5b4aa6
DE
73 abfd = bfd_openr (name, "coff-h8300");
74 if (abfd)
75 {
76 if (bfd_check_format(abfd, bfd_object))
ce38539a 77 {
cf5b4aa6 78 if (abfd->arch_info->mach == bfd_mach_h8300h)
3a1d485d 79 set_h8300h (1);
ce38539a 80
cf5b4aa6
DE
81 for (s = abfd->sections; s; s=s->next)
82 {
83 char *buffer = malloc(bfd_section_size(abfd,s));
84 bfd_get_section_contents(abfd, s, buffer, 0, bfd_section_size(abfd,s));
85 sim_write(s->vma, buffer, bfd_section_size(abfd,s));
ce38539a 86 }
cf5b4aa6
DE
87
88 start_address = bfd_get_start_address(abfd);
3a1d485d 89 sim_create_inferior (start_address, NULL, NULL);
cf5b4aa6
DE
90 sim_resume(0,0);
91 if (verbose)
3a1d485d 92 sim_info (verbose - 1);
cf5b4aa6 93 return 0;
1cec8dae 94 }
cf5b4aa6 95 }
a154eea7
SC
96
97 return 1;
98}
3a1d485d
DE
99
100void
101printf_filtered (va_alist)
102 va_dcl
103{
104 char *msg;
105 va_list args;
106
107 va_start (args);
108 msg = va_arg (args, char *);
109 vfprintf (stdout, msg, args);
110 va_end (args);
111}
057af5c9
C
112
113void
114usage()
115{
116 fprintf (stderr, "usage: run [-tv] program\n");
117 exit (1);
118}
This page took 0.125625 seconds and 4 git commands to generate.