The HEXBIN Utility (DOS)

| II.1.10 The HEXBIN Utility Most EPROM programmers are accepting the Intel-HEX object file format that is output by ASEM-51. However, for dumb EPROM burners and special purposes it might be useful to convert the HEX file to a pure binary image file. For this the conversion utility HEXBIN is provided. It is invoked as follows:
        HEXBIN <hex> [<bin>] [/OFFSET:o] [/LENGTH:l] [/FILL:f] [/QUIET]
where <hex> is the input file in Intel-HEX format, and <bin> is the binary output file. The parameter <bin> is optional. When omitted, the file name is derived from the <hex> file name, but with the extension BIN. All file names may be specified without extensions. In these cases, the program adds default extensions as shown below:
file | extension
--- | ---
<hex> | .HEX
<bin> | .BIN
> If you want a file name to have no extension, terminate it with a '.'! Instead of file names you may also specify device names to redirect the output to character I/O ports. Device names may be terminated with a ':'! It is not checked, whether the device is existing or suitable for the task. The binary file output can also be controlled with the options /OFFSET, /FILL and /LENGTH. Normally the first byte in the binary file is the first byte of the HEX record with the lowest load address. If a number of dummy bytes is to be inserted on top of the file (e.g. for alignment in an EPROM image), this can be performed with the /OFFSET option:
>     /OFFSET:1000
> would insert 4096 dummy bytes before the first byte of the first HEX record loaded. The offset must always be specified as a hex number. The default offset is 0. Since there may be peepholes between the HEX records, a fill byte value can be defined with the /FILL option:
>     /FILL:0
> would fill all peepholes between the HEX records with zero bytes as well as all the dummy bytes that might have been inserted with the /OFFSET or /LENGTH option. The fill byte value must always be specified as a hex number. The default fill byte is the EPROM-friendly FFH. By default the last byte in the binary file is the last byte of the HEX record with the highest load address. If the binary file should have a well defined length, then a number of dummy bytes can be appended to the file (e.g. for exactly matching an EPROM length), this can be performed with the /LENGTH option:
>     /LENGTH:8000
would append as many dummy bytes behind the last byte of the file, that the total file length becomes exactly 32768 bytes. The file length must always be specified as a hex number. When HEXBIN has been invoked with all the above options, it may display a file conversion report like this:
            Hex File Converter HEXBIN V2.3

                         offset:     1000H bytes
                  first address:     9000H
                   last address:     A255H
            fill peepholes with:       00H
            binary image length:     8000H bytes
> The /QUIET option suppresses this console output, while error messages are displayed regardless. Options may be abbreviated as long as they remain unique! Examples:
>     0.)    HEXBIN
> When invoked without parameters, HEXBIN displays a help screen:
>            Hex File Converter HEXBIN V2.3

>            usage:       HEXBIN <hexfile> [<binary>] [options]

>            options:     /OFFSET:offset
>                         /LENGTH:length
>                         /FILL:fillbyte
>                         /QUIET
>     1.)    HEXBIN PROGRAM
> will convert the Intel-HEX file PROGRAM.HEX to a pure binary image file PROGRAM.BIN.
>     2.)    HEXBIN TARZAN.OBJ JUNGLE/FILL:E5
> will convert the Intel-HEX file TARZAN.OBJ to a binary image file JUNGLE.BIN and fill all peepholes between the HEX file records with the binary value E5H.
>     3.)    HEXBIN PROJECT EPROM. /off:8000 /length:10000 /f:0
will convert the Intel-HEX file PROJECT.HEX to a binary image file EPROM, insert 32K dummy bytes on top of file, fill all peepholes and the dummy bytes with nulls, and extend the file to exactly 64K. When terminating HEXBIN returns an exit code to the operating system:
situation | ERRORLEVEL
--- | ---
no errors | 0
conversion errors detected | 1
fatal runtime error | 2
There is also a Win32 console-mode version of HEXBIN: HEXBINW.EXE! HEXBINW is functionally identical to HEXBIN, but can handle long file names.