
- •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

394 Chapter 11. Object-Hex Converter
|
|
Intel HEX File Format |
||
|
|
The Intel HEX file is an ASCII text file with lines of text that follow the Intel |
||
|
|
HEX file format. Each line in an Intel HEX file contains one HEX record. |
||
|
|
These records are made up of hexadecimal numbers that represent machine |
||
|
|
language code and/or constant data. Intel HEX files are often used to transfer |
||
|
|
the program and data that would be stored in a ROM or EPROM. Most EPROM |
||
|
|
programmers or emulators can use Intel HEX files. |
||
|
|
Record Format |
|
|
11 |
|
|||
|
An Intel HEX file is composed of any number of HEX records. Each record is |
|||
|
|
made up of five fields that are arranged in the following format: |
||
|
|
|
|
|
|
|
:llaaaatt dd... cc |
|
|
|
|
Each group of letters corresponds to a different field, and each letter represents a |
||
|
|
single hexadecimal digit. Each field is composed of at least two hexadecimal |
||
|
|
digits—which make up a byte—as described below: |
||
|
: |
is the colon that starts every Intel HEX record. |
||
|
|
ll |
is the record-length field that represents the number of data |
|
|
|
|
bytes (dd) in the record. |
|
|
|
aaaa |
is the address field that represents the starting address for |
|
|
|
|
subsequent data in the record. |
|
|
|
tt |
is the field that represents the HEX record type, which may |
|
|
|
|
be one of the following: |
|
|
|
|
00 |
data record |
|
|
|
01 |
end-of-file record |
|
|
|
02 |
extended 8086 segment address record. |
|
|
|
04 |
extended linear address record. |
|
|
dd |
is a data field that represents one byte of data. A record may |
|
|
|
|
have multiple data bytes. The number of data bytes in the |
|
|
|
|
record must match the number specified by the ll field. |
|
|
|
cc |
is the checksum field that represents the checksum of the |
|
|
|
|
record. The checksum is calculated by summing the values |

Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
395 |
|
|
of all hexadecimal digit pairs in the record modulo 256 and taking the two’s complement.
Data Record
The Intel HEX file is made up of any number of data records that are terminated with a carriage return and a linefeed. Data records appear as follows:
:10246200464C5549442050524F46494C4500464C33
where: |
|
|
|
is the number of data bytes in the record. |
11 |
||
10 |
|||
2462 |
is the address where the data are to be located in memory. |
||
00 |
is the record type 00 (a data record). |
|
|
|
|||
464C...464C |
is the data. |
|
|
33 |
is the checksum of the record. |
|
End-of-File (EOF) Record
An Intel HEX file must end with an end-of-file (EOF) record. This record must have the value 01 in the record type field. An EOF record always appears as follows:
:00000001FF |
|
where: |
|
00 |
is the number of data bytes in the record. |
0000 |
is the address where the data are to be located in memory. The |
|
address in end-of-file records is meaningless and is ignored. An |
|
address of 0000h is typical. |
01 |
is the record type 01 (an end-of-file record). |
FF |
is the checksum of the record and is calculated as |
|
01h + NOT(00h + 00h + 00h + 01h). |

396 Chapter 11. Object-Hex Converter
Extended 8086 Segment Record
The Intel HEX contains extended 8086 segment records when the H86 directive is used. This record is used to specify an address offset (in 8086 paragraph form) for the following data records. Extended 8086 segment records appear as follows:
:02000002F0000C
|
where: |
|
|
|
02 |
is the number of data bytes in the record. |
|
11 |
|||
0000 |
is always 0 in a extended 8086 segment record. |
||
02 |
is the record type 02 (a extended 8086 segment record). |
||
|
F000 |
is the offset in 8086 paragraph notation (= 0x0F0000). |
|
|
|||
|
0C |
is the checksum of the record. |
Extended Linear Address Record
The Intel HEX contains extended linear address records when the H386 directive is used. This record is used to specify the two most significant bytes (bits 16 - 31) of the absolute address. This address offset is used for all following data records. Extended linear address records appear as follows:
:0200000400FFFB |
|
where: |
|
02 |
is the number of data bytes in the record. |
0000 |
is always 0 in a extended 8086 segment record. |
04 |
is the record type 04 (a extended linear address record). |
00FF |
is the high word of the address offset (= 0xFF0000). |
FB |
is the checksum of the record. |

Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
397 |
|
|
Example Intel HEX File
Following is an example of a complete Intel HEX file:
:0200000400FFFB
:03000000020003F8
:10000300758107758920758DFDD28E759852C20052
:0B00130090001E12003612002B80F53A
:0D001E00544553542050524F4752414D005D
:10002B00740D120047740A12004722200004E49357
:0C003B008001E06006120047A380F02264
:080047003099FDC299F59922E0
:00000001FF
11

398 |
Chapter 11. Object-Hex Converter |
|
|
11