- •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
388 |
Chapter 11. Object-Hex Converter |
|
|
Using OHx51
To invoke OHx51 from the command prompt, type the program name along with the name of the absolute object file. The command line format for the OHx51 utilities is:
OH51 abs_file HEXFILE (file)
OHX51 abs_file HEXFILE (file) H386 RANGE (start–end) OFFSET (offset)
OH251 abs_file HEXFILE (file) H386 RANGE (start–end) OFFSET (offset)
11 |
where |
|
|
|
|
abs_file |
is the name of the absolute object file that is generated by the |
|
|||
|
Lx51 linker/locator. |
|
|
|
|
|
|
|
|
|
|
|
file |
is the name of the Intel HEX file to generate. By default, the |
|
||
|
|
HEX file name is the name of the |
abs_file with the |
|
|
|
|
extension .HEX. |
|
|
|
|
H386 |
specifies Intel HEX-386 format for the Intel HEX file. This |
|
||
|
|
format is automatically used, if the specified address range is |
|
||
|
|
more than 64KBytes. |
|
|
|
|
start-end |
specifies the address range of the |
abs_file that should be |
|
|
|
|
converted to the Intel HEX file. The default range depends on |
|
||
|
|
the device you are using and is listed in the following table: |
|
||
|
|
|
|
|
|
|
|
OHx51 Converter (Architecture) |
|
Address Range |
|
|
|
OHX51 (Classic, and Extended 8051) |
|
C:0x0000 - C:0xFFFF |
|
|
|
Note: For code banking applications OHX51 |
|
|
|
|
|
the default setting converts the complete |
|
|
|
|
|
content into an Intel HEX-386 format. |
|
|
|
|
|
OHX51 (Philips 80C51MX) |
|
0x800000 - 0x80FFFF |
|
|
|
OH251 (Intel/Atmel WM 251) |
|
0xFF0000 - 0xFFFFFF |
|
|
offset |
specifies an offset which is added to the address stored in |
|
||
|
|
the abs_file. |
|
|
|
Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
389 |
|
|
OHx51 Command Line Examples
The following command generates an Intel HEX-386 file for a 251 device. The address range 0xFE0000 - 0xFFFFFF should be converted. The offset 0xFE0000 is subtracted to get an Intel HEX file that can be directly programmed into an EPROM that is mapped to the address space 0xFE0000 - 0xFFFFFF in the 251 address space.
OH251 MYPROG RANGE (0xFE0000-0xFFFFFF) OFFSET (-0xFE0000)
The next example generates an Intel HEX file for a banked application with a |
|
||
classic 8051 device. Only the code bank 0 should be converted. The file format |
11 |
||
used will be the standard Intel HEX format. |
|||
|
|
||
OHX51 PROG |
RANGE (B:0-B:0xFFFF) |
|
|
The command below generates an Intel HEX-386 file for a Philips 80C51MX |
|
||
|
|||
device. The OFFSET control is used to create an output file that can be directly |
|
||
programmed into an EPROM. |
|
||
|
|
|
|
OHX51 MYAPP |
RANGE (0x800000-0x81FFFF) OFFSET (-0x800000) |
|
|
With the next command line, the constants stored in the XDATA space are converted into an Intel HEX file.
OHX51 MYPROG RANGE (X:0-X:FFFF)
Creating HEX Files for Banked Applications
For the BL51 linker/locater the OC51 Banked Object File Converter described on page 392 is used to split banked object files into standard object files that contain a 64KB code bank. These files can be converted with OH51 into HEX files that store the content of a 64KB bank. These files are programmed separately into the corresponding physical address space of the EPROM.
For the extended LX51 linker/locater the OHX51 object hex converter generates in the default setting and Intel HEX-386 file that contains the common area and all the code banks. If code bank 0 does not exist in your application, OHX51 will skip this memory area.
Examples: |
|
The figure below shows the HEX |
The following figure shows the |
390 |
Chapter 11. Object-Hex Converter |
|
|
file content for the example “Banking With Four 64 KByte Banks” on page 299.
|
|
|
|
Code Bank #3 |
|
|
|
|
|
|
|
|
30000H |
|
|
|
|
|
|
Code Bank #2 |
|
||
|
|
|
|
|
|
|
20000H |
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
11 |
|
|
|
Code Bank #1 |
|
10000H |
|
|
|
|
|
|
|
Code Bank #0 |
|
||
|
0 |
|
|
||
|
|||||
|
|
|
|
||
|
|
|
|
||
HEX file content for the example “Banking With Common Area” on page 303.
Code Bank #7
38000H
Code Bank #6
30000H
Code Bank #5
28000H
Code Bank #4
20000H
Code Bank #3
18000H
Code Bank #2
10000H
Code Bank #1
8000H
Common Area
0
OHx51 Error Messages
The following tables list error and warning messages of OHx51. Each message includes a brief description of the reason for the error or warning condition.
Error Message
***ERROR, INVALID RECORD-TYPE ENCOUNTERED
The absolute object file contains an invalid record type.
***FATAL, INCONSISTENT OBJECT FILE
The input file has an invalid format.
***ERROR, ARGUMENT TOO LONG
An argument in the command line is too long.
***ERROR, DELIMITER '(' AFTER PARAMETER EXPECTED
The command-line parameter must be followed by an argument enclosed in parentheses ().
*** ERROR, DELIMITER ')' AFTER PARAMETER EXPECTED
The command-line parameter must be followed by an argument enclosed in parentheses ().
*** ERROR, UNKNOWN CONTROL:
The specified command-line parameter is unrecognized.
***ERROR, RESPECIFIED CONTROL, IGNORED
The indicated command-line control was specified twice.
***ERROR, CAN’T OPEN FILE filename
The specified file cannot be open for read.
*** ERROR, CAN’T CREATE FILE filename
The specified file cannot be open for write.
Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
391 |
|
|
Error Message
*** I/O-ERROR ON FILE filename
A read/write error occurred during access of the specified file.
*** ERROR: PREMATURE END OF FILE ON filename
The input file does not end correctly. This is usually a result of a previous fatal error of an translator or linker/locater.
*** ERROR: MORE THAN 512 CLASSES ON filename
The input file contains more than 512 memory classes. This is the limit of OHx51.
*** ERROR, NON-NULL ARGUMENT EXPECTED
An argument is missing.
|
|
|
11 |
|
Warning Message |
|
|
|
|
|
|
|
|
|
|
WARNING: <PUBDEF> HEX-FILE WILL BE INVALID
The absolute object file still contains public definitions. This warning usually indicates that the object file has not been processed by the Lx51 linker/locator. The hex file that is produced may be invalid.
WARNING: <EXTDEF> UNDEFINED EXTERNAL
The absolute object file still contains external definitions. This warning usually indicates that the object file has not been processed by the Lx51 linker/locator. The hex file that is produced may be invalid.
WARNING: <FIXUPP> HEX-FILE WILL BE INVALID
The absolute object file still contains fix-ups. This warning usually indicates that the object file has not been processed by the L251 linker/locator. The hex file that is produced may be invalid.
