Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1186 | savelij | 1 | .TH p2bin 1 |
2 | |||
3 | .SH NAME |
||
4 | .B p2bin \- convert code files into hex files |
||
5 | |||
6 | .SH SYNTAX |
||
7 | .B p2bin |
||
8 | [ option(s) ] <name(s)> [ further options/names ] |
||
9 | |||
10 | .SH DESCRIPTION |
||
11 | |||
12 | P2BIN is a tool to convert the contents of one or several code files |
||
13 | generated by AS into binary files. A binary file is a 1:1 memory image |
||
14 | of the processor's memory and is especially suited for EPROM programmers |
||
15 | and emulators. |
||
16 | |||
17 | Arguments to P2BIN may be either command line parameters or file name |
||
18 | specifications. Any argument that starts with the charactes +, - or |
||
19 | / is regarded as a comand line parameter (which may take an |
||
20 | additional command line argument); any other argument is regarded as |
||
21 | a file name. Generally, P2BIN needs at least two file names: An |
||
22 | input code file and the name of the binary output file. If multiple |
||
23 | file names are given, P2BIN will always take the last name as the |
||
24 | output file's name. If an input file name does not have an |
||
25 | extension, the extension '.p' is added automatically. Similarly, the |
||
26 | extension '.bin' is added automatically to the target file's name. |
||
27 | A special case occurs when only one file name is given: P2BIN will |
||
28 | then take its name as the source (possibly extended with '.p'), and |
||
29 | the same name as target (with '.bin' as additional or replaced |
||
30 | extension). |
||
31 | |||
32 | .SH COMMAND-LINE PARAMETERS |
||
33 | |||
34 | If a command-line parameter starts with a slash(/) or minus sign(-), |
||
35 | it turns an option on; if a command-line parameter starts with a plus |
||
36 | sign(+), it turns a specific option off. Numeric arguments to |
||
37 | parameters can be either written in decimal or hexadecimal notation. |
||
38 | For hexadecimal notation, prefix the number with a dollar($) sign. |
||
39 | In the following list, all options will be shown in the form that is |
||
40 | needed to change the default behaviour, which might be a plus or |
||
41 | minus sign, depening on wether the option is on or off by default. |
||
42 | |||
43 | .B p2bin |
||
44 | accepts the following command-line parameters: |
||
45 | .TP |
||
46 | .B -f <number>[,<further numbers>] |
||
47 | |||
48 | Add <number> to the list of record header IDs that allow a record |
||
49 | from a source file to be written to the target file. A certain |
||
50 | header ID marks code for a certain target processor family; thus, |
||
51 | this filter allows to distill code for a certain processor out of a |
||
52 | source file that contains code for different processor families. |
||
53 | Negation of this parameter removes certain header IDs from P2BIN's |
||
54 | list. See the user manual of AS for a list of all possible header ID |
||
55 | values. If P2BIN's list of header IDs is empty, no filtering will |
||
56 | take place, i.e. all records from a source file will make it into the |
||
57 | target file. |
||
58 | .TP |
||
59 | .B -l <number> |
||
60 | |||
61 | Set the value that should be used to fill memory areas in the binary |
||
62 | image that are unused by the input code file(s). The default for this |
||
63 | is to fill unused areas with the value 255 (0xff), which is the best choice |
||
64 | for EPROMs as erased EPROM cells carry this value and an intelligent |
||
65 | EPROM burner can skip these cells, speeding up the programming process and |
||
66 | reducing stress for the EPROM. However, there are specialized EPROMs that |
||
67 | have zeros in their cells after erasure, and you might want to fill unused |
||
68 | areas with a code that executes as a NOP or BREAK statement. |
||
69 | .TP |
||
70 | .B -m <all|even|odd|byte<0|1|2|3>|word<0|1>> |
||
71 | |||
72 | Set the mask of bytes to be filtered out. If your target processor has |
||
73 | a 16- or 32-bit data path, but your EPROMs are only 8- or 16-bits wide, |
||
74 | the code has to be spread over the EPROMs in an alternating fashion. |
||
75 | This option allows you to do the necesary splitting, however you have |
||
76 | to run P2BIN two or four times with different masks. The possible arguments |
||
77 | have the following meanings: |
||
78 | |||
79 | .B all |
||
80 | does not do any filtering, i.e. all bytes of your code will show up in the |
||
81 | resulting image. This is the default. |
||
82 | |||
83 | .B even |
||
84 | or |
||
85 | .B odd |
||
86 | will take only those bytes whose addresses are in the form 2*n or 2*n+1. They |
||
87 | are useful if you have a 16-bit data path and two 8-bit EPROMs. |
||
88 | |||
89 | .B byte0, byte1, byte2 |
||
90 | or |
||
91 | .B byte3 |
||
92 | will take only those bytes whose addresses are in the form 4*n ... 4*n+3. |
||
93 | They are useful if you have a 32-bit data path and four 8-bit EPROMs. |
||
94 | |||
95 | .B word0 |
||
96 | or |
||
97 | .B word1 |
||
98 | will take only those bytes whose addresses are in the form 4*n+0 / 4*n+1 |
||
99 | or 4*n+2 / 4*n+3. They are useful if you have a 32-bit data path and two |
||
100 | 16-bit EPROMs. |
||
101 | |||
102 | When using one of these filters, the resulting images will automatically |
||
103 | become smaller by a factor of 2 or 4. Beware that this does not influence |
||
104 | address specifications given with the |
||
105 | .B -r |
||
106 | command-line parameter! See also the examples section below for correct |
||
107 | usage. |
||
108 | .TP |
||
109 | .B -r < <start>-<stop> > |
||
110 | |||
111 | Set a certain address range to be filtered out of the input file(s). |
||
112 | Code that lies outside this range does not appear in the output file. |
||
113 | The default for the address filter is the 0-$7fff, which might create |
||
114 | confusion in some cases. As a special option, |
||
115 | .B <start> |
||
116 | and |
||
117 | .B <stop> |
||
118 | may consist of just a single dollar sign (escape this |
||
119 | in UNIX shells!) to signify the lowest resp. highest address that |
||
120 | occurs in the input file(s). Using this option will implicitly |
||
121 | enable a second pass over all input files to find the minimum and |
||
122 | maximum values before conversion starts, reducing the speed of P2BIN |
||
123 | slightly. |
||
124 | .TP |
||
125 | .B -segment <CODE|DATA|....> |
||
126 | |||
127 | Select the address space hex data is created from. By default, only records |
||
128 | for the CODE segment (plus DATA for TI DSK) will be considered. Use this |
||
129 | option with different arguments if the source file contains data from other |
||
130 | address spaces. This way, multiple HEX files (one per address space) can |
||
131 | be produced. |
||
132 | .TP |
||
133 | .B -e <address> |
||
134 | |||
135 | Set an entry address or modify an existing one. P2BIN can optionally |
||
136 | prepend the start address to the binary image to tell a program loader |
||
137 | where to jump after the image has been loaded (see the '-S' option). |
||
138 | Normally, this address is generated by AS if the program's END statement |
||
139 | has a label as argument, but this options allows to change the entry point |
||
140 | or add one if it was forgotten in the program itself. |
||
141 | .TP |
||
142 | .B -S [L|B]<n> |
||
143 | |||
144 | Instruct P2BIN to prepend the program entry address to the image. 'n' is |
||
145 | the length in bytes the address should have and has an allowed range from 1 |
||
146 | to 4. The number may be prefixed by a 'L' or 'B' letter that sets the |
||
147 | endianess of the address. If no letter is used, little endian is assumed. |
||
148 | .TP |
||
149 | .B -s |
||
150 | |||
151 | Tell P2BIN to include a checksum into the image. A checksum is a byte |
||
152 | value entered into the image's last byte that is the two's complement of |
||
153 | the sum of all previous bytes. Therefore, the sum of all bytes modulus |
||
154 | 256 will become zero. This option is useful if you want to check the |
||
155 | ROM contents in your program as part of a power-on self-test, but keep |
||
156 | in mind that you must not use the last byte for your own purposes any |
||
157 | more! |
||
158 | .TP |
||
159 | .B -k |
||
160 | |||
161 | Instruct P2BIN to erase the program source files after conversion. |
||
162 | .TP |
||
163 | .B -q or -quiet |
||
164 | |||
165 | Enable quiet operation mode, suppressing copyright and purely informative |
||
166 | messages. Only errors will be displayed. |
||
167 | |||
168 | .SH PRESETTING PARAMETERS |
||
169 | |||
170 | Parameters need not neccessarily be given in the command line itself. Before |
||
171 | processing of command line parameters starts, P2BIN will look if the |
||
172 | .B P2BINCMD |
||
173 | environment variable is defined. If it exists, its contents will be |
||
174 | treated as additional command line paramters whose syntax is absolutely |
||
175 | equal to normal command line parameters. As exception is made if the |
||
176 | variable's contents start with a '@' sign; in such a case, the string after |
||
177 | the '@' sign is treated as the name of a file that contains the options. |
||
178 | Such a file (also called a 'key file') has the advantage that it allows |
||
179 | the options to be written in different lines, and it does not have a size |
||
180 | limit. Some operating systems (like MS-DOS) do have a length limit on |
||
181 | command lines and environment variable contents, so the key file may be |
||
182 | your only option if you have a lot of lengthy parameters for P2BIN. |
||
183 | |||
184 | .SH RETURN CODES |
||
185 | |||
186 | .B p2bin |
||
187 | may return with the following codes: |
||
188 | .TP |
||
189 | .B 0 |
||
190 | no errors. |
||
191 | .TP |
||
192 | .B 1 |
||
193 | incorrect command line parameters. |
||
194 | .TP |
||
195 | .B 2 |
||
196 | I/O-error. |
||
197 | .TP |
||
198 | .B 3 |
||
199 | An input file had an incorrect format. |
||
200 | |||
201 | .SH EXAMPLES |
||
202 | |||
203 | To convert a file |
||
204 | .B file1.p |
||
205 | fully into its binary representation, use |
||
206 | .PP |
||
207 | .B p2bin -r \e$-\e$ file1 |
||
208 | .PP |
||
209 | If you have a processor with a 64 KByte address space and a 16-bit |
||
210 | data path and you want to assure that the memory image always starts |
||
211 | at address 0, regardless of address layout in the code file, use |
||
212 | .PP |
||
213 | .B p2bin -r 0-\e$ffff -m even file1 |
||
214 | .B evenfile |
||
215 | |||
216 | .B p2bin -r 0-\e$ffff -m odd file1 |
||
217 | .B oddfile |
||
218 | .PP |
||
219 | to get images for two 27256 EPROMs. |
||
220 | |||
221 | .SH NATIONAL LANGUAGE SUPPORT |
||
222 | |||
223 | p2bin supports national languages in the same way as AS. See the manual |
||
224 | page for asl(1) for more information about this. |
||
225 | |||
226 | .SH TIPS |
||
227 | |||
228 | Calling P2BIN without any arguments will print a short help |
||
229 | listing all command line parameters. |
||
230 | |||
231 | .SH SEE ALSO |
||
232 | |||
233 | asl(1), plist(1), pbind(1), p2hex(1) |
||
234 | |||
235 | .SH HISTORY |
||
236 | |||
237 | P2BIN originally appeared as an AS tool in 1992, written in |
||
238 | Borland-Pascal, and was ported to C and UNIX in 1996. |
||
239 | |||
240 | .SH BUGS |
||
241 | |||
242 | Command line interpreters of some operating systems reserve some |
||
243 | characters for their own use, so it might be necessary to give |
||
244 | command line parameters with certain tricks (e.g., with the help |
||
245 | of escape characters). |
||
246 | |||
247 | P2BIN does not have so far an opportunity to filter records by |
||
248 | target segment. Instead, records that contain data for any other |
||
249 | segment than CODE are completely ignored. |
||
250 | |||
251 | .SH AUTHOR(S) |
||
252 | |||
253 | Alfred Arnold (alfred@ccac.rwth-aachen.de) |
||
254 |