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

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

117

 

 

LIT (AX51 & A251 only)

The LIT directive provides a simple text substitution facility. The LIT directive has the following format:

symbol

LIT

'literal string'

symbol

LIT

"literal string"

where

 

 

symbol

 

is the name of the symbol to define. The literal string

 

 

specified in the LIT directive will be substituted for each

 

 

occurrence of symbol that is used in your assembly

 

 

program.

literal string

is a numeric expression which contains no forward

 

 

references, or a simple relocatable expression.

Every time the symbol is encountered, it is replaced by the literal string

4

assigned to the symbol name. The symbol name follows the same rules as other

identifiers, that is, a literal name is not encountered if it does not form a separate token. If a substring is to be replaced, symbol must be enclosed in braces: TEXT{symbol}. The assembler listing shows the expanded lines where literals are substituted.

Example

Source text containing literals before assembly:

$INCLUDE (REG51.INC)

REG1

LIT

'R1'

NUM

LIT

'A1'

DBYTE

LIT

"DATA BYTE"

FLAG

LIT

'ACC.3'

?PR?MOD SEGMENT

CODE

 

RSEG

?PR?MOD

 

MOV

REG1,#5

 

SETB

FLAG

 

JB

FLAG,LAB_{NUM}

 

PUSH

DBYTE 0

LAB_{NUM}:

 

END

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

118 Chapter 4. Assembler Directives

Assembler listing from previous example:

 

 

 

1

 

$INCLUDE (REG51.INC)

 

 

+1

80

+1

$RESTORE

 

 

 

 

 

81

 

 

 

 

 

 

 

82

 

REG1

LIT

'R1'

 

 

 

83

 

NUM

LIT

'A1'

 

 

 

84

 

DBYTE

LIT

"DATA BYTE"

 

 

 

85

 

FLAG

LIT

'ACC.3'

------

 

 

86

 

 

 

 

 

 

87

?PR?MOD SEGMENT CODE

------

 

 

88

 

RSEG ?PR?MOD

 

 

 

89

 

 

 

 

000000

7E1005

 

90

 

 

MOV

R1,#5

000003

D2E3

 

91

 

 

SETB

ACC.3

000005

20E300

F

92

 

 

JB

ACC.3,LAB_A1

000008

C000

 

93

 

 

PUSH

DATA BYTE 0

00000A

 

 

94

 

LAB_A1:

 

 

 

 

 

95

 

 

 

 

 

 

 

96

 

 

END

 

4

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

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