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

122

Chapter 4. Assembler Directives

 

 

Reserving Memory

The memory reservation directives are used to reserve space in either word, dword, byte, or bit units. The space reserved starts at the point indicated by the current value of the location counter in the currently active segment.

DBIT

The DBIT directive reserves space in a bit or ebit segment. The DBIT directive has the following format:

 

 

label: DBIT

expression

 

 

 

where

 

 

 

4

 

label

 

is the symbol that is given the address of the reserved

 

 

 

memory. The label is a symbol of the type BIT and gets the

 

 

 

current address value and the memory class of the active

 

 

 

 

segment. The label can only be used where a symbol of this

 

 

 

 

 

 

 

 

type is allowed.

 

 

expression

 

is the number of bits to reserve. The expression cannot

 

 

 

 

contain forward references, relocatable symbols, or external

 

 

 

 

symbols.

 

 

 

The DBIT directive reserves space in the bit segment starting at the current

 

 

address. The location counter for the bit segment is increased by the value of the

 

 

expression. You should note that the location counter for the bit segment

 

 

references bits and not bytes.

 

 

 

 

 

 

 

 

 

NOTE

 

 

 

 

 

The Ax51 assembler is a two–pass assembler. Symbols are collected and the

 

 

length of each instruction is determined in the first pass. In the second pass,

 

 

forward references are resolved and object code is produced. For these

 

 

reasons, an expression used with the DBIT directive may not contain forward

 

 

references.

 

 

 

 

 

Example

 

 

 

 

 

 

 

 

 

 

 

ON_FLAG:

DBIT

1

; reserve 1 bit

 

 

OFF_FLAG:

DBIT

1

 

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

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

123

 

 

DS

The DS directive reserves a specified number of bytes in a memory space. The DS directive has the following format:

label: DS

expression

 

 

where

 

 

 

 

label

 

is the symbol that is given the address of the reserved

 

 

 

memory. The label is a typeless number and gets the current

 

 

 

address value and the memory class of the active segment.

 

 

 

The label can only be used where a symbol of this type is

 

 

 

allowed.

 

expression

 

is the number of bytes to reserve. The expression cannot

 

 

 

contain forward references, relocatable symbols, or external

 

 

 

symbols.

4

The DS directive reserves space in the current segment at the current address.

The current address is then increased by the value of the expression. The sum

 

 

of the location counter and the value of the specified expression should not

 

exceed the limitations of the current address space.

 

 

 

 

 

 

NOTE

 

 

 

 

The A251 assembler is a two–pass assembler. Symbols are collected and the

 

length of each instruction is determined in the first pass. In the second pass,

 

forward references are resolved and object code is produced. For these

 

reasons, an expression used with the DS directive may not contain forward

 

references.

 

 

 

 

Example

 

 

 

 

 

 

 

 

GAP:

DS

(($ + 16) AND 0FFF0H) – $

 

 

 

DS

20

 

 

TIME:

DS

8

 

 

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

124 Chapter 4. Assembler Directives

 

 

DSB

(AX51 & A251 only)

 

 

The DSB directive reserves a specified number of bytes in a memory space. The

 

DSB directive has the following format:

 

 

 

 

 

label:

DSB

expression

 

where

 

 

 

 

label

 

is the symbol that is given the address of the reserved

 

 

 

 

memory. The label is a symbol of the type BYTE and gets

 

 

 

 

the current address value and the memory class of the active

 

 

 

 

segment. The label can only be used where a symbol of this

 

 

 

 

type is allowed.

 

expression

is the number of bytes to reserve. The expression cannot

 

 

 

 

contain forward references, relocatable symbols, or external

4

 

 

 

symbols.

The DSB directive reserves space in the current segment at the current address.

The current address is then increased by the value of the expression. The sum of the location counter and the value of the specified expression should not exceed the limitations of the current address space.

NOTE

The Ax51 assembler is a two–pass assembler. Symbols are collected and the length of each instruction is determined in the first pass. In the second pass, forward references are resolved and object code is produced. For these reasons, an expression used with the DSB directive may not contain forward references.

Example

DAY: DSB 1

MONTH: DSB 1

HOUR: DSB 1

MIN: DSB 1

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

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

125

 

 

DSW (AX51 & A251 only)

The DSW directive reserves a specified number of words in a memory space. The DSW directive has the following format:

label: DSW

expression

 

 

where

 

 

 

 

label

 

is the symbol that is given the address of the reserved

 

 

 

memory. The label is a symbol of the type WORD and gets

 

 

 

the current address value and the memory class of the active

 

 

 

segment. The label can only be used where a symbol of this

 

 

 

type is allowed.

 

expression

 

is the number of bytes to reserve. The expression cannot

 

 

 

contain forward references, relocatable symbols, or external

 

 

 

symbols.

4

The DSW directive reserves space in the current segment at the current address.

The current address is then increased by the value of the expression. The sum

 

 

of the location counter and the value of the specified expression should not

 

exceed the limitations of the current address space.

 

 

 

 

 

 

NOTE

 

 

 

 

The Ax51 assembler is a two–pass assembler. Symbols are collected and the

 

length of each instruction is determined in the first pass. In the second pass,

 

forward references are resolved and object code is produced. For these

 

reasons, an expression used with the DSW directive may not contain forward

 

references.

 

 

 

 

Example

 

 

 

 

 

 

 

 

 

YEAR:

DSW

1

 

 

DAYinYEAR:

DSW

1

 

 

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

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