srecord  1.65.0
asm.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2003, 2006-2008, 2010 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see
17 // <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef SRECORD_OUTPUT_FILE_ASM_H
21 #define SRECORD_OUTPUT_FILE_ASM_H
22 
23 #include <srecord/output/file.h>
24 #include <srecord/interval.h>
25 
26 namespace srecord
27 {
28 
29 /**
30  * The srecord::output_file_asm class is used to represent an output file
31  * which emits assembler code.
32  */
34  public output_file
35 {
36 public:
37  /**
38  * The destructor.
39  */
40  virtual ~output_file_asm();
41 
42 private:
43  /**
44  * The constructor.
45  *
46  * @param file_name
47  * The name of the file to be written.
48  */
49  output_file_asm(const std::string &file_name);
50 
51 public:
52  /**
53  * The create class method is used to create new dynamically
54  * allocated instances of this class.
55  *
56  * @param file_name
57  * The file name to open to write data to. The name "-" is
58  * understood to mean the standard output.
59  */
60  static pointer create(const std::string &file_name);
61 
62 protected:
63  // See base class for documentation.
64  void write(const record &);
65 
66  // See base class for documentation.
67  void line_length_set(int);
68 
69  // See base class for documentation.
70  void address_length_set(int);
71 
72  // See base class for documentation.
74 
75  // See base class for documentation.
76  bool preferred_block_size_set(int nbytes);
77 
78  // See base class for documentation.
79  void command_line(arglex_tool *cmdln);
80 
81  // See base class for documentation.
82  const char *format_name() const;
83 
84 private:
85  /**
86  * The prefix instance variable is used to remember the variable
87  * name prefix to be used in the output.
88  */
89  std::string prefix;
90 
91  /**
92  * The taddr instance variabel is used to remember the
93  * termination address, to be emitted in the footer.
94  */
95  unsigned long taddr;
96 
97  /**
98  * The range instance variable is used to remember the range
99  * of addresses present in the output.
100  */
101  interval range;
102 
103  /**
104  * The column instance variable is used to remember the current
105  * printing column on the line.
106  */
107  int column;
108 
109  /**
110  * The current_address instance variabel is used to remember
111  * the current address that the file is positioned at. This is
112  * used to know whether we need to add padding.
113  */
114  unsigned long current_address;
115 
116  /**
117  * The line_length instance variable is used to remember the
118  * maximum line length. The output usually does not exceed it.
119  */
120  int line_length;
121 
122  /**
123  * The org_warn instance variable is used to remember if the ORG
124  * directive warning comment has been issued.
125  */
126  bool org_warn;
127 
128  /**
129  * The output_word instance variable is used to remember whether or not
130  * the input bytes should be emitted as word.
131  */
132  bool output_word;
133 
134  /**
135  * The emit_byte method is used to emit a single byte. It uses
136  * column to track the position, so as not to exceed line_length.
137  */
138  void emit_byte(int);
139 
140  /**
141  * The emit_word method is used to emit 2 byte. It uses
142  * column to track the position, so as not to exceed line_length.
143  * It is called by output_word addition.
144  */
145  void emit_word(unsigned int);
146 
147  /**
148  * The emit_4byte method is used to emit a double word (4 Byte). It uses
149  * column to track the position, so as not to exceed line_length.
150  */
151  void emit_4byte_array(unsigned long *);
152 
153  /**
154  * The dot_style instance variable is used to remember whether or
155  * not "dot" style pseudo-ops are being used. Such as:
156  *
157  * not dot_style dot_style
158  * ------------- ------------------------
159  * DB .byte
160  * DL .long
161  * DW .short
162  * END .end
163  * ORG .org
164  * PUBLIC .global
165  */
166  bool dot_style;
167 
168  /**
169  * The section_style instance variable is used to remember whether
170  * or not the output is to contain "sections".
171  *
172  * In non-section output, the output uses ORG (.org) directives to
173  * place the code at the appropriate addresses. In section output,
174  * tables of addresses and lenthgs are emitted, and the actual data
175  * is intended to be relocated at run time.
176  */
177  bool section_style;
178 
179  /**
180  * The hex_style is used to reember whether or not we are using
181  * hexadecimal constatnts or decimal constants.
182  */
183  bool hex_style;
184 
185  /**
186  * The default constructor. Do not use.
187  */
188  output_file_asm();
189 
190  /**
191  * The copy constructor. Do not use.
192  */
194 
195  /**
196  * The assignment operator. Do not use.
197  */
198  output_file_asm &operator=(const output_file_asm &);
199 };
200 
201 };
202 
203 #endif // SRECORD_OUTPUT_FILE_ASM_H
The srecord::arglex_tool is used to parse command line with srec-specific arguments.
Definition: tool.h:41
The interval class is used to represent a set of integer values, usually composed of runs of adjacent...
Definition: interval.h:36
The srecord::output_file_asm class is used to represent an output file which emits assembler code.
Definition: asm.h:35
bool preferred_block_size_set(int nbytes)
The preferred_block_size_set method is is to set a precific number of bytes for the preferred block s...
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
void write(const record &)
The write method is used to write a recordonto an output.
void command_line(arglex_tool *cmdln)
The command_line method is used by arglex_srec::get_output when parsing the command line,...
virtual ~output_file_asm()
The destructor.
int preferred_block_size_get() const
The preferred_block_size_get method is used to get the proferred block size of the output fformat.
const char * format_name() const
The format_name method is used to obtain the name of this output format.
void line_length_set(int)
The set_line_length method is used to set the maximum length of an output line, for those formats for...
void address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
The srecord::output_file class is used to represent a generic output file.
Definition: file.h:35
std::shared_ptr< output > pointer
Definition: output.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35