- •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
32 |
Chapter 2. Architecture Overview |
|
|
Philips 80C51MX
The Philips 80C51MX provides a unified 16 MB address space. New instructions can access up to 16MB memory whereby CODE and XDATA space are mapped into one single address space. The stack pointer can be configured as 16-Bit stack pointer that addresses the on-chip RAM area in the EDATA memory class. The following table shows the memory classes used for
2 programming the 80C51MX architecture. These memory classes are available when you are using the AX51 macro assembler and the LX51 linker/locater.
Memory Class |
Address Range |
Description |
DATA |
7F:0000 – 7F:007F |
Direct addressable on-chip RAM. |
BIT |
7F:0020 – 7F:002F |
Bit-addressable RAM; accessed bit instructions. |
IDATA |
7F:0000 – 7F:00FF |
Indirect addressable on-chip RAM; can be |
|
|
accessed with @R0 or @R1. |
EDATA |
7F:0000 – 7F:FFFF |
Complete on-chip RAM; can be used as stack |
|
|
space or can be accessed with @PR0 or |
|
|
@PR1. |
XDATA |
00:0000 – 00:FFFF |
64 KB RAM (read/write access). Accessed with |
|
|
MOVX instruction. |
HDATA |
00:0000 – 7F:FFFF |
8 MB RAM (read/write access). Accessed with |
|
|
MOVX instruction and extended DPTR. |
CODE |
80:0000 – 80:FFFF |
Classic 8051 compatible 64 KB ROM (only read |
|
|
access possible). Used for executable code or |
|
|
constants. |
ECODE |
80:0000 – 80:FFFF |
8 MB ROM (only read access possible). |
HCONST |
80:0000 – 80:FFFF |
8 MB ROM. Same as ECODE, this class is |
|
|
used by the CX51 Compiler for constants. |
BANK 0 |
80:0000 – 0xBF:FFFF |
Used by the CX51 Compiler to expand the |
… BANK 63 |
B0:0000 – B63:FFFF |
program memory to more than 64KB. Refer to |
|
|
“Philips 80C51MX” on page 277 for more |
|
|
information. |
|
|
|
NOTES
Colons are used to improve the readability only. The addresses are entered in the tools as numbers without colon.
The memory prefixes D: I: X: C: B0: .. B31: cannot be used at Ax51 assembler level. The memory prefix is only listed for better understanding. The Lx51 linker/locater and several Debugging tools, for example the µVision2 Debugger, are using memory prefixes to identify the memory class of the address.
Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
33 |
|
|
80C51MX Memory Layout
The Philips 80C51MX memory layout, shown in the following figure, provides a universal memory map that includes all memory types in a single 16MB address region. The memory layout of the Philips 80C51MX is shown below:
|
|
|
DATA |
|
|
|
2 |
FF:FFFF |
|
7F:FFFF |
FF |
|
|
|
|
|
|
|
|
|
98 |
||
|
|
|
|
|
|||
|
|
|
|
|
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SFR |
|
|
|
|
|
|
|
SPACE |
|
|
|
|
|
|
|
DATA |
|
|
|
|
|
|
|
|
|
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ECODE |
|
|
80 |
8MB |
|
|
|
|
|
DATA |
|
|
|
80 |
DA |
|
|
|
TA |
|
|
7F: |
|
|
|
007F |
|
|
EDATA |
|
|
|
64KB |
|
|
CODE |
7F:00FF |
|
|
(= Bank 0) |
|
|
|
|
|
|
|
64KB |
|
|
|
80:0000 |
|
|
|
7F:FFFF |
IDATA |
|
|
|
|
|
|
EDATA |
256 Bytes |
|
|
|
DATA |
|
|
64KB |
|
|
|
|
128 Bytes |
|
|
|
|
|
|
7F:0000 |
|
|
|
|
7F:0080 |
|
|
|
|
|
2F |
HDATA |
|
|
8051 |
8MB |
|
|
Bitspace |
|
DATA |
|
20 |
|
|
1F |
|
00:FFFF |
128 Bytes |
|
|
|
|
4 |
|
|
|
|
|
XDATA |
|
|
Register |
|
|
Banks |
|
64KB |
|
|
|
|
|
|
|
00:0000 |
7F:0000 |
|
0 |
The 80C51MX offers new CPU instructions that provide a new addressing mode, called Universal Pointer addressing. Two Universal Pointer registers PR0 and PR1 are available. PR0 is composed of registers R1, R2, and R3. PR1 is composed of registers R5, R6, and R7. These new Universal Pointer registers hold a 24-bit address that is used together with the EMOV instruction to address the complete 16MB memory.
34 Chapter 2. Architecture Overview
|
Intel/Atmel WM 251 |
|
Also the 251 architecture is a superset of the classic 8051 architecture. The 251 |
|
is the most advanced variant and provides the following key features: |
|
Completely code compatible with the standard 8051 microcontroller. |
2 |
Powerful 8/16/32-bit instructions and flexible 8/16/32-bit registers. |
16MB linear address space and CPU support for 16-bit and 32-bit pointers. |
True stack-oriented instructions with 16-bit stack pointer.
The following table shows the memory classes used for programming a 251 microcontroller. These memory classes are available when you are using the A251 macro assembler and the L251 linker/locater.
Memory |
Address Range |
Description |
Class |
|
|
DATA |
00:0000 - 00:007F |
Direct addressable on-chip RAM. |
BIT |
00:0020 - 00:002F |
8051 compatible bit-addressable RAM; can be accessed |
|
|
with short 8-bit addresses. |
IDATA |
00:0000 - 00:00FF |
Indirect addressable on-chip RAM; can be accessed with |
|
|
@R0 or @R1. |
EDATA |
00:0000 – 00:FFFF |
Extended direct addressable memory area; can be |
|
|
accessed with direct 16-bit addresses available on the 251. |
ECONST |
00:0000 – 00:FFFF |
Same as EDATA - but allows the definition of ROM |
|
|
constants. |
EBIT |
00:0020 - 00:007F |
Extended bit-addressable RAM; can be accessed with the |
|
|
extended bit addressing mode available on the 251. |
XDATA |
01:0000 – 01:FFFF |
8051 compatible DATA space. Can be mapped on the 251 |
|
(default space) |
to any 64 KB memory segment. Accessed with MOVX |
|
|
instruction. |
HDATA |
00:0000 – FF:FFFF |
Full 16 MB address space of the 251. Accessed with MOV |
|
|
@DRK instructions. This space is used for RAM areas. |
HCONST |
00:0000 – FF:FFFF |
Same as HDATA - but allows the definition of ROM |
|
|
constants. |
ECODE |
00:0000 – FF:FFFF |
Full 16 MB address space of the 251; executable code |
|
|
accessed with ECALL or EJMP instructions. |
CODE |
FF:0000 - FF:FFFF |
8051 compatible CODE space; used for executable code or |
|
(default space) |
RAM constants. Can be located with L251 to any 64 KB |
|
|
segment |
CONST |
FF:0000 - FF:FFFF |
Same as CODE - but can be used for ROM constants only. |
|
(default space) |
|
|
|
|
Colons are used to improve the readability only.
The addresses are entered in the tools as numbers without colon.
Keil Software — A51/AX51/A251 Macro Assembler and Utilities |
35 |
|
|
251 Memory Layout
The following figure shows the memory layout of the 251 architecture.
HDATA ECODE HCONST 16 MB
FF:FFFF |
00:FFFF |
DATA |
|
|
|
FF |
|
|
|
F8 |
2 |
CODE |
|
98 |
|
default page |
|
||
|
|
|
FF:0000 |
|
SFR |
|
|
|
|
|
|
|
SPACE |
90 |
Reset Vector |
|
|
|
|
|
|
88 |
|
|
DATA |
|
|
|
80 |
80 |
|
|
|
|
|
|
00: |
|
|
|
007F |
|
|
EDATA |
|
EBIT |
|
64 KB |
00:0100 |
|
|
251 |
||
|
|
||
|
|
|
|
|
|
|
bitaddr. |
02:0000 |
|
|
|
|
|
IDATA |
|
XDATA |
|
256 Bytes |
|
|
DATA |
|
|
(default, |
|
|
|
|
128 BYTE |
|
|
SEGMENT |
|
|
|
|
|
|
|
mapable) |
|
00:0080 |
|
|
|
|
|
|
|
|
2F |
01:0000 |
|
|
8051 |
|
|
|
|
|
|
|
Bitspace |
|
|
DATA |
20 |
|
|
1F |
|
EDATA |
|
128 Bytes |
|
|
|
||
|
|
|
|
64 KB |
|
|
4 Register |
|
|
|
|
|
|
|
Banks |
00:0000 |
|
00:0000 |
0 |
The 251 completely supports all aspects of the classic 8051 memory layout and instruction set. Existing 8051 programs can be directly execute on the 251. The four 8051 memory spaces (DATA, IDATA, CODE and XDATA) are mapped into specific regions of the 16 MB address space.