Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
71
Добавлен:
14.04.2015
Размер:
2.03 Mб
Скачать

266 Chapter 9. Linker/Locator

 

 

Linking Programs

 

9

 

 

The Lx51 linker/locater is invoked by typing the program name at the Windows

 

command prompt. On this command line, you must include the name of the

 

 

assembler source file to be translated, as well as any other necessary assembler

 

 

 

controls required to translate your source file. The format for the Lx51

 

 

command line is:

 

 

 

 

 

 

 

 

 

 

BL51

inputlist TO

outputfile

controls

 

 

LX51

inputlist TO

outputfile

controls

 

 

L251

inputlist TO

outputfile

controls

 

 

or

 

 

 

 

 

 

 

 

 

 

 

BL51

@commandfile

 

 

 

 

LX51

@commandfile

 

 

 

 

L251

@commandfile

 

 

where

inputlist is a list of the object files, separated by commas, for the linker/locator to include in the outputfile. The inputlist can contain files from Ax51, Cx51, PL/M-51 and library files. For library files you may force the inclusion of modules by specifying the module names in parentheses. The format of the inputlist is described below.

outputfile is the name of the absolute object file that the linker/locator creates. If no outputfile is specified on the command line, the first filename in the input list is used. The basename of the outputfile is also the default name for the map file.

controls are commands and parameters that control the operation of the Lx51 linker/locator.

commandfile is the name of a command input file that may contain an

inputlist, outputfile, and controls. The text in a

commandfile has the same format as the standard command line and is produced by any standard ASCII text editor. Newline characters and comments a commandfile are ignored. Lx51 interprets the first filename preceded by an at sign (@) as a

commandfile.

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

267

 

 

The inputlist uses the following general format:

filename (modulename , … ) , …

9

 

where

filename is the name of an object file created by Ax51, Cx51, or Intel PL/M-51 or a library file created by the LIBx51 library manager. The filename must be specified with its file extension. Object files use the extension .OBJ. Library files use the extension .LIB.

modulename is the name of an object module in the library file. The modulename may only be used after the name of a library file. The modulenames must be specified in parentheses after the filename. Multiple modulenames may be separated by commas.

268 Chapter 9. Linker/Locator

Command Line Examples

9 The following examples are proper command lines for the Lx51 linker/locator.

BL51 C:\MYDIR\PROG.OBJ TO C:\MYDIR\PROG.ABS

In this example, only the input file, C:\MYDIR\PROG.OBJ, is processed and the absolute object file generated is stored in the output file C:\MYDIR\PROG.ABS.

LX51 SAMPLE1.OBJ, SAMPLE2.OBJ, SAMPLE3.OBJ TO SAMPLE.ABS

In this example, the files SAMPLE1.OBJ, SAMPLE2.OBJ, and SAMPLE3.OBJ are

linked and absolute object file that is generated is stored in the file

SAMPLE.ABS.

L251 PROG1.OBJ, PROG2.OBJ, UTILITY.LIB

In this example, unresolved external symbols are resolved with the public symbols from the library file UTILITY.LIB. The modules required from the library are linked automatically. Modules from the library that are not referenced are not included in the generated absolute object file.

BL51 PROG1.OBJ, PROG2.OBJ, UTILITY.LIB (FPMUL, FPDIV)

In this example, unresolved external symbols are resolved with the public symbols from the library file UTILITY.LIB. The modules required from the library are linked automatically. In addition, the FPMUL and FPDIV modules are included whether they are needed or not. Other modules from the library that are not referenced are not included in the generated absolute object file.

LX51 @PROJECT.LIN

Content of the file PROJECT.LIN:

PROG1.OBJ,

/* Program Module 1

*/

PROG2.OBJ,

// program module 2

 

UTILITY.LIB (FPMUL, FPDIV)

; include always FPMUL and FPDIV

This is example is the same as the example before, but uses a command input file that includes comments.

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

269

 

 

Control Linker Input with µVision2

The C and assembler source files that are part of a µVision2 project are

9

translated when you build your application. The object files generated are then

supplied as linker input file by the µVision2 build process. However you may also include object and library files as part of a µVision2 project in the same way as you include source files. You may set additional linker options for a file or file group using the Options Properties dialog. For detailed information refer to the Getting Started and Creating Applications User’s Guide.

ERRORLEVEL

After linking, the Lx51 linker/locator sets the ERRORLEVEL to indicate the status of the linking process. The Lx51 linker/locater and the other utilities generate the same ERRORLEVEL values as the Ax51 macro assembler. Refer to “ERRORLEVEL” on page 197 for more information.

Output File

The Lx51 linker/locator creates an output file using the input object files that you specify on the command line. The output file is an absolute object file that may be loaded into debugging tools like the µVision2 Debugger or may be converted into a Intel HEX for PROM programming.

Соседние файлы в папке HLP