- •Chapter 1. Introduction
- •How to Develop A Program
- •What is an Assembler?
- •Modular Programming
- •Modular Program Development Process
- •Segments, Modules, and Programs
- •Translate and Link Process
- •Filename Extensions
- •Program Template File
- •Chapter 2. Architecture Overview
- •Memory Classes and Memory Layout
- •Classic 8051
- •Extended 8051 Variants
- •Philips 80C51MX
- •Intel/Atmel WM 251
- •CPU Registers
- •CPU Registers of the 8051 Variants
- •CPU Registers of the Intel/Atmel WM 251
- •Program Status Word (PSW)
- •Instruction Sets
- •Opcode Map
- •8051 Instructions
- •Additional 251 Instructions
- •Additional 80C51MX Instructions via Prefix A5
- •Chapter 3. Writing Assembly Programs
- •Assembly Statements
- •Directives
- •Controls
- •Instructions
- •Comments
- •Symbols
- •Symbol Names
- •Labels
- •Operands
- •Special Assembler Symbols
- •Immediate Data
- •Memory Access
- •Program Addresses
- •Expressions and Operators
- •Numbers
- •Characters
- •Character Strings
- •Location Counter
- •Operators
- •Expressions
- •Chapter 4. Assembler Directives
- •Introduction
- •Segment Directives
- •Location Counter
- •Generic Segments
- •Stack Segment
- •Absolute Segments
- •Default Segment
- •SEGMENT
- •RSEG
- •BSEG, CSEG, DSEG, ISEG, XSEG
- •Symbol Definition
- •CODE, DATA, IDATA, XDATA
- •esfr, sfr, sfr16, sbit
- •LIT (AX51 & A251 only)
- •Memory Initialization
- •DD (AX51 & A251 only)
- •Reserving Memory
- •DBIT
- •DSW (AX51 & A251 only)
- •DSD (AX51 & A251 only)
- •Procedure Declaration (AX51 & A251 only)
- •PROC / ENDP (AX51 & A251 only)
- •LABEL (AX51 and A251 only)
- •Program Linkage
- •PUBLIC
- •EXTRN / EXTERN
- •NAME
- •Address Control
- •EVEN (AX51 and A251 only)
- •USING
- •Other Directives
- •_ _ERROR_ _
- •Chapter 5. Assembler Macros
- •Standard Macro Directives
- •Defining a Macro
- •Parameters
- •Labels
- •Repeating Blocks
- •REPT
- •IRPC
- •Nested Definitions
- •Nested Repeating Blocks
- •Recursive Macros
- •Operators
- •NUL Operator
- •& Operator
- •< and > Operators
- •% Operator
- •;; Operator
- •! Operator
- •Invoking a Macro
- •C Macros
- •C Macro Preprocessor Directives
- •Stringize Operator
- •Predefined C Macro Constants
- •Examples with C Macros
- •C Preprocessor Side Effects
- •Chapter 6. Macro Processing Language
- •Overview
- •Creating and Calling MPL Macros
- •Creating Parameterless Macros
- •MPL Macros with Parameters
- •Local Symbols List
- •Macro Processor Language Functions
- •Comment Function
- •Escape Function
- •Bracket Function
- •METACHAR Function
- •Numbers and Expressions
- •Numbers
- •Character Strings
- •SET Function
- •EVAL Function
- •Logical Expressions and String Comparison
- •Conditional MPL Processing
- •IF Function
- •WHILE Function
- •REPEAT Function
- •EXIT Function
- •String Manipulation Functions
- •LEN Function
- •SUBSTR Function
- •MATCH Function
- •Console I/O Functions
- •Advanced Macro Processing
- •Literal Delimiters
- •Blank Delimiters
- •Identifier Delimiters
- •Literal and Normal Mode
- •MACRO Errors
- •Chapter 7. Invocation and Controls
- •Environment Settings
- •Running Ax51
- •ERRORLEVEL
- •Output Files
- •Assembler Controls
- •Controls for Conditional Assembly
- •Conditional Assembly Controls
- •Chapter 8. Error Messages
- •Fatal Errors
- •Non–Fatal Errors
- •Chapter 9. Linker/Locator
- •Overview
- •Combining Program Modules
- •Segment Naming Conventions
- •Combining Segments
- •Locating Segments
- •Overlaying Data Memory
- •Resolving External References
- •Absolute Address Calculation
- •Generating an Absolute Object File
- •Generating a Listing File
- •Bank Switching
- •Using RTX51, RTX251, and RTX51 Tiny
- •Linking Programs
- •Command Line Examples
- •Control Linker Input with µVision2
- •ERRORLEVEL
- •Output File
- •Linker/Locater Controls
- •Locating Programs to Physical Memory
- •Classic 8051
- •Extended 8051 Variants
- •Philips 80C51MX
- •Intel/Atmel WM 251
- •Data Overlaying
- •Program and Data Segments of Functions
- •Using the Overlay Control
- •Tips and Tricks for Program Locating
- •Locate Segments with Wildcards
- •Special ROM Handling (LX51 & L251 only)
- •Bank Switching
- •Common Code Area
- •Code Bank Areas
- •Bank Switching Configuration
- •Configuration Examples
- •Control Summary
- •Listing File Controls
- •Output File Controls
- •Segment and Memory Location Controls
- •High-Level Language Controls
- •Error Messages
- •Warnings
- •Non-Fatal Errors
- •Fatal Errors
- •Exceptions
- •Chapter 10. Library Manager
- •Using LIBx51
- •Interactive Mode
- •Create Library within µVision2
- •Command Summary
- •Creating a Library
- •Adding or Replacing Object Modules
- •Removing Object Modules
- •Extracting Object Modules
- •Listing Library Contents
- •Error Messages
- •Fatal Errors
- •Errors
- •Chapter 11. Object-Hex Converter
- •Using OHx51
- •OHx51 Command Line Examples
- •Creating HEX Files for Banked Applications
- •OHx51 Error Messages
- •Using OC51
- •OC51 Error Messages
- •Intel HEX File Format
- •Record Format
- •Data Record
- •Extended 8086 Segment Record
- •Extended Linear Address Record
- •Example Intel HEX File
- •Appendix A. Application Examples
- •ASM – Assembler Example
- •Using A51 and BL51
- •Using AX51 and LX51
- •Using A251 and L251
- •CSAMPLE – C Compiler Example
- •Using C51 and BL51
- •Using C51 and LX51
- •Using C251 and L251
- •BANK_EX1 – Code Banking with C51
- •Using C51 and BL51
- •Using C51 and LX51
- •BANK_EX2 – Banking with Constants
- •Using C51 and BL51
- •Using C51 and LX51
- •Using BL51
- •Using C51 and LX51
- •Philips 80C51MX – Assembler Example
- •Philips 80C51MX – C Compiler Example
- •Appendix B. Reserved Symbols
- •Appendix C. Listing File Format
- •Assembler Listing File Format
- •Listing File Heading
- •Source Listing
- •Macro / Include File / Save Stack Format
- •Symbol Table
- •Listing File Trailer
- •Appendix D. Assembler Differences
- •Differences Between A51 and A251/AX51
- •Differences between A51 and ASM51
- •Differences between A251/AX51 & ASM51
- •Glossary
- •Index
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.
