Blame | Last modification | View Log | Download | RSS feed
.TH p2bin 1.SH NAME.B p2bin \- convert code files into hex files.SH SYNTAX.B p2bin[ option(s) ] <name(s)> [ further options/names ].SH DESCRIPTIONP2BIN is a tool to convert the contents of one or several code filesgenerated by AS into binary files. A binary file is a 1:1 memory imageof the processor's memory and is especially suited for EPROM programmersand emulators.Arguments to P2BIN may be either command line parameters or file namespecifications. Any argument that starts with the charactes +, - or/ is regarded as a comand line parameter (which may take anadditional command line argument); any other argument is regarded asa file name. Generally, P2BIN needs at least two file names: Aninput code file and the name of the binary output file. If multiplefile names are given, P2BIN will always take the last name as theoutput file's name. If an input file name does not have anextension, the extension '.p' is added automatically. Similarly, theextension '.bin' is added automatically to the target file's name.A special case occurs when only one file name is given: P2BIN willthen take its name as the source (possibly extended with '.p'), andthe same name as target (with '.bin' as additional or replacedextension)..SH COMMAND-LINE PARAMETERSIf a command-line parameter starts with a slash(/) or minus sign(-),it turns an option on; if a command-line parameter starts with a plussign(+), it turns a specific option off. Numeric arguments toparameters can be either written in decimal or hexadecimal notation.For hexadecimal notation, prefix the number with a dollar($) sign.In the following list, all options will be shown in the form that isneeded to change the default behaviour, which might be a plus orminus sign, depening on wether the option is on or off by default..B p2binaccepts the following command-line parameters:.TP.B -f <number>[,<further numbers>]Add <number> to the list of record header IDs that allow a recordfrom a source file to be written to the target file. A certainheader ID marks code for a certain target processor family; thus,this filter allows to distill code for a certain processor out of asource file that contains code for different processor families.Negation of this parameter removes certain header IDs from P2BIN'slist. See the user manual of AS for a list of all possible header IDvalues. If P2BIN's list of header IDs is empty, no filtering willtake place, i.e. all records from a source file will make it into thetarget file..TP.B -l <number>Set the value that should be used to fill memory areas in the binaryimage that are unused by the input code file(s). The default for thisis to fill unused areas with the value 255 (0xff), which is the best choicefor EPROMs as erased EPROM cells carry this value and an intelligentEPROM burner can skip these cells, speeding up the programming process andreducing stress for the EPROM. However, there are specialized EPROMs thathave zeros in their cells after erasure, and you might want to fill unusedareas with a code that executes as a NOP or BREAK statement..TP.B -m <all|even|odd|byte<0|1|2|3>|word<0|1>>Set the mask of bytes to be filtered out. If your target processor hasa 16- or 32-bit data path, but your EPROMs are only 8- or 16-bits wide,the code has to be spread over the EPROMs in an alternating fashion.This option allows you to do the necesary splitting, however you haveto run P2BIN two or four times with different masks. The possible argumentshave the following meanings:.B alldoes not do any filtering, i.e. all bytes of your code will show up in theresulting image. This is the default..B evenor.B oddwill take only those bytes whose addresses are in the form 2*n or 2*n+1. Theyare useful if you have a 16-bit data path and two 8-bit EPROMs..B byte0, byte1, byte2or.B byte3will take only those bytes whose addresses are in the form 4*n ... 4*n+3.They are useful if you have a 32-bit data path and four 8-bit EPROMs..B word0or.B word1will take only those bytes whose addresses are in the form 4*n+0 / 4*n+1or 4*n+2 / 4*n+3. They are useful if you have a 32-bit data path and two16-bit EPROMs.When using one of these filters, the resulting images will automaticallybecome smaller by a factor of 2 or 4. Beware that this does not influenceaddress specifications given with the.B -rcommand-line parameter! See also the examples section below for correctusage..TP.B -r < <start>-<stop> >Set a certain address range to be filtered out of the input file(s).Code that lies outside this range does not appear in the output file.The default for the address filter is the 0-$7fff, which might createconfusion in some cases. As a special option,.B <start>and.B <stop>may consist of just a single dollar sign (escape thisin UNIX shells!) to signify the lowest resp. highest address thatoccurs in the input file(s). Using this option will implicitlyenable a second pass over all input files to find the minimum andmaximum values before conversion starts, reducing the speed of P2BINslightly..TP.B -segment <CODE|DATA|....>Select the address space hex data is created from. By default, only recordsfor the CODE segment (plus DATA for TI DSK) will be considered. Use thisoption with different arguments if the source file contains data from otheraddress spaces. This way, multiple HEX files (one per address space) canbe produced..TP.B -e <address>Set an entry address or modify an existing one. P2BIN can optionallyprepend the start address to the binary image to tell a program loaderwhere to jump after the image has been loaded (see the '-S' option).Normally, this address is generated by AS if the program's END statementhas a label as argument, but this options allows to change the entry pointor add one if it was forgotten in the program itself..TP.B -S [L|B]<n>Instruct P2BIN to prepend the program entry address to the image. 'n' isthe length in bytes the address should have and has an allowed range from 1to 4. The number may be prefixed by a 'L' or 'B' letter that sets theendianess of the address. If no letter is used, little endian is assumed..TP.B -sTell P2BIN to include a checksum into the image. A checksum is a bytevalue entered into the image's last byte that is the two's complement ofthe sum of all previous bytes. Therefore, the sum of all bytes modulus256 will become zero. This option is useful if you want to check theROM contents in your program as part of a power-on self-test, but keepin mind that you must not use the last byte for your own purposes anymore!.TP.B -kInstruct P2BIN to erase the program source files after conversion..TP.B -q or -quietEnable quiet operation mode, suppressing copyright and purely informativemessages. Only errors will be displayed..SH PRESETTING PARAMETERSParameters need not neccessarily be given in the command line itself. Beforeprocessing of command line parameters starts, P2BIN will look if the.B P2BINCMDenvironment variable is defined. If it exists, its contents will betreated as additional command line paramters whose syntax is absolutelyequal to normal command line parameters. As exception is made if thevariable's contents start with a '@' sign; in such a case, the string afterthe '@' sign is treated as the name of a file that contains the options.Such a file (also called a 'key file') has the advantage that it allowsthe options to be written in different lines, and it does not have a sizelimit. Some operating systems (like MS-DOS) do have a length limit oncommand lines and environment variable contents, so the key file may beyour only option if you have a lot of lengthy parameters for P2BIN..SH RETURN CODES.B p2binmay return with the following codes:.TP.B 0no errors..TP.B 1incorrect command line parameters..TP.B 2I/O-error..TP.B 3An input file had an incorrect format..SH EXAMPLESTo convert a file.B file1.pfully into its binary representation, use.PP.B p2bin -r \e$-\e$ file1.PPIf you have a processor with a 64 KByte address space and a 16-bitdata path and you want to assure that the memory image always startsat address 0, regardless of address layout in the code file, use.PP.B p2bin -r 0-\e$ffff -m even file1.B evenfile.B p2bin -r 0-\e$ffff -m odd file1.B oddfile.PPto get images for two 27256 EPROMs..SH NATIONAL LANGUAGE SUPPORTp2bin supports national languages in the same way as AS. See the manualpage for asl(1) for more information about this..SH TIPSCalling P2BIN without any arguments will print a short helplisting all command line parameters..SH SEE ALSOasl(1), plist(1), pbind(1), p2hex(1).SH HISTORYP2BIN originally appeared as an AS tool in 1992, written inBorland-Pascal, and was ported to C and UNIX in 1996..SH BUGSCommand line interpreters of some operating systems reserve somecharacters for their own use, so it might be necessary to givecommand line parameters with certain tricks (e.g., with the helpof escape characters).P2BIN does not have so far an opportunity to filter records bytarget segment. Instead, records that contain data for any othersegment than CODE are completely ignored..SH AUTHOR(S)Alfred Arnold (alfred@ccac.rwth-aachen.de)