📄 asem_51.doc
字号:
Examples: $NOMOD51 ;switch off 8051 SFR symbol definitions
$PAGELENGTH(60) ;set page length to 60 lines per page
$PW(80) ;set page width to 80 characters per line
$NOSYMBOLS ;no symbol table required
$NOTABS ;printer doesn't support tab characters
$DATE(2. 8. 95) ;date of latest version
$XREF ;generate a cross-reference listing
III.8.2 General Controls
------------------------
$EJECT Starts a new page in the list file.
The control has no effect, when the $NOPAGING control has
been specified.
$INCLUDE (file) Includes an external source file into the assembler program
just behind the $INCLUDE statement. If the include file
cannot be found in the default directory, the include file
path, specified with the /INCLUDES command line option, is
searched. Include files may also be nested.
$NOLIST After this control statement source code lines are no longer
listed, provided they do not contain errors, until the next
$LIST statement occurs.
$TITLE (string) Inserts a title string into the list file page header.
Titles may be truncated according to the specified (or
default) page width.
Default: ASEM-51 copyright information.
The control has no effect, when the $NOPAGING control has
been specified.
Examples: $NOLIST ;switch off listing
$INCLUDE (8052.MCU) ;include 8052 SFR symbol definition file
$LIST ;switch on listing
$TITLE (Computer-Controlled Combustion Unit for Motorcycles)
$EJ ;new page with new title
III.9 Predefined Symbols
------------------------
For easy access to the 8051 special function register and interrupt
addresses, ASEM-51 has a number of predefined (built-in) DATA, BIT and
CODE symbols.
These predefined symbols can be switched off with the $NOMOD51 control.
For detailed information on symbols and addresses refer to Appendix C.
III.10 Conditional Assembly
---------------------------
To support easy configuration control and maintenance of 8051 application
programs, the following fife meta instructions have been implemented for
conditional assembly:
IF <expr>
IFDEF <symbol>
IFNDEF <symbol>
ELSE
ENDIF
For the IF statement, conditional assembly works as follows:
When the expression <expr> in the IF statement is not equal to 0 (TRUE),
then the statements 1 to n are assembled and the statements n+1 to n+m
are ignored.
IF <expr>
<statement 1>
<statement 2> ;assembled when <expr> is TRUE
.
.
<statement n>
ELSE
<statement n+1>
<statement n+2> ;assembled when <expr> is FALSE
.
.
<statement n+m>
ENDIF
Should <expr> be equal to 0 (FALSE), it is exactly vice versa! That means
the statements 1 to n are ignored and the statements n+1 to n+m are
assembled.
This works also, when the IF or ELSE branches contain no statements at all.
When the ELSE branch doesn't enclose any statements, the whole construction
can be simplified to a special case:
IF <expr>
<statement 1>
<statement 2> ;assembled when <expr> is TRUE
.
.
<statement n>
ENDIF
Then the statements 1 to n are assembled, if <expr> is not equal to 0,
otherwise they are ignored.
The value of <expr> must be known on pass 1!
Example: TARGET EQU 0 ;configuration: 1 for application board
;-------------- 0 for evaluation board
IF TARGET
ORG 0 ;program start address of application board
ELSE
ORG 08000H ;program start address of evaluation board
ENDIF
The IFDEF and IFNDEF statements are working quite similar:
IFDEF <symbol>
.
ELSE
.
ENDIF
When the <symbol> is defined in the program, the statements in the IFDEF
branch are assembled, and those in the ELSE branch (if any) are ignored.
When the <symbol> is not defined in the program, it is exactly vice versa!
IFNDEF <symbol>
.
ELSE
.
ENDIF
When the <symbol> is defined in the program, the statements in the IFNDEF
branch are ignored, and those in the ELSE branch (if any) are assembled.
When the <symbol> is not defined in the program, it is vice versa!
Example: ;EVA_537 EQU 0 ;symbol undefined: 80C537 application board
;symbol defined: 80C537 evaluation board
IFNDEF EVA_537
CLOCK EQU 16 ;clock frequency of application board
CSEG AT 0 ;program start address of application board
ELSE
CLOCK EQU 12 ;clock frequency of evaluation board
CSEG AT 08000H ;program start address of evaluation board
ENDIF
Currently the program is configured for the application board version.
The <symbol> operands of the IFDEF and IFNDEF instructions must be either
undefined or defined on pass 1!
IF/IFDEF/IFNDEF...ELSE...ENDIF constructions may be nested to any depth!
IV. Compatibility with the Intel Assembler
==========================================
The ASEM-51 assembly language is a subset of the Intel standard, that
guarantees maximum compatibility with existing 8051 assembler sources.
It implements all 8051 instruction mnemonics as well as a useful subset
of the Intel pseudo instructions and assembler controls.
IV.1 Restrictions
-----------------
Since ASEM-51 generates an Intel-HEX file output instead of relocatable
object modules, the whole source code of an 8051 application program has to
reside in one single file. Consequently all pseudo instructions, that deal
with relocatable segments or external symbols, have not been implemented:
PUBLIC
EXTRN
SEGMENT
RSEG
The SET command cannot redefine special assembler symbols (e.g. registers)!
Macros are not supported!
Up to now only the following assembler controls and their abbreviations have
been implemented:
| primary controls abbrev. | general controls abbrev.
---------+-----------------------------------+-----------------------------
| $DATE (<string>) $DA | $EJECT $EJ
| $DEBUG $DB | $INCLUDE (<file>) $IC
| $NODEBUG $NODB | $LIST $LI
| $MOD51 $MO | $NOLIST $NOLI
Intel- | $NOMOD51 $NOMO | $TITLE (<string>) $TT
| $PAGING $PI |
controls | $NOPAGING $NOPI |
| $SYMBOLS $SB |
| $NOSYMBOLS $NOSB |
| $PAGELENGTH (<lines>) $PL |
| $PAGEWIDTH (<columns>) $PW |
---------+-----------------------------------+-----------------------------
ASEM-51 | $NOTABS ----- |
controls | $PHILIPS ----- |
IV.2 Extensions
---------------
Assembler controls need not start in column 1, but may be preceded by any
number of blanks and tabs. Primary controls may also be preceded by
$INCLUDE statements, provided the corresponding include files are only
containing other control statements.
Character strings may also be enclosed in double quotes.
The DATA symbol for the special function register PCON is predefined.
The bit operator '.' is allowed in all expressions, not only in those that
have to match the segment type BIT.
To support easy conditional assembly, the following fife meta instructions
have been implemented:
IF <expression>
IFDEF <symbol>
IFNDEF <symbol>
ELSE
ENDIF
IV.3 Further Differences
------------------------
To make semantics unique, especially the precedence of unary operators in
expressions is slightly different. Furthermore, expressions with a bit
operation "." evaluate to a BIT type result, not to NUMBER. This is described
in detail in chapters "III.4 Expressions" and "III.7 Segment Type".
Except in DB instructions, the zero length string constant '' is illegal.
The $NOMOD51 control disables also the predefined CODE addresses.
The special assembler symbols AR0...AR7 are predefined for bank 0 before
the first USING statement occurs.
V. List File Format
===================
The ASEM-51 list file format has been designed to give the user as much
information about the generated code as possible.
Besides the source code listed, there are five basic layout structures
in the listing:
- the page header
- the file header
- the line headings
- the error diagnosis
- the symbol table or cross-reference listing
Normally every page of the listing starts with a page header as shown below:
ASEM-51 V1.2 Copyright (c) 1996 by W.W. Heinz PAGE 1
It identifies the assembler, contains the copyright information and shows the
actual page number at the right margin. After the page header, source lines
are output in the list file format. When the maximum number of lines per page
is reached, another page header is output after a form feed character. When
the printer used doesn't work with form feeds, the page header can be
suppressed with the $NOPAGING control. The number of lines per page can be
adjusted to the paper format with the $PAGELENGTH control. The width of the
page header (and all other lines) can be set with the $PAGEWIDTH control.
The file header appears only on the first page. It identifies the assembler,
lists all input and output files and marks the columns for the line headings.
A typical file header is looking as shown below:
MCS-51 Family Cross Assembler A S E M - 5 1 V 1.2
=====================================================
Source File: DEMO.A51
Object File: DEMO.HEX
List File: DEMO.LST
Line I Addr Code Source
Directly after the file header starts the listing of the source code lines.
Every source code line is preceded by a line heading. The line heading
consists of four columns: line number, include file level, line address,
and generated code.
The column "Line" contains the source file line number. It is not necessarily
the local line number within the particular source file, but a global line
number, that is counted over the main source and all include files.
The column "I" flags the level of include file nesting. In the main source,
this column is empty. The first include file gets level 1. If this include
file includes another include file, this one gets level 2, and so on.
The column "Addr" shows the start address of the listed line in the currently
active segment (8051 address space). All addresses are represented as hex
numbers. The addresses in the CODE and XDATA segments are four-digit numbers.
Addresses in all other segments are two-digit numbers. For lines that cannot
be assigned to a particular segment, the "Addr" field is left blank.
The "Code" column may contain up to four bytes of generated code, which is
sufficient for all 8051 instructions. The code is listed in hex byte
quantities starting from the left margin of the "Code" column.
However, the code generated for DB and DW instructions may be longer than
four bytes. In these cases, the source code line is followed by additional
line headings until the whole code of the line is listed.
The "Code" column does not always contain code, that consumes space in the
8051 CODE segment. In contrast to many other assemblers, ASEM-51 lists the
evaluation results of all expressions that may appear in pseudo instructions
or assembler controls. These values are listed in hex representation at the
right margin of the "Code" column. The segment type of those expressions is
flagged with one single character at the left margin of the "Code" column:
C CODE
D DATA
I IDATA
X XDATA
B BIT
N number
The "Source" column finally contains the original source code line
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -