File: cmd_load.cc

package info (click to toggle)
gpsim 0.20.14-7.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,932 kB
  • ctags: 5,975
  • sloc: cpp: 25,431; ansic: 12,617; sh: 8,774; asm: 3,735; yacc: 678; lex: 432; makefile: 304
file content (115 lines) | stat: -rw-r--r-- 2,710 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
   Copyright (C) 1999 T. Scott Dattalo

This file is part of gpsim.

gpsim 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.

gpsim 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 gpsim; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */


#include <iostream>
#include <iomanip>
#include <string>

#include "command.h"
#include "cmd_load.h"

#include "../src/pic-processor.h"

using namespace std;

extern int parser_warnings;

// instead of including the whole symbol.h file, just get what we need:
int load_symbol_file(pic_processor **, char *);
void display_symbol_file_error(int);

cmd_load c_load;

static cmd_options cmd_load_options[] =
{
  "h",1,    OPT_TT_BITFLAG,
  "c",2,    OPT_TT_BITFLAG,
  "s",3,    OPT_TT_BITFLAG,
  NULL,0,0
};


cmd_load::cmd_load(void)
{ 
  name = "load";

  brief_doc = string("Load either a hex,command, or .cod file");

  long_doc = string ("load  h | c | s  file_name\
\n\n\tload either a hex file, command file, or a symbol file.\
\n\t(Byte Craft's .cod files are the only symbol files that\
\n\tare recognized.)\
\n\n\tExample:\
\n\t  load s perfect_program.cod\
\n\t    will load the symbol file perfect_program.cod\
\n\t    note that the .cod file contains the hex stuff\
\n");

  op = cmd_load_options; 
}

//--------------------
//
//
#define MAX_LINE_LENGTH 256  
int parse_string(char *cmd_string);
extern void process_command_file(char * file_name);

void cmd_load::load(int bit_flag,char *filename)
{
  //int verbose_save;
  switch(bit_flag)
    {
    case 1:
      if(have_cpu(1))
	{
	  if(verbose)
	    cout << "cmd_load::load hex file " << filename << '\n';
	  cpu->load_hex(filename);
	}
      else
	cout << " No cpu has been selected\n";
      break;

    case 2:
      /* Don't display parser warnings will processing the command file */
      parser_warnings = 0;
      process_command_file(filename);
      parser_warnings = 1;
      break;
    case 3:
      if(verbose)
	cout << " cmd_load::load cod file "  << filename << '\n';

      int i=load_symbol_file(&cpu, filename);

      if(i)
	{
	  cout << "found a fatal error in the symbol file " << filename <<'\n';
	  display_symbol_file_error(i);
	}
      else
	new_processor(cpu);

      break;
    }
}