- •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
Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
419 |
|
|
Macro / Include File / Save Stack Format
In the listing file, the assembler displays the macro nesting level, the include file level, and the level of the SAVE/RESTORE stack. These nesting levels are shown before and after the LINE number as shown in the following listing.
LOC |
OBJ |
|
LINE |
|
SOURCE |
|
|
|
|
|
|
1 |
|
$GEN |
; Enable Macro |
Listing |
|
|
|
|
2 |
|
|
|
|
|
|
|
|
3 |
|
MYMACRO |
MACRO |
|
; A sample macro |
|
|
|
4 |
|
|
INC |
A |
; Macro Level 1 |
|
|
|
5 |
|
|
MACRO2 |
|
|
|
|
|
6 |
|
|
ENDM |
|
|
|
|
|
7 |
|
|
|
|
|
|
|
|
8 |
|
MACRO2 |
MACRO |
|
; Macro 2 |
|
|
|
9 |
|
|
NOP |
|
; Macro Level 2 |
|
|
|
10 |
|
|
ENDM |
|
|
|
|
|
11 |
|
|
|
|
|
|
|
|
12 |
|
|
|
|
|
------ |
|
|
13 |
|
MYPROG |
SEGMENT |
CODE |
|
------ |
|
|
14 |
|
|
RSEG |
MYPROG |
|
|
|
|
15 |
|
|
|
|
|
000000 |
7400 |
|
16 |
|
|
MOV |
A,#0 |
|
|
|
|
17 |
|
|
MYMACRO |
|
|
000002 |
04 |
|
18+1 |
|
|
INC |
A |
; Macro Level 1 |
|
|
|
19+1 |
|
|
MACRO2 |
|
|
000003 |
00 |
|
20+2 |
|
|
NOP |
|
; Macro Level 2 |
|
|
|
21 |
|
$INCLUDE (MYFILE.INC) |
; A include file |
||
|
|
+1 |
22 |
|
; This is a comment |
; Include Level 1 |
||
|
|
+1 |
23 |
|
|
MACRO2 |
|
|
000004 |
00 |
+1 |
24+1 |
|
|
NOP |
|
; Macro Level 1 |
000005 |
7401 |
|
25 |
|
|
MOV |
A,#1 |
|
|
|
|
26 |
+1 |
$SAVE |
|
|
; Save Control |
|
|
|
27 |
+1 |
|
MYMACRO |
|
; SAVE Level 1 |
000007 |
04 |
|
28+1+1 |
|
INC |
A |
; Macro Level 1 |
|
|
|
|
29+1+1 |
|
MACRO2 |
|
|
|
000008 |
00 |
|
30+2+1 |
|
NOP |
|
; Macro Level 2 |
|
|
|
|
31 |
+1 |
$RESTORE |
|
|
|
000009 |
00 |
|
32 |
|
|
NOP |
|
|
|
|
|
33 |
|
|
END |
|
|
C
Symbol Table
The symbol table is a list of all symbols defined in the program along with the status information about the symbol. Any predefined symbols used will also be listed in the symbol table. If the XREF control is used, the symbol table will contain information about where the symbol was used in the program.
420 |
Appendix C. Listing File Format |
|
|
The status information includes a NAME field, a TYPE field, a VALUE field, and an
ATTRIBUTES field.
The TYPE field specifies the type of the symbol: ADDR if it is a memory address, NUMB if it is a pure number (e.g., as defined by EQU), SEG if it is a relocatable segment, and REG if a register. For ADDR and SEG symbols, the segment type is added.
The VALUE field shows the value of the symbol when the assembly was completed. For REG symbols, the name of the register is given. For NUMB and ADDR symbols, their absolute value (or if relocatable, their offset) is given, followed by A (absolute) or R (relocatable). For SEG symbols, the segment size
C is given here. Bit address and size are given by the byte part, a period (.), followed by the bit part. The scope attribute, if any, is PUB (public) or EXT (external). These are given after the VALUE field.
The ATTRIBUTES field contains an additional piece of information for some symbols: relocation type for segments, segment name for relocatable symbols.
Example Symbol Table Listing
SYMBOL TABLE LISTING |
|
|
|
|
|
------ ----- ------- |
|
|
|
|
|
N A M E |
T Y P E |
V A L U E |
ATTRIBUTES |
||
BITVAR . . . . . . |
B |
SEG |
000001H |
|
REL=UNIT, ALN=BIT |
DUMMY. . . . . . . |
D |
ADDR |
000000H |
R |
SEG=VAR1 |
PCONST . . . . . . |
C |
SEG |
00000DH |
|
REL=UNIT, ALN=BYTE |
PROG . . . . . . . |
C |
SEG |
00001BH |
|
REL=UNIT, ALN=BYTE |
PUTSTRING. . . . . |
C |
ADDR |
------- |
|
EXT |
PUT_CRLF . . . . . |
C |
ADDR |
------- |
|
EXT |
REPEAT . . . . . . |
C |
ADDR |
000010H |
R |
SEG=PROG |
SAMPLE . . . . . . |
|
|
|
|
|
STACK. . . . . . . |
I |
SEG |
000010H |
|
REL=UNIT, ALN=BYTE |
START. . . . . . . |
C |
ADDR |
000000H |
R |
SEG=PROG |
TXT. . . . . . . . |
C |
ADDR |
000000H |
R |
SEG=PCONST |
TXTBIT . . . . . . |
B |
ADDR |
0000H.0 |
R |
SEG=BITVAR |
VAR1 . . . . . . . |
D |
SEG |
000021H |
|
REL=UNIT, ALN=BYTE |
If the XREF control is used, then the symbol table listing will also contain all of the line numbers of each line of code that the symbol was used. If the value of the symbol was changed or defined on a line, then that line will have a hash mark
(#) following it. The line numbers are displayed in decimal.
Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
421 |
|
|
Listing File Trailer
At the end of the listing, the assembler prints a message in the following format:
REGISTER BANK(S) USED: [r r r r]
ASSEMBLY COMPLETE. |
(n) WARNING(S), (m) ERROR(S) |
where |
|
r |
are the numbers of the register banks used. |
n |
is the number of warnings found in the program. |
m |
is the number of errors found in the program. |
C
422 |
Appendix C. Listing File Format |
|
|
C