beautypg.com

Union directive, With and .endwith directives – Zilog Z8F0130 User Manual

Page 340

background image

Using the Macro Assembler

UM013037-1212

316

Zilog Developer Studio II – Z8 Encore!
User Manual

.UNION Directive

The

.UNION

directive is similar to the

.STRUCT

directive, except that the offset is reset to

zero on each label. A

.UNION

directive cannot have an offset or parent union. The key-

word to terminate a

.UNION

definition is

.ENDSTRUCT

.

The .UNION directive has the following form:

[stag]

.UNION

[name_1]

DS

count1

[name_2]

DS

count2

[tname]

.TAG

stagx [count]

...

[name_n]

DS

count3

[ssize]

.ENDSTRUCT

[stag]

An example of the

.UNION

directive usage is as follows:

BYTES .STRUCT

B0 DS 1

B1 DS 1

B2 DS 1

B3 DS 1

BSIZE .ENDSTRUCT BYTES

LONGBYTES .UNION

LDATA BLKL 1

BDATA .TAG BYTES

LSIZE .ENDSTRUCT LONGBYTES

.WITH and .ENDWITH Directives

Using the fully qualified names for fields within a structure can result in very long names.
The

.WITH

directive allows the initial part of the name to be dropped.

The

.WITH

and

.ENDWITH

directives have the following form:

.WITH

name

;

directives

.ENDWITH

[name]

The identifier name may be the name of a previously defined

.STRUCT

or

.UNION

, or an

ordinary label to which a structure has been attached using a

.TAG

directive. It can also be

the name of an equate or label with no structure attached. Within the

.WITH

section, the

assembler attempts to prepend “name.” to each identifier encountered, and selects the