home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / sim / h8300 / run.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-12  |  1.5 KB  |  79 lines

  1. /* front end to the simulator.
  2.  
  3.    Written by Steve Chamberlain of Cygnus Support.
  4.    sac@cygnus.com
  5.  
  6.    This file is part of H8/300 sim
  7.  
  8.  
  9.         THIS SOFTWARE IS NOT COPYRIGHTED
  10.  
  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.
  14.  
  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. */
  20.  
  21. #include "bfd.h"
  22. #include "sysdep.h"
  23.  
  24. int
  25. main(ac,av)
  26. int ac;
  27. char **av;
  28. {
  29.   bfd *abfd;
  30.   bfd_vma start_address;
  31.   asection *s;
  32.   int i;
  33.   int verbose = 0;
  34.   int trace = 0;
  35.   char *name = "";
  36.   for (i = 1; i < ac; i++)
  37.   {
  38.     if (strcmp(av[i],"-v") == 0) 
  39.     {
  40.       verbose = 1;
  41.     }
  42.     else if (strcmp(av[i],"-t") == 0) 
  43.     {
  44.       trace = 1;
  45.     }
  46.  
  47.     else 
  48.     {
  49.       name = av[i];
  50.     }
  51.   }
  52.   if (verbose)
  53.   {
  54.     printf("run %s\n", name);
  55.   }
  56.   abfd = bfd_openr(name,"coff-h8300");
  57.   if (abfd) {
  58.       
  59.     if (bfd_check_format(abfd, bfd_object)) 
  60.     {
  61.  
  62.       for (s = abfd->sections; s; s=s->next) 
  63.       {
  64.     char *buffer = malloc(bfd_section_size(abfd,s));
  65.     bfd_get_section_contents(abfd, s, buffer, 0, bfd_section_size(abfd,s));
  66.     sim_write(s->vma, buffer, bfd_section_size(abfd,s));
  67.       }
  68.  
  69.       start_address = bfd_get_start_address(abfd);
  70.       sim_store_register(
  71.              9,start_address);
  72.       sim_resume(0,0);
  73.       return 0;
  74.     }
  75.   }
  76.  
  77.   return 1;
  78. }
  79.