10 UTILITIES

This chapter contains the following sections:

Overview
ar51
dmp51
flashcy51
flashphytec
ieee51
ihex51
omf51
srec51
mk51

10.1 Overview

The following utilities are supplied with the Cross-Assembler for the 8051 which can be useful at various stages during program development.

ar51 A librarian facility, which can be used to create and maintain object libraries.

dmp51 A utility program to report the contents of an object file.

flashcy51 A utility for the Cygnal 8051 family to flash an IEEE-695, OMF51, Intel Hex or Motorola S-Records file.

flashphytec A utility for the Phytec 8051 target boards to flash an IEEE-695, OMF51, Intel Hex or Motorola S-Records file.

ieee51 A program which formats files generated by the assembler to the IEEE format (used by a debugger).

ihex51 A program which formats files generated by the linker to Intel Hex Format Format.

omf51 A formatter to translate TCP a.out formatted files into absolute OMF51 format.

srec51 A program which formats files generated by the linker to Motorola S Format.

mk51 A utility program to maintain, update, and reconstruct groups of programs.

When you use a UNIX shell (Bourne shell, C-shell), arguments containing special characters (such as '( )' and '?') must be enclosed with "" or escaped. The -? option (in the C-shell) becomes: "-?" or -\?.

The utilities are explained on the following pages.

10.2 ar51

Name

ar51 archive and library maintainer

Syntax

ar51 d | p | q | s | t | x [vl] archive files...
ar51 r | m [a | b | i posname][ cvl] archive files...
ar51 -Qfile
ar51 -V
ar51
-? ( UNIX C-shell: "-?" or -\? )

Description

ar51 maintains groups of files (modules) combined into a single archive file. Its main use is to create and update library files as used by the assembler/linker. It can be used, though, for any similar purpose.

The ar51 archiver uses a full ASCII module header. This makes archives portable and allows them to be edited. The header only contains name and size information.

A file produced by ar51 starts with the line

followed by the constituent files, each preceded by a file header, for example:

Note that ar51 has an option that searches for headers instead of using the size.

archive is the archive file. If '-' is used as archive file name, then the original archive is read from standard input and the resulting archive file is written to standard output. This makes it possible to use ar51 as a filter.

files are constituent modules in the archive file. For PC, the usage of wildcards (?,*) is allowed.

posname is required for the positioning options a b i and specifies the position in the archive where modules are inserted.

Options

a Append new modules after posname.

b Insert new modules before posname.

c Normally ar51 creates archive when it needs to. The create option suppresses the warning message that is produced when archive is created. The c option can only be used with the r command and '-' as archive file name to suppress reading from standard input.

d Delete the named modules from the archive file.

i Identical to option b.

l Local. This option causes ar51 to place the temporary files in the current directory for PC; in the directory /tmp for UNIX.

m Move the named modules to the end of the archive, or to another position as specified by one of the positioning options.

p Print the named modules in the archive on standard output.

q Quickly append the named modules to the end of the archive file. Positioning options are invalid. The command does not check whether the added members are already in the archive. Useful only to avoid very long waiting times when creating a large archive piece-by-piece.

r Replace the named modules in the archive file. If no names are given, only those modules are replaced for which a file with the same name is found in the current directory. New modules are placed at the end unless another position is specified by one of the positioning options.

s Scan for the end of a module; do not use the size in the module header. The end of a module is found if end-of-file is detected or if a new module header is reached. Note that this may give false results if the modules happen to contain lines resembling module headers. Normally this letter is used as an option, but if no command character is present it behaves as a command: the archive is rewritten with correct module sizes.

t Print a table of contents of the archive file. If no names are given, all modules in the archive are printed. If names are given, only those modules are tabled.

v Verbose. Under the verbose option, ar51 gives a module-by-module description of the making of a new archive file from the old archive and the constituent modules. When used with t, it gives not only the names but also the sizes of modules. When used with p, it precedes each module with a name.

x Extract the named modules. If no names are given, all modules in the archive are extracted. In neither case does x alter the archive file.

-Qfile Use this option for very long command lines. The file is used as an argument string. Each line in the file is treated as a separate argument for ar51.

-V Display version information at stderr.

-? Display an explanation of options at stdout.

If the same module is mentioned twice in an argument list, it may be put in the archive twice.

10.3 dmp51

Name

dmp51 report the contents of an object file

Syntax

dmp51 [options] [file ...]
dmp51 -V
dmp51
-? ( UNIX C-shell: "-?" or -\? )

Description

dmp51 gives a complete report of all files in the argument list which have been created by the TASKING assembler or linker. If no file is given, the file a.out is displayed.

Options

Options start with a dash '-'. Options can be combined after one dash. For example -vh is the same as -v -h.

-h Display the header record of the input file.

-s Display the section records of the input file.

-c Display the code bytes of each section.

-r Display the relocation records of the input file.

-n Display the symbol table records of the input file.

-a Display the string area of the input file.

-e Display the extension records of the input file.

-v Verbose mode. Display also section names when a reference to a section number is made. Type information is also decoded into symbolic names as mentioned in out.h and sd_class.h.

-V Display version information at stderr.

-? Display an explanation of options at stdout.

All options except the -v, -V and -? options are on by default. The use of any option except the -v option turns off all other options.

Files

out.h
sd_class.h

10.4 flashcy51

Name

flashcy51 Flash tool for the Cygnal 8051 family
(using Cygnal JTAG wiggler).

Syntax

flashcy51 [option]... [file]...

Description

With flashcy51 you can load an IEEE-695, OMF51, Intel Hex or Motorola S-record file in a flash device. If you invoke flashcy51 with the -nodialog command line option the absolute file is directly flashed into the target.

You can configure all flash settings from EDE via the Flasher entry of the Project | Project Options dialog. You can then start flashing with one click on the Flash IEEE-695, Intel Hex, Motorola S-Rec or OMF51 file button located in the toolbar.

You can perform several actions with the flash tool:

Program

Select this to program the flash device with the specified file.

Verify

Select this to compare the absolute file with the content of the FLASH.

Options

-actions={P|V}
Specify flash actions to perform in the order given:
P - Program file
V - Verify programmed blocks

-com{1|2|3|4}
Specify the serial port to use (Windows only).

-dir directory
Set working directory.

-err file Append errors to file.

-f file Read options from file.

-go Start the application directly after flashing.

-h Display a short explanation of options.

-level=number
Log level (0=none until 3=all).

-nodialog Do not use the Flash dialog..

Example

To flash and verify the file demo.sre in a device connected at serial port COM2, using a command line interface, type:

10.5 flashphytec

Name

flashphytec Flash tool for the Phytec 8051 target boards.

Syntax

flashphytec [option]... [file]...

Description

With flashphytec you can load an IEEE-695, OMF51, Intel Hex or Motorola S-record file in a flash device. If you invoke flashphytec with the -nodialog command line option the absolute file is directly flashed into the target.

You can configure all flash settings from EDE via the Flasher entry of the Project | Project Options dialog. You can then start flashing with one click on the Flash IEEE-695, Intel Hex, Motorola S-Rec or OMF51 file button located in the toolbar.

You can perform several actions with the flash tool:

Full erase

Select this to erase the entire flash memory.

Program

Select this to program the flash device with the specified file.

Options

-actions={B|F|P|V}
Specify flash actions to perform in the order given:
F - Erase all blocks
P - Program file

-baudrate=baudrate
Specify the baud rate to use: 96000, 19200, 38400 or 57600 (default).

-com{1|2|3|4}
Specify the serial port to use (Windows only).

-tty=device Specify the device to use (UNIX only).

-dir directory
Set working directory.

-err file Append errors to file.

-f file Read options from file.

-h Display a short explanation of options.

-level=number
Log level (0=none until 3=all).

-nodialog Do not use the Flash dialog..

-version Get version info.

Example

To erase the flash device and flash the file demo.sre at a baud rate of 19200 in a device connected at serial port COM2, using a command line interface, type:

10.6 ieee51

Name

ieee51 format a.out absolute object code to standard IEEE-695 object module format

Syntax

ieee51 [-sstartaddr] [-c] inputfile outputfile
ieee51 -V
ieee51
-? ( UNIX C-shell: "-?" or -\? )

Description

The program ieee51 formats a TASKING a.out file to IEEE-695 Object Module Format, as required by a debugger. The inputfile must be a TASKING a.out load file, which is already linked.

The section information and data part are formatted to IEEE format. If the a.out file contains high level language debug information, it is also formatted to IEEE debug records.

It is recommended to use $debuginfo(371o) of asm51, to control the amount of generated debug information. With this option the assembler exports everything but compiler generated labels and assembler local symbols.

Options

-? Display an explanation of options at stdout.

-V Display version information at stderr.

-c No distinction between parameters and automatics and no stack adjustments. This option makes the output strict IEEE-695.

-sstartaddr Define the (hex) execution start address of the IEEE file. If you omit this option, the default execution start address is 0.

10.7 ihex51

Name

ihex51 format object code into Intel hex format

Syntax

ihex51 [-lcount] [-z] [-ssectlist] [-i8] [-i16] [-caddress[,address]]
[-aaddress[,address]] [-poffset [-ehex]] [-w] [infile]
[[-o] outfile]

ihex51 -V
ihex51
-? ( UNIX C-shell: "-?" or -\? )

Description

ihex51 formats object files and executable files to Intel hex format records for (E)PROM programmers. Hexadecimal numbers A to F are always generated as capitals.

Empty sections in the input file are skipped. No empty records are generated for empty sections.

The program can format records to Intel hex8 format (for addresses less then 0xFFFF) and Intel hex16 format. When a section jumps over a 64k limit the program switches to hex16 records automatically. It is the programmers responsibility that sections do not intersect with each other.

Addresses that lie between sections are not filled in.

The output does not contain symbol information.

There is no need to place the input and output file names at the end of the command line. If data is to be read from standard input and the output is not standard output, the output file must be specified with the -o option.

If only one filename is given, it is assumed that it is the name of the input file hence output is written to standard output. It is also possible to omit both the input filename and output filename. In that case standard input and standard output are used.

Options

Options must be separated by a blank and start with a minus sign (-). Decimal and hexadecimal arguments should be concatenated directly to the option letter.

Options may be specified in any order.

Output filenames should be separated from the -o option letter by a blank.

Example:

The next example gives the same result:

-i8 Output of Intel hex8 records for addresses up to 0xFFFF. This is the default record format.

-i16 Output of Intel hex16 records, i.e. extended address records with a segment base address are generated for every section. This format is also used when a 64k boundary is crossed.

-lcount Number of data bytes in the Intel hex format record. The number of characters in a line is given by count * 2 + 11. The default count is 32.

-z Do not output records with zeros (0x00) only.

-ssectlist sectlist is a list of section numbers that must be written to output. The section numbers must be separated by commas. Note: section numbers start at 0 and can be found with the dmp51 utility.

-poffset offset is the offset in a section at which the output must start. If no section number is specified with the -s option, then bytes are skipped in the first record found. The user should be aware of the fact that there is no detection of skipping an entire section in a file. The -p option may not occur more than once in a command line. Warning: sections are adjacent in the input file, but do not have to be contiguous in memory!

-ehex hex is the length of the data output (must be used in combination with -p option). The user must have a clear view of the sizes and base addresses of the sections when he uses the -p and -e options.

-aaddress[,address]
If only one address is given the specified address is added to the address of any data record.

-caddress[,address]
This option specifies the start address which is loaded into the processor. The start address is placed in the 'end-of-file' record. See the -a option for further details about the format.

-o outfile outfile is the name of the file to which output is written. This option must be used if the input is standard input and the output must be written in a file.

-w Select word address count instead of byte address count.

-V Display version information at stderr.

-? Display an explanation of options at stdout.

10.8 mk51

Name

mk51 maintain, update, and reconstruct groups of programs

Syntax

mk51 [option ...] [target ...] [macro=value ...]
mk51 -V
mk51
-? ( UNIX C-shell: "-?" or -\? )

Description

mk51 takes a file of dependencies (a 'makefile') and decides what commands have to be executed to bring the files up-to-date. These commands are either executed directly from mk51 or written to the standard output without executing them.

If no target is specified on the command line, mk51 uses the first target defined in the first makefile.

Long filenames are supported when they are surrounded by double quotes ("). It is also allowed to use spaces in directory names and file names.

Options

-? Show invocation syntax.

-D Display the text of the makefiles as read in.

-DD Display the text of the makefiles and 'mk51.mk'.

-G dirname
Change to the directory specified with dirname before reading a makefile. This makes it possible to build an application in another directory than the current working directory.

-K Do not remove temporary files.

-S Undo the effect of the -k option. Stop processing when a non-zero exit status is returned by a command.

-V Display version information at stderr.

-W target Execute as if this target has a modification time of "right now". This is the "What If" option.

-d Display the reasons why mk51 chooses to rebuild a target. All dependencies which are newer are displayed.

-dd Display the dependency checks in more detail. Dependencies which are older are displayed as well as newer.

-e Let environment variables override macro definitions from makefiles. Normally, makefile macros override environment variables. Command line macro definitions always override both environment variables and makefile macros definitions.

-f file Use the specified file instead of 'makefile'. A '-' as the makefile argument denotes the standard input.

-i Ignore error codes returned by commands. This is equivalent to the special target .IGNORE:.

-k When a nonzero error status is returned by a command, abandon work on the current target, but continue with other branches that do not depend on this target.

-m file Read command line information from file. If file is a '-', the information is read from standard input.

-n Perform a dry run. Print commands, but do not execute them. Even lines beginning with an @ are printed. However, if a command line is an invocation of mk51, that line is always executed.

-q Question mode. mk51 returns a zero or non-zero status code, depending on whether or not the target file is up to date.

-r Do not read in the default file 'mk51.mk'.

-s Silent mode. Do not print command lines before executing them. This is equivalent to the special target .SILENT:.

-t Touch the target files, bringing them up to date, rather than performing the rules to reconstruct them.

-w Redirect warnings and errors to standard output. Without, mk51 and the commands it executes use standard error for this purpose.

macro=value
Macro definition. This definition remains fixed for the mk51 invocation. It overrides any regular definitions for the specified macro within the makefiles and from the environment. It is inherited by subordinate mk51's but act as an environment variable for these. That is, depending on the -e setting, it may be overridden by a makefile definition.

Usage

Makefiles

The first makefile read is 'mk51.mk', which is looked for at the following places (in this order):

- in the current working directory

- in the directory pointed to by the HOME environment variable

- in the etc directory relative to the directory where mk51 is located

Example (PC):

Example (UNIX):

It typically contains predefined macros and implicit rules.

The default name of the makefile is 'makefile' in the current directory. If this file is not found on a UNIX system, the file 'Makefile' is then used as the default. Alternate makefiles can be specified using one or more -f options on the command line. Multiple -f options act as if all the makefiles were concatenated in a left-to-right order.

The makefile(s) may contain a mixture of comment lines, macro definitions, include lines, and target lines. Lines may be continued across input lines by escaping the NEWLINE with a backslash (\). If a line must end with a backslash then an empty macro should be appended. Anything after a "#" is considered to be a comment, and is stripped from the line, including spaces immediately before the "#". If the "#" is inside a quoted string, it is not treated as a comment. Completely blank lines are ignored.

An include line is used to include the text of another makefile. It consists of the word "include" left justified, followed by spaces, and followed by the name of the file that is to be included at this line. Macros in the name of the included file are expanded before the file is included. Include files may be nested.

An export line is used for exporting a macro definition to the environment of any command executed by mk51. Such a line starts with the word "export", followed by one or more spaces and the name of the macro to be exported. Macros are exported at the moment an export line is read. This implies that references to forward macro definitions are equivalent to undefined macros.

Conditional Processing

Lines containing ifdef, ifndef, else or endif are used for conditional processing of the makefile. They are used in the following way:

The if-lines and else-lines may contain any number of lines or text of any kind, even other ifdef, ifndef, else and endif lines, or no lines at all. The else line may be omitted, along with the else-lines following it.

First the macroname after the if command is checked for definition. If the macro is defined then the if-lines are interpreted and the else-lines are discarded (if present). Otherwise the if-lines are discarded; and if there is an else line, the else-lines are interpreted; but if there is no else line, then no lines are interpreted.

When using the ifndef line instead of ifdef, the macro is tested for not being defined. These conditional lines can be nested up to 6 levels deep.

Macros

Macros have the form `WORD = text and more text'. The WORD need not be uppercase, but this is an accepted standard. Spaces around the equal sign are not significant. Later lines which contain $(WORD) or ${WORD} will have this replaced by `text and more text'. If the macro name is a single character, the parentheses are optional. Note that the expansion is done recursively, so the body of a macro may contain other macro invocations. The right side of a macro definition is expanded when the macro is actually used, not at the point of definition.

Example:

`$(FOOD)' becomes `meat and/or vegetables and water' and the environment variable FOOD is set accordingly by the export line. However, when a macro definition contains a direct reference to the macro being defined then those instances are expanded at the point of definition. This is the only case when the right side of a macro definition is (partially) expanded. For example, the line

after the export line affects `$(FOOD)' just as the line

would do. However, the environment variable FOOD will only be updated when it is exported again.

You are advised not to use the double quotes (") for long filename support in macros, otherwise this might result in a concatination of two macros with double quotes (") in between.

Special Macros

MAKE This normally has the value mk51. Any line which invokes MAKE temporarily overrides the -n option, just for the duration of the one line. This allows nested invocations of MAKE to be tested with the -n option.

MAKEFLAGS
This macro has the set of options provided to mk51 as its value. If this is set as an environment variable, the set of options is processed before any command line options. This macro may be explicitly passed to nested mk51's, but it is also available to these invocations as an environment variable. The -f and -d flags are not recorded in this macro.

PRODDIR This macro expands the name of the directory where mk51 is installed without the last path component. The resulting directory name will be the root directory of the installed 8051 package, unless mk51 is installed somewhere else. This macro can be used to refer to files belonging to the product, for example a library source file.

Example:

When mk51 is installed in the directory /cc51/bin this line expands to:

SHELLCMD
This contains the default list of commands which are local to the SHELL. If a rule is an invocation of one of these commands, a SHELL is automatically spawned to handle it.

$ This macro translates to a dollar sign. Thus you can use "$$" in the makefile to represent a single "$".

There are several dynamically maintained macros that are useful as abbreviations within rules. It is best not to define them explicitly.

$* The basename of the current target.

$< The name of the current dependency file.

$@ The name of the current target.

$? The names of dependents which are younger than the target.

$! The names of all dependents.

The $< and $* macros are normally used for implicit rules. They may be unreliable when used within explicit target command lines. All macros may be suffixed with F to specify the Filename components (e.g. ${*F}, ${@F}). Likewise, the macros $*, $< and $@ may be suffixed by D to specify the directory component.

The result of the $* macro is always without double quotes ("), regardless of the original target having double quotes (") around it or not.
The result of using the suffix F (Filename component) or D (Directory component) is also always without double quotes ("), regardless of the original contents having double quotes (") around it or not.

Functions

A function not only expands but also performs a certain operation. Functions syntactically look like macros but have embedded spaces in the macro name, e.g. '$(match arg1 arg2 arg3 )'. All functions are built-in and currently there are five of them: match, separate, protect, exist and nexist.

The match function yields all arguments which match a certain suffix:

will yield

The separate function concatenates its arguments using the first argument as the separator. If the first argument is enclosed in double quotes then '\n' is interpreted as a newline character, '\t' is interpreted as a tab, '\ooo' is interpreted as an octal value (where, ooo is one to three octal digits), and spaces are taken literally. For example:

will result in

Function arguments may be macros or functions themselves. So,

will yield all object files the current target depends on, separated by a newline string.

The protect function adds one level of quoting. This function has one argument which can contain white space. If the argument contains any white space, single quotes, double quotes, or backslashes, it is enclosed in double quotes. In addition, any double quote or backslash is escaped with a backslash.

Example:

will yield

The exist function expands to its second argument if the first argument is an existing file or directory.

Example:

When the file test.c exists it will yield:

When the file test.c does not exist nothing is expanded.

The nexist function is the opposite of the exist function. It expands to its second argument if the first argument is not an existing file or directory.

Example:

Targets

A target entry in the makefile has the following format:

Any line which does not have leading white space (other than macro definitions) is a 'target' line. Target lines consist of one or more filenames (or macros which expand into same) called targets, followed by a colon (:). The ':' is followed by a list of dependent files. The dependency list may be terminated with a semicolon (;) which may be followed by a rule or shell command.

Special allowance is made on PC for the colons which are needed to specify files on other drives, so for example, the following will work as intended:

If a target is named in more than one target line, the dependencies are added to form the target's complete dependency list.

The dependents are the ones from which a target is constructed. They in turn may be targets of other dependents. In general, for a particular target file, each of its dependent files is 'made', to make sure that each is up to date with respect to it's dependents.

The modification time of the target is compared to the modification times of each dependent file. If the target is older, one or more of the dependents have changed, so the target must be constructed. Of course, this checking is done recursively, so that all dependents of dependents of dependents of ... are up-to-date.

To reconstruct a target, mk51 expands macros and functions, strips off initial white space, and either executes the rules directly, or passes each to a shell or COMMAND.COM for execution.

For target lines, macros and functions are expanded on input. All other lines have expansion delayed until absolutely required (i.e. macros and functions in rules are dynamic).

Special Targets

.DEFAULT:
The rule for this target is used to process a target when there is no other entry for it, and no implicit rule for building it. mk51 ignores all dependencies for this target.

.DONE: This target and its dependencies are processed after all other targets are built.

.IGNORE: Non-zero error codes returned from commands are ignored. Encountering this in a makefile is the same as specifying -i on the command line.

.INIT: This target and its dependencies are processed before any other targets are processed.

.SILENT: Commands are not echoed before executing them. Encountering this in a makefile is the same as specifying -s on the command line.

.SUFFIXES:
The suffixes list for selecting implicit rules. Specifying this target with dependents adds these to the end of the suffixes list. Specifying it with no dependents clears the list.

.PRECIOUS:
Dependency files mentioned for this target are not removed. Normally, mk51 removes a target file if a command in its construction rule returned an error or when target construction is interrupted.

Rules

A line in a makefile that starts with a TAB or SPACE is a shell line or rule. This line is associated with the most recently preceding dependency line. A sequence of these may be associated with a single dependency line. When a target is out of date with respect to a dependent, the sequence of commands is executed. Shell lines may have any combination of the following characters to the left of the command:

@ will not echo the command line, except if -n is used.

- mk51 will ignore the exit code of the command, i.e. the ERRORLEVEL of MS-DOS. Without this, mk51 terminates when a non-zero exit code is returned.

+ mk51 will use a shell or COMMAND.COM to execute the command.

If the '+' is not attached to a shell line, but the command is a DOS command or if redirection is used (<, |, >), the shell line is passed to COMMAND.COM anyway. For Unix, redirection, backquote (`) parentheses and variables force the use of a shell.

You can force mk51 to execute multiple command lines in one shell environment. This is accomplished with the token combination ';\'.

Example:

The ';' must always directly be followed by the '\' token. Whitespace is not removed when it is at the end of the previous command line or when it is in front of the next command line. The use of the ';' as an operator for a command (like a semicolon ';' separated list with each item on one line) and the '\' as a layout tool is not supported, unless they are separated with whitespace.

mk51 can generate inline temporary files. If a line contains '<<WORD' then all subsequent lines up to a line starting with WORD, are placed in a temporary file. Next, '<<WORD' is replaced with the name of the temporary file.

No whitespace is allowed between '<<' and 'WORD'.

Example:

The four lines between the tags (EOF) are written to a temporary file (e.g. "\tmp\mk2"), and the command line is rewritten as "link51 @\tmp\mk2".

Implicit Rules

Implicit rules are intimately tied to the .SUFFIXES: special target. Each entry in the .SUFFIXES: list defines an extension to a filename which may be used to build another file. The implicit rules then define how to actually build one file from another. These files are related, in that they must share a common basename, but have different extensions.

If a file that is being made does not have an explicit target line, an implicit rule is looked for. Each entry in the .SUFFIXES: list is combined with the extension of the target, to get the name of an implicit target. If this target exists, it gives the rules used to transform a file with the dependent extension to the target file. Any dependents of the implicit target are ignored.

If a file that is being made has an explicit target, but no rules, a similar search is made for implicit rules. Each entry in the .SUFFIXES: list is combined with the extension of the target, to get the name of an implicit target. If such a target exists, then the list of dependents is searched for a file with the correct extension, and the implicit rules are invoked to create the target.

Examples

This makefile says that prog.out depends on two files prog.obj and sub.obj, and that they in turn depend on their corresponding source files (prog.c and sub.c) along with the common file inc.h.

CSTART  =  $(PRODDIR)\lib\cstart.obj
LIB    =  $(PRODDIR)\lib\c51s.lib
CC51INC  =  $(PRODDIR)\include
export CC51INC
PATH  =  $(PRODDIR)\bin;$(PATH)
export PATH

prog.out:  prog.obj sub.obj
    link51 $(CSTART),prog.obj,sub.obj,$(LIB) to prog.out

prog.obj:  prog.c inc.h
    cc51 prog.c
    asm51 prog.src NOPRINT

sub.obj:  sub.c inc.h
    cc51 sub.c
    asm51 sub.src NOPRINT

The following makefile uses implicit rules (from mk51.mk) to perform the same job. It is assumed that the environment variables LIBDIR, CC51INC and PATH are set:

prog.out:  $(LIBDIR)\cstart.obj prog.obj sub.obj $(LIBDIR)\c51s.lib
prog.obj:  prog.c inc.h
sub.obj:  sub.c inc.h

Files

makefile Description of dependencies and rules.
Makefile Alternative to makefile, for Unix.
mk51.mk Default dependencies and rules.

Diagnostics

mk51 returns an exit status of 1 when it halts as a result of an error. Otherwise it returns an exit status of 0.

10.9 omf51

Name

omf51 translate a.out formatted files to absolute OMF51 format.

Syntax

omf51 [-r] ifile ofile
omf51 -V
omf51
-? ( UNIX C-shell: "-?" or -\? )

Description

omf51 formats a.out formatted files to files in the absolute OMF51-file format of Intel. The program can format the code part as well as the symbolic debug part. If the program is invoked in its most simple form:

code and symbolic debug information will be formatted. The -r option can be used to format the code part only.

Options

-r Format the code part only.

-V Display version information at stderr.

-? Display an explanation of options at stdout.

Diagnostics

Warnings:

Illegal memory type for section # number
Sections and segments have a memory type. If the formatter finds a type number outside the valid range, this warning is generated.

Section type mismatch for section # number
The symbol type conflicts with the memory type of the section it belongs to.

Error messages:

Cannot open ifile for input
The input file is not present or cannot be opened for reading.

Cannot open ofile for output
The output filename is illegal or the file may not be written in the directory specified.

Input is not an a.out-file
The input file is in the wrong format. Only files produced by the linker can be formatted.

Unexpected end of file on input
The input file is corrupted or cannot be read successfully.

Memory allocation failed (range records)
A request for dynamic memory failed. This occurred while reading the range records of the a.out file.

Memory allocation failed (symbol record buffers)
A request for dynamic memory failed. This occurred while reading the symbol records of the a.out file.

Language not equal to PL/M-51
Conversion of high language debug information can only be done for PL/M-51 generated files.

Nesting of procedures too deep
The conversion program uses a stack to maintain the declaration sequence of procedure names in the PL/M-51 program. If this program contains a deeply nested declarations, the stack overflows. The maximum stack depth is 32.

Syntax error
omf51 expects the symbolic debug records in a predefined sequence. If symbolic debug records appear in an unexpected order this error message is displayed.

Internal errors:

seek error
A search request to an offset in the input file failed.

error in start position
The start position of the code part in the input file is outside the valid range.

inconsistent range of records
The size of a code range conflicts with the size of the segment it belongs to.

Write error (symbol records, type: num)
An attempt to write a symbol record in the OMF51-file failed.

10.10 srec51

Name

srec51 format object code into Motorola S format

Syntax

srec51 [-lcount] [-z] [-w] [-ssectlist] [-caddress] [-r1] [-r2] [-r3]
[-aaddress] [-n] [-nh] [-nt] [-poffset [-ehex]] [infile]
[[-o] outfile]

srec51 -V
srec51 -?
( UNIX C-shell: "-?" or -\? )

Description

srec51 formats object files and executable files to Motorola S format records. Hexadecimal numbers A to F are always generated as capitals.

Empty sections in the input file are skipped. No empty records are generated for empty sections.

The program can format records to Motorola S1 S2 and S3 format.

Addresses that lie between sections are not filled in.

The output does not contain symbol information.

There is no need to place the input and output file names at the end of the command line. If data is to be read from standard input and the output is not standard output, the output file must be specified with the -o option.

If only one filename is given, it is assumed that it is the name of the input file, hence output is written to standard output.

It is also possible to omit both the input filename and output filename. In that case standard input and standard output are used.

Options

Options must be separated by a blank and start with a minus sign (-). Decimal and hexadecimal arguments should be concatenated directly to the option letter.

Options may be specified in any order.

Output filenames should be separated from the -o option letter by a blank.

Example:

The next example gives the same result:

-r1 Output of Motorola S1 data records, for 16 bits addresses. This is the default record type.

-r2 Output of Motorola S2 records, for 24 bits addresses.

-r3 Output of Motorola S3 records, for 32 bits addresses.

-lcount Number of character pairs in the output record. The number of characters in a line is given by count * 2 + 4. The default count is 32.

-z Do not output records with zeros (0x00) only.

-ssectlist sectlist is a list of section numbers that must be written to output. The section numbers must be separated by commas. Note: section numbers start at 0 and can be found with the dmp51 utility.

-poffset offset is the offset in a section at which the output must start. If no section number is specified with the -s option, then bytes are skipped in the first record found. The user should be aware of the fact that there is no detection of skipping an entire section in a file. The -p option may not occur more than once in a command line. Warning: sections are adjacent in the input file, but do not have to be contiguous in memory!

-ehex hex is the length of the data output (must be used in combination with -p option). The user must have a clear view of the sizes and base addresses of the sections when he uses the -p and -e options. Example:

-aaddress address specifies the address that is to be added to the address of any data record.

-caddress This option specifies the start address which is loaded into the processor. The start address is placed in the termination record.

-n Suppress header (S0), and termination records (S7, S8 or S9).

-nh No output of header record.

-nt No output of termination record.

-o outfile outfile is the name of the file to which output is written. This option must be used if the input is standard input and the output must be written in a file.

-w Select word address count instead of byte address count.

-V Display version information at stderr.

-? Display an explanation of options at stdout.


Copyright © 2002 Altium BV