Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
59
Добавлен:
14.04.2015
Размер:
2.03 Mб
Скачать

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

113

 

 

Symbol Definition

The symbol definition directives allow you to create symbols that can be used to represent registers, numbers, and addresses.

Symbols defined by these directives may not have been previously defined and may not be redefined by any means. The SET directive is the only exception to this.

EQU, SET

 

 

 

The EQU and SET directive assigns a numeric value or register symbol to the

 

specified symbol name. Symbols defined with EQU may not have been

 

previously defined and may not be redefined by any means. The SET directive

 

 

allows later redefinition of symbols. Statements involving the EQU or SET

4

directive are formatted as follows:

 

 

 

 

 

symbol

EQU

expression

 

 

symbol

EQU

register

 

 

symbol

SET

expression

 

 

symbol

SET

register

 

 

where

 

 

 

 

symbol

 

is the name of the symbol to define. The expression or

 

 

 

register specified in the EQU or SET directive will be

 

 

 

substituted for each occurrence of symbol that is used in

 

 

 

your assembly program.

 

expression

 

is a numeric expression which contains no forward

 

 

 

references, or a simple relocatable expression.

 

register

 

is one of the following register names: A, R0, R1, R2, R3,

 

 

 

R4, R5, R6, or R7.

 

Symbols defined with the EQU or SET directive may be used anywhere in operands, expressions, or addresses. Symbols that are defined as a register name can be used anywhere a register is allowed. A251 replaces each occurrence of the defined symbol in your assembly program with the specified numeric value or register symbol.

Shaded directives and options are available only in AX51 and A251.

114

Chapter 4. Assembler Directives

 

 

Symbols defined with the EQU directive may not be changed or redefined. You cannot use the SET directive if a symbol was previously defined with EQU and you cannot use the EQU directive if a symbol which was defined with SET.

Examples

LIMIT

EQU

1200

VALUE

EQU

LIMIT – 200 + 'A'

SERIAL

EQU

SBUF

ACCU

EQU

A

COUNT

EQU

R5

VALUE

SET

100

VALUE

SET

VALUE / 2

COUNTER

SET

R1

TEMP

SET

COUNTER

TEMP

SET

VALUE * VALUE

CODE, DATA, IDATA, XDATA

4

The BIT, CODE, DATA, IDATA, and XDATA directives assigns an address

value to the specified symbol. Symbols defined with the BIT, CODE, DATA,

 

IDATA, and XDATA directives may not be changed or redefined. The format

 

of theses directives is:

 

 

 

 

 

 

 

symbol

BIT

bit_address

defines a BIT symbol

 

symbol

CODE

code_address

defines a CODE symbol

 

symbol

DATA

data_address

defines a DATA symbol

 

symbol

IDATA

idata_address

defines an IDATA symbol

 

symbol

XDATA

xdata_address

defines a XDATA symbol

 

where

 

 

 

 

symbol

 

is the name of the symbol to define. The symbol name can

 

 

 

be used anywhere an address of this memory class is valid.

bit_address

code_address data_address

is the address of a bit in internal data memory in the area 20H .. 2FH or a bit address of an 8051 bit-addressable SFR.

is a code address in the range 0000H .. 0FFFFH.

is a data memory address in the range 0 to 127 or a special function register (SFR) address in the range 128 .. 255.

idata_address xdata_address

is an idata memory address in the range 0 to 255.

is an xdata memory address in the range 0 to 65535.

Shaded directives and options are available only in AX51 and A251.

Keil Software — A51/AX51/A251 Macro Assembler and Utilities

115

 

 

Example

DATA_SEG

SEGMENT BITADDRESSABLE

 

 

 

RSEG

DATA_SEG

 

; a bit-addressable rel_seg

 

 

CTRL:

DS

1

; a 1–byte variable (CTRL)

 

 

ALARM

BIT

CTRL.0

; bit in a relocatable byte

 

 

SHUT

BIT

ALARM+1

; the next bit

 

 

ENABLE_FLAG

BIT

60H

; an absolute bit

 

 

DONE_FLAG

BIT

24H.2

; an absolute bit

 

 

P1_BIT2

EQU

90H.2

; a SFR bit

 

 

RESTART

CODE

00H

 

 

 

INTVEC_0

CODE

RESTART + 3

 

 

 

INTVEC_1

CODE

RESTART + 0BH

 

 

 

INTVEC_2

CODE

RESTART + 1BH

 

 

 

SERBUF

DATA

SBUF

; redfinition of SBUF

 

 

RESULT

DATA

40H

 

 

 

RESULT2

DATA

RESULT + 2

 

 

 

PORT1

DATA

90H

; a SFR symbol

 

 

BUFFER

IDATA

60H

 

 

 

BUF_LEN

EQU

20H

 

 

 

BUF_END

IDATA

BUFFER + BUF_LEN – 1

 

 

 

XSEG1

SEGMENT XDATA

 

 

 

 

 

 

RSEG

XSEG1

 

 

 

4

DTIM:

DS

6

;reserve 6–bytes for DTIM

 

TIME

XDATA

DTIM + 0

 

 

DATE

XDATA

DTIM + 3

 

 

 

 

 

 

 

 

 

Shaded directives and options are available only in AX51 and A251.

116

Chapter 4. Assembler Directives

 

 

esfr, sfr, sfr16, sbit

The sfr, sfr16 and sbit directives are fully compatible to the Cx51 compiler and allows you to use a generic SFR register definition file for both: the Ax51 macro assembler and the Cx51 compiler. The esfr directive defines symbols in the extended SFR space of the Philips 80C51MX architecture. This directive is only available in the AX51 macro assembler. These directives have the following format:

sfr

sfr_symbol

= address;

 

esfr

sfr_symbol

= address;

 

sfr16

sfr_symbol

= address;

; ignored by Ax51

sbit

sfr_symbol

= bit-address;

 

where

sfr_symbol is the name of the special function register (SFR) symbol to define.

4 address bit-address

is an SFR address in the range 0x80 – 0xFF.

is address of an SFR bit in the format address ^ bitpos or sfr_symbol ^ bitpos. address or sfr_symbol refers to an bitaddressable SFR and bitpos specifies the bit position of the SFR bit in the range 0 – 7.

Symbols defined with the esfr, sfr, or sbit directive may be used anywhere as address of a SFR or SFR bit.

Example

sfr

P0

= 0x80;

 

sfr

P1

= 0x90;

 

sbit

P0_0

= P0^0;

 

sbit

P1_1

= 0x90^1;

 

esfr

MXCON

= 0xFF;

/* extended Philips 80C51MX SFR */

sfr16

T2

= 0xCC;

/* ignored by Ax51 */

NOTE

The Ax51 assembler ignores symbol definitions that start with sfr16. This is implemented for compatibility to the Cx51 compiler.

Shaded directives and options are available only in AX51 and A251.

Соседние файлы в папке HLP