📄 asem_51.doc
字号:
Example: DS 200H
DBIT <expr> define bits
Reserves a number of uninitialized bits.
The value of <expr> must be known on pass 1!
DBIT is only allowed in the BIT segment!
Example: DBIT 16
NAME <symbol> define module name
Defines a name for the program module. The module name must be a
legal symbol. Only one NAME instruction is allowed in the program.
Since the NAME instruction has been introduced for compatibility
purposes only, the symbol is not currently used. It may be redefined
in the subsequent program.
ORG <expr> origin of segment
Sets the location counter of the current segment to the value <expr>.
Additional ORG statements may be used to generate program segments
which will load at different locations.
The value of <expr> must be known on pass 1!
The default value of all location counters at program start is 0.
Example: ORG 08000H
USING <expr> using register bank
Sets the register bank used to <expr>, which must be in the range
of 0...3. The USING instruction only affects the values of the
special assembler symbols AR0, ... , AR7 representing the direct
addresses of registers R0, ... , R7 in the current register bank.
The value of <expr> must be known on pass 1!
The default value for the register bank is 0.
Example: USING 1
END end of program
This must be the last statement in the source file. After the END
statement only commentary and blank lines are allowed!
Example: END ;end of program
<symbol> EQU <expr> define constant
<symbol> SET <expr> define variable
The EQU instruction defines a symbolic constant of the type NUMBER.
A symbol defined with EQU can never be changed!
The SET instruction defines a symbolic value of the type NUMBER,
that may be changed with subsequent SET statements.
The value of <expr> must be known on pass 1!
A symbol that has been SET, cannot be redefined with EQU!
A symbol that has been EQU'd cannot be reSET!
On pass 2, forward references to a SET symbol always evaluate
to the last value, the symbol has been SET to on pass 1.
Examples: MAXMONTH EQU 12
OCTOBER EQU MAXMONTH-2
CHAPTER SET 1
CHAPTER SET CHAPTER+1
<symbol> CODE <expr> define ROM address
<symbol> DATA <expr> define direct RAM address
<symbol> IDATA <expr> define indirect RAM address
<symbol> BIT <expr> define bit address
<symbol> XDATA <expr> define external RAM address
These instructions define symbolic addresses for the five 8051
memory segments (address spaces). For DATA, IDATA and BIT type
symbols, the value of <expr> must not exceed 0FFH!
The value of <expr> must be known on pass 1!
Once defined with one of the above instructions, the symbols cannot
be redefined.
Examples: EPROM CODE 08000H
STACK DATA 7
V24BUF IDATA 080H
REDLED BIT P1.5
SAMPLER XDATA 0100H
CSEG [AT <expr>] switch to CODE space [at address]
DSEG [AT <expr>] switch to DATA space [at address]
ISEG [AT <expr>] switch to IDATA space [at address]
BSEG [AT <expr>] switch to BIT space [at address]
XSEG [AT <expr>] switch to XDATA space [at address]
These instructions switch to one of the five 8051 memory segments
(address spaces) and optionally set the location counter of that
segment to a particular address <expr>.
When the construction "AT <expr>" is omitted, the location counter
keeps its previous value.
The value of <expr> must be known on pass 1!
At program start the default segment is CODE and all the location
counters are set to zero.
Examples: DSEG ;switch to DATA segment
CSEG AT 8000h ;switch to CODE segment at address 8000H
XSEG at 0 ;switch to XDATA segment at address 0
III.7 Segment Type
------------------
Every assembly time expression is assigned a segment type, depending on
its operands and operators. The segment type indicates the address space,
the expression result might belong to, if it were used as an address.
There are six possible segment types:
CODE
DATA
IDATA
XDATA
BIT
NUMBER (typeless)
Most expression results have the segment type NUMBER. That means they are
assumed to be typeless. However, in some cases it may be useful to assign
a particular segment type!
The following six rules apply when the segment type is evaluated:
1. Numerical constants are always typeless.
Consequently their segment type is NUMBER.
2. Symbols are assigned a segment type during definition. Symbols
that are defined with EQU or SET have no segment type.
Labels get the segment type of the currently active segment.
3. The result of a unary operation (+, -, NOT, HIGH, LOW) will have
the segment type of its operand.
4. The results of all binary operations (except "+", "-" and ".") will
have no segment type.
5. If only one operand in a binary "+" or "-" operation has a segment
type, then the result will have that segment type, too. In all other
cases, the result will have no segment type.
6. The result of the bit operation "." will always have the segment
type BIT.
Examples:
--------- The following symbols have been defined in a program:
OFFSET EQU 16
START CODE 30H
DOIT CODE 0100H
REDLED BIT P1.3
VARIAB4 DATA 20H
PORT DATA 0C8H
RELAY EQU 5
1.) The expression START+OFFSET+3 will have the segment type CODE.
2.) The expression START+DOIT will be typeless.
3.) The expression DOIT-REDLED will be typeless.
4.) The expression 2*VARIAB4 will be typeless.
5.) The expression PORT.RELAY will have the segment type BIT.
The segment type is checked, when expressions appear as addresses. When the
expression result is not typeless and does not have the segment type of the
corresponding segment, the instruction is flagged with an error message.
The only exceptions are the segment types DATA and IDATA, which are assumed
to be compatible in the address range of 0 to 7FH. Since ASEM-51 does only
support absolute segments, those addresses are really always pointing to the
same physical location in the internal memory.
Example:
--------
Line I Addr Code Source
1: N 30 DSEG AT 030H ;internal RAM
2: 30 N 01 COUNT: DS 1 ;counter variable
3:
4: CSEG ;ROM
5: 0000 C2 30 START: CLR COUNT
^
@@@@@ segment type mismatch @@@@@
The CLR instruction is flagged with the error message "segment type mismatch"
in the assembler list file, because only a BIT type address is allowed here.
However, COUNT is a label with the segment type DATA!
III.8 Assembler Controls
------------------------
ASEM-51 implements a number of assembler controls that influence the
assembly process and list file generation. There are two groups of
controls: primary and general controls.
Primary controls can only be used at the beginning of the program and
remain in effect throughout the assembly. They may be preceded only
by control statements, blank and commentary lines. If the same primary
control is used multiple times with different parameters, the last one
counts.
General controls may be used everywhere in the program. They perform a
single action, or remain in effect until they are cancelled or changed by
a subsequent control statement.
Assembler controls may have a number or string type operand.
Number type operands are arithmetic expressions that must be known on pass 1.
String type operands are character strings which are enclosed in parentheses
instead of quotes. In analogy to quoted strings, no control characters
(including tabs) are allowed within these strings! The string delimiter ')'
can be represented by two subsequent ')' characters.
The subsequent paragraphs contain detailed explanations of the implemented
controls and their abbreviations:
Control Type Default Abbreviation Meaning
------------------------------------------------------------------------------
$DATE(string) P '' $DA inserts date string into page header
------------------------------------------------------------------------------
$DEBUG P $NODEBUG $DB (currently dummy)
$NODEBUG P $NODB ( " " )
------------------------------------------------------------------------------
$EJECT G $EJ start a new page in list file
------------------------------------------------------------------------------
$INCLUDE(file) G $IC include a source file
------------------------------------------------------------------------------
$LIST G $LIST $LI list subsequent source lines
$NOLIST G $NOLI don't list subsequent source lines
------------------------------------------------------------------------------
$MOD51 P $MOD51 $MO enable predefined SFR symbols
$NOMOD51 P $NOMO disable predefined SFR symbols
------------------------------------------------------------------------------
$PAGING P $PAGING $PI enable listing page formatting
$NOPAGING P $NOPI disable listing page formatting
------------------------------------------------------------------------------
$PAGELENGTH(n) P n=64 $PL set lines per page for listing
------------------------------------------------------------------------------
$PAGEWIDTH(n) P n=132 $PW set columns per line for listing
------------------------------------------------------------------------------
$PHILIPS P MCS-51 --- switch on 83C75x family support
------------------------------------------------------------------------------
$SYMBOLS P $SYMBOLS $SB create symbol table
$NOSYMBOLS P $NOSB don't create symbol table
------------------------------------------------------------------------------
$NOTABS P use tabs --- don't use tabs in list file
------------------------------------------------------------------------------
$TITLE(string) G copyright $TT inserts title string into page header
------------------------------------------------------------------------------
$XREF P $NOXREF $XR create cross reference
$NOXREF P $NOXR don't create cross reference
III.8.1 Primary Controls
------------------------
$DATE (string) Inserts a date string into the list file page header.
If $DATE() is specified, the actual date is inserted.
Date strings will be truncated to a maximum length of
11 characters.
Default is: no date string.
The control has no effect, when the $NOPAGING control has
been specified.
$DEBUG Dummy. (For compatibility purposes only!)
$NODEBUG Dummy. (For compatibility purposes only!)
$MOD51 Switches on the built-in 8051 special function register
and interrupt symbol definitions. (Default!)
$NOMOD51 Switches off the built-in 8051 special function register
and interrupt symbol definitions.
$PAGING Switches on the page formatting in the list file.
(Default!)
$NOPAGING Switches off the page formatting in the list file.
$PAGELENGTH (n) Sets the list file page length to n lines.
(12 <= n <= 65535)
Default is n=64.
The control has no effect, when the $NOPAGING control has
been specified.
$PAGEWIDTH (n) Sets the list file page width to n columns.
(72 <= n <= 255)
Default is n=132.
$PHILIPS Switches on the Philips 83C75x family support option.
This disables the LJMP, LCALL, and MOVX instructions as
well as the XDATA and XSEG pseudo instructions. Generic
jumps and calls will always assemble to absolute addressing.
$SYMBOLS Generates the symbol table at the end of the list file.
(Default!)
When the $XREF control is active, $SYMBOLS has no effect!
$NOSYMBOLS Suppresses the symbol table at the end of the list file.
When the $XREF control is active, $NOSYMBOLS has no effect!
$NOTABS Expands all tab characters in the list file output to
blanks.
$XREF Generates a cross-reference listing instead of a symbol
table. Note that this slightly slows down assembly, and
consumes about 67 % more memory space!
$NOXREF Generates a symbol table instead of a cross-reference
listing. (Default!)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -