R E L O C A T
I
N G M A C R O A S S E M B L E RA N D L
I
N K E Rfor
Z 8 O A N D H D 6 4 1 8 O
by
Patrick
O'ConnellZas,
Zlink,
Z1ib, Zcon, Zref are Copyright 1984/85 by Mitek. Nopart of
this
document may be reproducedin
any wayor
by any meanswithout prior written
permission of thepublisher.
Mdressrequests to
Echelon,Inc.,
101First
Street,
LosAltos,
CACopyright 1984/85 Mitek
All
Rights ReservedWARNING
THIS SOFTWARE AND MANUAL ARE BOTH PROTECTED BY U.S. COPYRIGHT LAW
(TITLE 17 UNITED STATES CODE). UNAUTHORIZED REPRODUCTION AND/OR SALES MAY RESULT IN IMPRISONMENTOF UPTOONEYEARAND FINES OF UP TO $10,000 (17 USC 506). COPYRIGHT INFRINGERS MAY ALSO BE SUBJECT TO CIVIL LIABILITY.
LIMITED WARRANTY
THIS PROGRAM AND INSTRUCTION MANUAL ARE SOLD "AS
IS,"
WITHOUT WARRANTY AS TO THEIR PERFORMANCE, MERCHANTABILITY, OR FITNESS FORANY PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE RESULTS AND PERFORMANCE OF THIS PROGRAM IS ASSUMED BY YOU.
HOWEVER, TO THE ORIGINAL PURCHASER ONLY, ECHELON WARRANTS THE MAGNETC DISKETTE ON WHICH THE PROGRAM IS RECORDED TO BE FREE FROM DEFECTS IN MATERIALS AND FAULTY WORKMANSHIP UNDER NORMAL USE FOR A PERIOD OF THIRTY DAYS FROM THE DATE OF SHIPMENT. IF DURING THIS THIRTY-DAY PERIOD THE DISKETTE SHOULD BECOME DEFECTIVE, IT MAY BE RETURNED TO ECHELON FOR A REPLACEMENT WITHOUT CHARGE.
YOUR SOLE AND EXCLUSIVE REMEDY IN THE EVENT OF A DEFECT IS EXPRESSLY LIMITED TO REPLACEMENT OF THE DISKETTE AS PROVIDED ABOVE. IF FAILURE OF A DISKETTE HAS RESULTED FROM ACCIDENT OR ABUSE ECHELON SHALL HAVE NO RESPONSIBILITY TO REPLACE THE DISKETTE U7'DER THE TERMS OF THIS LIMITED WARRANTY.
ANY IMPLIED WARRANTIES RELATING TO THE DISKETTE, INCLUDINGANY
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICU-LAR PURPOSE, ARE LIMITED TO A PERIOD OF THIRTY DAYS FROM DATE OF SHIPMENT. ECHELOP' SHALL NOT BE LIABLE FOR INDIRECT, SPECIAL, OR
CONSEQUENTIAL DAMAGES RESULTING FROM THE USE OF THIS PRODUCT. SOME STATES DO NOT ALLOW THE EXCLUSION OR
LIMITATION OF
INCIDEN-TIAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE LIMITATIONS MIGHT NOT
APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS, AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH VARY FROM STATE TO STATE.
Trademarks: Zas,
Zlink,
Zlib,
Zcon,Zref,
Mitek;
ZDM, RDSoftware;
DSD,soft
Solutions;
Z-System, Echelon,Inc.;
Z80,Zilog,
Inc.;
HD64180,Hitachi;
CP/M, DDT, SID, ZSID,Digital
TABLE OF CONTENTS
Chapter 1
INTRODUCFION...
I
1.1 Overview 1
1.2
Distribution
Files
11.3
Installation
11.4 Software Updates 2
Chapter 2 ZAS
INVCCATION...
32.1 ZAS Operation 3
2.2 ZAS Options 3
2.3 Assembly
Statistics
4Chapter 3 PROGRAM
FORMAT...
53.1 Label
Field
53.2 Operation
Field
53.3 Operand
Field
53.4 Comment
Field
6Chapter 4
EXPRESSIONS...
74.1 Numeric Constants 7
4.2
String
Constants 74.3 Character Constants 7
4.4 Labels 8
4.4.1 Label
Characteristics
84.4.2 Relocation Bases 8
4.5 Relocation Counter Reference 9
4.6 Registers 9
4.7 Operators 10
4.8 Precedence
of
Operators 114.9 Parentheses Versus Brackets 12
4.10 Expression
Restrictions
12Chapter 5
PSEUIX)-OPS...
135.1 General Pseudo-ops 13
5.2
Listing
Control Pseudo-ops 165.3 Conditional Assembly Pseudo-ops 16
5.3.1 IF Pseudo-ops Evaluatiorí 16
5.3.2 Conditional Assembly Forms 17
5.4 Linkage Pseudo-ops 19
5.5 Relocation Base Pseudo-ops 20
5.6 Macro Pseudo-ops d?
~4
5.7 Special Function Pseudo-ops 22
Chapter 6 MACRO
FACILITY...
236.1 Repeat Macros 23
6.2 Stored Macros 25
6.3
Exiting
Macros 256.4 Local Symbols 25
6.5 Macro
Invocation
26TABLE OF CONTENTS (continued)
Chapter 7 ZAS ERROR
MESSAGES...
297.1 Non-Fatal Errors 29
7.2 Fatal Errors 30
7.2.1 General Fatal
Error
Messages 307.2.2 Macro Fata!
Error
Messages 30 CHAPTER 8 CROSS-REFERENCE GENERATION... 318.1 Overview 31
8.2 ZREF Operation 3i
8.3 Reserved Symbols 31
CHAPTER 9 CODE
CONVERTER...
339.1 Code Converter Operation 33
9.2 Convertible TDL Pseudo-ops 33
9.3
Error
Messages 34CHAPTER 10
LINKER...
3510.1 Overview 35
10.2 ZLINK Operation 35
10.3 ZLINK Options 35
10.4 Define Next Free Memory Location 36
10.5 ZLINK
Error
Messages 37CHAPTER 11 LIBRARY
MANAGER...
3911.1 Overview 39
11.2 ZLIB Operation 39
11.3 ZLIB Options 39
11.4 ZLIB Messages 39
11.5 ZLIB
Error
Messages 40Appendix A: Z80 Mnemonic Machine
Instruction
CodesAppendix B: Software Update Form
Appendix C: Pseudo-op Summary
CHAPTER 1 INTRODUCTION
1—I OVERVIEW
ZAS (Z80 and HD64180 Relocating Macro Assembler) reads assembly
language statements from a
disk
file
and produceseither
anIntel
compatible
HEXfile
or
aMicrosoft
compatible
RELfile.
Thesefiles
can then be loadedusing
Echelonsupplied
MLOAD,or
CP/f'1LOAD, command
or
anyMicrosoft
object compatible
linker.
Asymbol
table
file
(SYM)is optionally
producedthat
can be usedwith
Echelon DSD orDigital
Research SID and ZSID debuggers. The minimum Zor
CP/M systemconfiguration in
whichto
use zasis
48k-bytes of
RAMwith
onedisk drive.
As soon as you receive ZAS, make backup copies! Then go through
the
installation
process using a copy.1.2 DISTRIBUTION FILES
You
will
find
thefollowing
files
on yourdistribution
disk:
File
FunctionZAS.COM Assembler
ZLINK.COM
Linker
ZLIB.COM
Library
ManagerZCON.COf1 8080
to
Z80 Code Converter ZREF.COM Cross-reference GeneratorTEST.Z80 Test Assembly
File
INSTZAS.COM
Installation
Program1.3 INSTALLATION The
installation
program was designed
to
set assembler outputop-tions.
Typein
INSTZASto
invoke theinstallation
program. TheCHAPTER
I:
INTRODUCTIONINSTMS<cr>
ZAS
installation
options:
l.
Listing to terminal
-
off
2.
Listing to disk
file
- off
3.Listing to printer
-
off
4. Generateobject
file
-
on 5. Generate symbolfile
-
off
6.object
file
type- rel
7. IF trueness based on
- least significant
bit
99. Changes complete
Enter
option
numberto
change:The preset values
for different
optionsis indicated to right of
option.
To change(toggle)
anoption value (i.e., onto
off, rel
to
hex,or least
significant
bit
to
all
sixteen
bits),
simply
enter option
number(l
to
7)followed
bycarriage
return
<CR>. Whendesired option
changes have been made,type in
99to
endinstallation
program and have ZAS.COMautomatically
updated.1.4 UPDATES
You can
assist in refining
ZAS by recommending enhancements andreporting
any software problems on a copyof
the Software UpdateForm, a sample
of
whichis in
Appendix B. Software updateswill
be providedat regular intervals
for
a nominal fee. Youwill
becmvrm
2 ZAS INVOCATION2.1 ZAS OPERATION
ZAS
is
invoked bytyping:
ZAS
filename.filetype
where
filename is the
nameof the
sourcefije
to
be assembled.If
nofiletype
is specified,
then Z80is
assumed. Typing ^Cwill
cancel ZAS
operation.
2.2 ZAS OFTIONS
A
variety
of options
areavailable
to provide control
overthe
execution pararneters
of
ZAS. They are used onceat
the endof
a commandline
and spaces are not allowed betweenoptions:
ZAS filename
{$}options
There are two types
of options:
non-disk reference options ariddisk reference options.
Usingthe non-disk reference options
reverses the settings
supplied
bythe
Install
Program andin-cludes the
C, H, and Loptions.
C: CRTOption.
Setting the
Coption
will
pagethe output of
ZAS,
at
23lines
per page.Pressing
any keyallows
youto
continue
to scroll
through the output page by page. However,it
should be notedthat
a ^Cwill
abort the assembly.H: Hex
Option.
Whenthis
option is set
it
will
generate
Intel
compatible hex
files
insteadof Microsoft
compatible RELfiles.
Note: When
using
HEXfiles,
you must have an ORGstatement of
1OOH or higherto
prevent aninverted
addresserror
from MLOAD orLOAD.COM.
L:
Listing
tcjPrinter
Option.
Setting
the
Loption
sends aformatted
assemblylisting
to
Zor CP,"61 LST: device.
The
disk reference options require
twocharacters.
Thefirst
characteris
the P, O, or Soption
characters. The secondcharac-ter
indicates
the output disk drive for the specified
option.
The second character must be A-P or Z, where Z
(for
zero or
null)
suppresses the outputaltogether.
o:
object
File
Generation
(filename.REL or filename.HEX). The Ooption specifies
the disk for object
file
output.
Depending on the Hoption,
theobject
file will
be aMicrosoft
compatible RELfile
or anIntel
compatible HEXfile.
P:
Listing
to
a PRNFile
(filenarne.PRN). The Poption
will
senda formatted assembly
listing
to
thespecified disk.
S: SymbolFile
Generation
(filename.SYMÁ The SCHAPTER 2: ZAS INVOCATION
2.3 ASSEMBLY STATISTICS
At the completion
of
an assembly, ZAS provides severalstatistics
on the program assembled. The output
is
asfollows:
Assemblystatistics:
nnnn
lines
nnnnlabels
nnnn macros read nnnn macro expansions nnnnerrors
cFlAprER 3 PRCX;RAMFORMAT
Acceptable program
input consists of
a sequenceof
statementsin
the form:
label
operation operand commentwhere each
field
is
separated by one or more spaces and/or tabs.All fields
areoptional
and may beginin
any column exceptfor
the
label
field
which must beginin
column one. The statementis
terminated
by acarriage return
and aline
feedis allowed
butnot necessary. You rnay also
insert
blanklines into
the program. The statement may beeither
upper or lower-case exceptfor
macroparameters. For macro parameters, the
actual
and formal parameters must bein
the saíne casefor substitution
to
take place.3.1 IABEL FIELD
Labels take the form:
label
or
label:
and are
optional
except for the
SET, EQU, and MACRO assemblerdirectives.
Thelabel
consist-sof
alphanumeric characters, a ?, an @,or
a $ and thefirst
character must not be numeric.If
thelabel
exceeds 15characters then the label is truncated to the
right.
Labels can beeither
upper-caseor lower-case.
The ":"
following
alabel is optional.
Examplesof labels include the
following:
a123 ?a123 @a123
aLL: ?ALL:
update_file
Áll?
INDEX UPDATE$EILE3.2 OPERATION FIELD
The operation
field
contains oneof
thefollowing three:
amne-monic machine
instruction
code, a pseudooperation
code whichdirects
the
assemblyprocess, or
a macro. The Z80 mnemonicmachine
instruction
codesare
listed
in
Appendix A andHitachi
HD64180
instruction
codesare
listed
in Appendix
D. Theassembler pseudo-op codes are
discussed in
Chapter 5,with
asummary
of the
pseudo-opslisted
Appendix C. Andthe
macroinstructions
are discussedin
Chapter 6.3.3 OPERAND FIELD The operand
field
may contain numeric constants, charactercon-stants,
ASCIIstrings,
relocation
counter references,
labels,
register
references, operators, or expressions containing
anycombination
of
thepreviously
mentioned items. Expresstons areCHAPTER 3: PR(JGRPM FORMAT
3.4 COFHENT FIEID
A comment
field
is
always preceded by a semicolon(;).
CommentsCHAETER 4 EXPRESSIONS
Before the
pseudooperations
and macros can bedescribed,
it
is
necessary
to discuss expressions
becauseof
their
complexity.
Expressions consist of simple
operands combinedinto properly
formed sub-expressions by operators. Blanks and tabs are ignored between operators and operandsof
the expression. Eachexpres-sion produces a
16-bit
value during the assembly.If
only 8bits
are needed,
the least
significant
half of the 16-bit value is
used.4.1 NUMERIC CONSTANTS
A numeric
constant is
a16-bit
value in
oneof several
numberbases. The base,
called
theradix of
the constant,is
denoted by atrailing
radix indicator.
Any numeric constant which does notterminate with
aradix indicator
uses thedefault radix
which hasbeen
initially
setto
decimal. Theradix indicators
are:B
binary
constant base 2O
octal
constant base 8Q
octal
constant base 8D decimal constant base 10
H hexadecimal constant base 16
A constant
is
a sequenceof digits,
followed
by anoptional radix
indicator,
where thedigits
areappropriate for
theradix,
i.e.,
binary constants
must be composedof
O andI digits
etc.
For hexadecimal constants, the leadingdigit
must be a decimaldigit
in order to avoid confusing the
hexadecimalconstant with
anidentifier
(aleading
Owill
work).
A numericconstant
mustproduce a
binary
number which can becontained within
a16-bit
value.
4.2 ASCII STRINGS
String
constants represent sequencesof
ASCII characters, and are represented by enclosing the characterswithin
apostrophe symbols(').
All
strings
must befully
contained within
the current
physical line.
The apostrophe characteritself
can be includedwithin
astring
byrepresenting
it
as a double apostrophe("),
which becomes a
single
apostrophe when read by the assembler.4.3 CHARACTER CONSTANTS
Like strings,
character
constants
are composedof
O, 1,or
2ASCII characters,
delimited
by an apostrophe (') orquotation
(") symbol. Onedifference
betweenstrings
and character constantspseudo-CHAPTER 4: EXPRESSIONS
ops.
In
all
other
cases, acharacter
constant
is
assumed.Another
difference
is that the value of
acharacter constant is
calculated
andthe result
is stored with the
lowbyte in the
first
address andthe high byte in the
second address. Forexample,
in
the character constant:DW 'AB'
the value of
Ais stored in the
second memorylocation
and Bis
stored
in
thefirst
memorylocation.
In thestring:
DB 'AB'
the value of
Ais stored in the
first
memorylocation
and Bis
stored
in
the second memorylocation.
4.4 T?F'[FT"éA
label is given
avaluedeterminedby
the type of statement
it
precedes.
If
thelabel
precedes a macrodefinition,
thelabel is
given
atext
value,
whichis the
bodyof the
macrodefinition.
If
the label
precedes an EQUor
SET pseudooperation,
thenthe
label
is given the value of the
operandfield.
If
alabel
precedes any
other type of statement,
it
is given the value of
thecurrent relocation
counter.The
value of
alabel is not allowed to
changeunless the label
precedes a SET pseudo-op.
In
which case,there is
nolimit
to
the number
of
times thelabel's
value may change.4.4.1
LABEL CHARACTERISTICSLabels
fall
into
oneof three categories:
public,
external,
or
local.
Public labels
arelabels
definedin
thecurrent
program module and can bereferenced in other
program modulesExternal
labels
arelabels
which have been defined aspublic in
someother
program module and are being referenced
in
the moduledeclaring
themexternal.
If
alabel
hasnot
beendeclared external
or
public then
it
is local
and cannot bereferenced
by anyother
program module.4.4.2
REUJCATION BASESThe
symbolic
namesfor
independently located
memory areas arecalled relocationbases.
Theserelocationbases
mayrepresent
ROM, shared COMMONareas, special
memory areas such asvideo
refresh,
memory mapped I/O, etc.Within
each sub-program, eachof
these
memory areasis referenced
by aunique
name. Theactual
allocation
and mappingof the
nameto physical
addressesis
deferredto
thelink edit
and load process.All label
referenceswithin
the assembled program arerelative to
oneof
thesereloca-tion
bases. Thefour relocation
bases andtheir typical
uses areCHAPTER 4: EXPRESSIONS
Absolute:
Absolute assemblesnon-relocatable
code. A programmerselects
Absolute
mode when ablock of
program codeis to
beloaded each
time into specific
addresses, regardlessof
what elseis
locatedat
the sametime.
Data
Relative:
DataRelative
assembles codefor
asection of
aprogram
that
may change andtherefore
must be loadedinto
RAM.This
applies especially to
program data areas. Symbolsin
DataRelative
arerelocatable.
Code
Relative:
Code (program)Relative
assembles codefor
sectionsof
programsthat
will
not be changed andtherefore
canbe
loaded
into
ROM/PROM. Symbolsin
CodeRelative
are
relocatable.
COMMON: COMMON assembles code
that is
loadedinto
adefined
common data area. Thisallows
program modulesto
share a blockof
memory and common values.To change
the relocation
base, use oneof the following
pseudo-ops
in
a statementline:
ASEG Absolute
DSEG Data
Relative
CSEG Code
Relative--default
CO.YLYON CO!)MON
4.5 RELOCATION COUNTER REFERENCE
The
current
relocation
counter
may bereferenced
as a16-bit
value
by useof the
symbol $. Thevalue represented
by $is
always the
relocation
counter valueat
thestart of
thecurrent
statement. For example,JP $
will
endlessly junpto
itself.
4.6 RE)GISTERSWhen ZAS encounters a one or two character symbol,
it
will
lookup
the
symbolin the corresponding
8or 16-bit
register
table
(see the next page).
If
the symbolis
found, then the operandis
assumedto
be aregister
reference.
Because thesesingle
and double character symbols are reserved words, do not use them asCHAPTER 4: EXPRESSIONS
8-Bit
Registers16-Bit
Registers(Reserved Words) (Reserved Words)
A BC
B DE
C HL
D IX
E IY
H SP
L AF
M
I
R
4.7 OPERAIKJRS
The operands
previously
described
can be combinedin
normalalgebraic expression using
anycombination of properly
formed operands, operators, and parenthesized expressions.All
arithme-tic
operators (",-,*,/,MOD,SHL,
and SHR) produce a16-bit
un-signed
arithmetic
result.
Therelational
operators (EQ, LT, LE, GT, GE, and NE) produce atrue
(OFFFFH)or false
(OOOOH)16-bit
result.
And thelogical
operators (NOT, AND, OR, and XOR) operatebit-by-bit
ontheir
operand(s)producing
a16-bit
result
of
16individual
bit
operations.
The HIGH and LOWoperators always
produce a
16-bit
result
with
ahigh order byte
whichis
zero. The NUL operator produces atrue
orfalse result.
The operators
for
the operandfield
are given below.In
general,the
letters
xandy represent
operands which aretreated
as16-bit
unsignedquantities
in
the range 0-65535.Arithmetic
Operators Result
x"y
arithmetic
sumof
x and yx-y
arithmetic difference
between x and y x * y unsignedmultiplication
of
x by y x/
y unsigneddivision of
x by yx MOD y remainder
after division of
x by y x SHL yshift left
by y,with
zeroright
fill
x SHR y
shift
right
byy, with
zeroleft
fill
Relational
Operators Result
x EQ y, x=y
true
if
x equals y,false
otherwisex LT
y,
x<ytrue
if
xis less
than y,false
otherwise x LE y, x<=ytrue
if
xis
less or equalto y,
elsefalse
x GTy,
x>ytrue
if
xis greater
than y,false
otherwise x GE y, x)=ytrue
if
xis greater
or equalto y,
elsefalse
x NE y, x<>ytrue
CHAPTER 4: EXPRESSIONS
Logical
Operators Result
NOT y
bit-by-bit
logical
inverseof
y x AND ybitwise logical
AND of x and y x OR y,x!y
bitwise logical
ORof
x and y x XOR ylogical exclusive
ORof
x and ySpecial
Operators Result
HIGH y
identical
to
y SHR 8 (high order byteof
y)LOW
y
identical
to
y AND OFFH (low order byteof
y)NUL
line
true
if
the remainderof
thecurrent line is null
or contains only space and/or tab characters. Be-causethe
NULoperator
usesthe rest of
thecurrent
sourceline
as an operand,it
must be thelast
operator on aline.
4.8 PRECEDENCE OF OPERATORS
Without parentheses or brackets operators have an order of
appli-cation
asif
they were parenthesized or bracketed. As described below,the operators
listed
first
havehighest
precedence, andthe operators
listed
last
havelowest
precedence.Operators
listed
on the sameline
have equalpriority
and are applied fromleft
to right in
the expressionhighest precedence *
/
MOD SHL SHR + —EQ LT LE GT GE NE
NOT AND
OR XOR
HIGH LOW
lowest precedence NUL
The expressions shown below are
equivalent:
X " y * Z = X " [y * Z]
x OR y * a SHR b = x OR {y * la SHR
bll
Balanced parenthesized or bracketed sub-expressions can always be
used
to override the order of
precedencedescribed
above. Thelast
expression could berewritten to force application of
opera-tors in
adifferent
order:CHAPTER 4: EXPRESSIONS
4.9 parentheses xmtsus brackets
Parentheses and
brackets
arenot interchangeable.
They servedifferent
purposes. Parentheses are usedin expressions that
haveindirect
addressing modes. For example,LD HL, (5+1)
will
loadthe register
pair
HL fromthe contents of
memorylocation six
(5"1) and seven.Brackets are used
for
all
other
expressions where the addressingmode
is
notindirect.
Using the above examplewith
brackets, LD HL, 15+1)will
load theregister pair
HLwith
the immediate valuesix.
4.10 EXPRESSION RESTRICTIONS
The operand
field
of
a statement mayconsist of
a ccmplexarith-metic expression
with
thefollowing restrictions:
(I)
Anexternal
mayonly
have anabsolute quantity
addedor
subtracted from
it.
Theresult
will
beexternal.
(2) A
relocatable
value may have an absoluteor
anotherrelocat-able value (in the
samerelocation
base) addedto or
sub-tracted
fromit.
Theresult
will
relocatable.
(3)
If
tworelocatable
values are subtracted then theresult
will
be absolute.(4)
In
all
other arithmetic
andlogical
operations, both operands must be absolute. Theresult
will
be absolute.An expression
error
will
be generatedif
an expression does notCHAPTER 5 PSEUDO-OPS
5.1 GENERAL PSEUDO-OPS
DB: The D.efine Byte pseudo-op
is
usedto
enter one or more one-byte data valuesinto
the program. The statement formis:
DB n
{,n...}
where n
is
any expressionwith
avalid B-bit
value. More than onebyte can be defined
at
a time by separatingit
from the precedingvalue with
a comma.All
of the bytes defined in
asingle
DBstatement are assigned consecutive memory
locations.
TheZilog
mnemonic DEFB can be used instead
of
DB.DC: The D.efine C.haracter pseudo-op
stores the characters in
astring in
successive memorylocations
beginningwith
thecurrent
relocation
counter. The mostsignificant
bit
of
thelast
charac-ter
will
be setto
one. The formfor
the DC pseudo-opis:
DC
'string'
DS: The D.efine Space pseudo-opreserves
an areaof
memory. The formis:
DS expression {,expression}
where the value
of
thefirst
expression gives the numberof
bytesto
bereserved.
TheZilog
mnemonic DEFS can be usedinstead of
DS.To
initialize
the reserved space, set theoptional
secondexpres-sion
to
the value desired.If
the second expressionis omitted,
the reserved
spaceis
left
asis
(uninitialized).
Thereserved
block of
memoryis not automatically
initialized
to
zeros. Toinitialize
to
zeros give the second expression the value O.All
names usedin
thefirst
expression must bepreviously
defined on pass 1. Otherwise, a Uerror
(undefined symbol)is
generatedduring
pass 1, and a Perror
(phaseerror)
will
probably
begenerated
during
pass 2 becausethe
DS pseudo-op generated nocode on pass 1.
DW: The
Define
Worddirective
is
usedto enter
a16-bit
value
into
the program. Thisdirective
takes the form:DW
nn
{,nn...}
Where nn
is
anyexpression with
avalid
16-bit value. Multiple
16-bit
values may be definedwith
one DW statement by separatingthe values with
a comma.All
16-bit values defined
by the DWpseudo-op are stored
in
standard Z80 word formatwith
theleast
significant
byte
first.
TheZilog
mnemonic DEFW can be usedCHAPTER 5: PSETJ1X)-OPS
END: The END statement
is optional.
All
statementsfollowing
the END are ignored. The formis:
END lexpressiorú
The
optional
expressionis
the programstarting
address.If
anIntel
compatible hexfile
is
being generated, thenthis starting
addresswill
be includedin
thelast
recordof
the hexfile.
If
a REL
file
is being generated, then
ZLINKwill
place
a JUMPinstruction
at
1OOHto
thespecified starting
address.EQU: The EQUate statement
is
usedto
name synonymsfor
particu-lar
numeric values. The formis:
label
EQU expressionThe
label mustbe present andcannot label
anyother statement.
The assembler evaluates the expression and assigns
this
valueto
the
label.
Thelabel is usually
a name which describes the valueof the expression.
Also,
this
name can be usedthroughout the
program as a parameter
or
operand..IN: The.l.N.sert
(or
MACLIB) pseudo-opallows the
programmerto
usethe
samesection of
assembler source codein
a numberof
different
assemblies. The formatis:
.IN {d:
}filenaIne
or MACLIBK: lfilename
where d
is the optional
Zor
CP/Mdisk
specifier
(defaulting
to
the
loggeddisk)
andfilename
is the
file
ondisk with
the
assumedfiletype
LIB.This
directive
causesthe specified
file
to
becopied into the
assemblyin
its
entirety,
andto
betreated exactly
asif it
werepart of
theoriginal
sourcefile.
All inserted
sourcelines
areflagged with
a "+" onthe
listing.
Only onelevel of insert
is
allowed, they cannot be nested.
.LIST: This pseudo-op resumes a
listing
which has been suppressedby the .XLIST
directive.
See the next page.PAGE: The page pseudo-op gives
control
over the outputformatting
which
is
sent to the
PRNfile
and/or
directly
to
Zor
CP/M LST:device. The form
for
the PAGE statementis:
PAGE {expression}If
the
PAGEstatement is
usedwithout the optional
expression
then a form feed
is
sentto
the outputfile
and/or Z or CP/M LST:device. The form feed
is
sent before the statementwith
PAGE hasbeen
printed.
Consequently,the
PAGE commandis
often issued
directly
aheadof
major sectionsof
an assembly language program,such as a group
of subroutines,
to
causethe next statement to
appear
at
the topof
thefollowing printer
page.CHAPTER 5: PSEUIXJ-OPS
page
size.
In
this
case,the expression
whichfollows the
PAGE pseudo-op determines the numberof
outputlines to
beprinted
oneach page.
If
the expression
equatesto
avalue
between 40 and90, then
the
pagesize is set to the value of the expression.
When
this
value is
reachedfor
each page, a form feedis
issuedto
cause a pageeject.
The assemblerinitially
assumes a 56line
page
size
and produces a pageeject
at the beginning of the
listing.
Usually,
no morethan
one PAGEstatement with the
expressionoption is
includedin
aparticular
program..RADIX: The statement form
is:
.RADIX n
where n
is
2, 8, 10,or
16.This
pseudo-op set-sthe radix to
nfor
all
numbers whichfollow,
unless another .RADIX statementis
encountered, or the radix is overridden
by asuffix
radix
modi-fier.
Initially,
the default
radix
is set to
10(decima]).
SET: The SET statementis
usedto
name synonymsfor particular
numeric values. The form
is:
label
SET expressionThe
label
must be present and cannotlabel
anyother
statement,except
for
another SET. The assembler evaluates the expressionand assigns
this
valueto
thelabel.
Thelabel is usually
a namewhich describes the value
of
the expression. Also,this
name canbe used
throughout the
program as aparameter or
operand. TheZilog
mnemonic DEFL can be used insteadof
SET..TITLE and .SBTTL: The
title
andsubtitle
pseudo-opstake the
form:.TITLE
'string-constant
I'
.SBTTL
'string-constant
2'where
the string-constants
are an ASCIIstring,
enclosedin
apostrophes,
which do not exceed 64characters.
If
a .TITLEand/or .SBTTL
is
encountered during the assembly, then each pageof
thelisting
is prefixed with
thetitle
and,'orsubtitle
string-constant.
Thetitle
line
will
be preceded by astandard
ZASheader as
follows:
MITEK Relocating Macro Assembler vers n.n page nnn
string-constant
l
string-constant
2where n.n
is the
ZASversion
number, nnnis the current
pagenumber and
string-constant
1 and/or 2is
thestring
givenin
thecorresponding
pseudo-op. ZASinitially
assumesthat
thesepseudo-ops are
not in effect.
Whenspecified,
the
title
line,
along
with the
subtitle
line
are notincluded in the line
countCHAPTER 5: PSEUDO-OPS
5.2 LISTING CONTROL PSEUDO-OPS
.LALL: ,L,ist ALL macro
lines,
including
lines
that
donot
generate code..LIST:
This pseudo-op
resumes alisting
which
has been suppressed by the .XLISTdirective.
.LFCOND: The L,ist .F,alse CONDitionals pseudo-op assures the
list-ing
of conditional
expressionsthat
evaluatefalse.
.PRINT: Thepass,text
This
pseudo-opwill
output
text
to the console during
the
specified
pass. The pass can be oneof
three values:O
- print text
during both passes1
- print text
during pass one2
- print text
during pass two.SALÍ): ,S.uppress ALL
of
the macrolisting,
including
all
text
andobject
code produced by macros..SFCOND: The,S.uppress.F.alse CONDitionals pseudo-op suppresses
the
portion of
thelisting
that
containsconditional
expressionsthat
evaluatefalse.
.XALL: The EXclude ALL non-code macro
lines
pseudo-opwill
list
source and
object
code produced by a macro,but
sourcelines
which do not generate code are not
listed.
.XLIST:
This
pseudo-op suppressesall
list
output
until
a .LISTpseudo-op
is
encountered.5.3 CONDITIONAL ASSEMBLY PSEUDO-OPS
The
next
twosections describe the
ZASconditional
assemblyfacility.
5.3.1
IF PSEUDO-OP EVALUATIONZAS has two
different
methodsfor evaluating
the truenessof
anIF expression. One method bases the trueness on the
least
signi-ficant
bit
of
the IF expression, whichis
compatiblewith Digital
Research's ASM, MAC, and RMACassemblers.
The second method basesthe trueness of the expression
onthe
full
16-bit
expres-sion value.
This
methodis compatible with the Microsoft
M80CHAPTER 5: PSEUIXJ-OPS
The
default
evaluation
is
set
bythe
installation
program(section
1.3). Theevaluation
method may also beexplicitly
setby the
following
two pseudo-ops:.IF1
-
will
causeIF expressions to evaluate to true
if
the least
significant bit
of the
IFexpression
evaluates
to
1.OR
.IF16
-
will
cause IF expressionsto
evaluateto true
whenthe IF expression evaluates
to
non-zero.5.3.2
CONDITIONAL ASSEMBLY FYJRMSThe
IF,
ELSE, and ENDIF pseudo-opsdefine
a rangeof
assemblylanguage statements which are
to
be included or excluded duringthe
assemblyprocess.
The IF and ENDIFstatements alone
can be usedto
bound agroup of statements
to
beconditionally
assembled thus:
IF expression statement #1
stat.ernent- #2
e 0
statement #n ENDIF
Upon encountering the IF statement, the assembler evaluates the
expression
following
the IF(all
operandsin
the expression must bedefiríed
aheadof the
IFstatement).
Depending onthe
condi-tional
assemblyoption in effect,
if
the expression evaluatesto
a
non-zero value or the least
significant bit
evaluates to
a 1,then
statement
#1through statement
#n are assembled.If
theexpression evaluates to
azero,
thenthe statements
arelisted
but not assembled.
The ELSE
statement
can be used as analternative
to
an IFstatement,
and must occur betweenthe
IF and ENDIFstatements.
The form
is:
IF expression statement #1
statement #2
0 0 0
statement #n ELSE
statement
#n"l
statement #n"20 9 0
CHAPTER 5: PSEUIX)-OPS
If
the expression
produces
anon-zero
(true)
value,
then
statements
I
through nareassembled.
However,statements rj+j
through m are skippedin
the assembly process. When the
expres-sion
prcxiuces a zerovalue (false),
statements
1through
n areskipped, while statements
n"l
through
m are assembled. As anexample,
the conditional
assembly shownin
Listing
Acould
berewritten
as shownin Listing
B.Listing
ATTY EQU 1
CRT EQU 2
DEVICE EQU TTY TTYOUT EQU OFO03H CRTOUT EQU OF1OOH
IF DEVICE EQ TTY
CALL TTYOUT ENDIF
IF DEVICE EQ CRT
CALL CRTOUT ENDIF
Listinq
BTTY EQU
l
CRT EQU 2
DEVICE EQU TTY TTYOUT EQU OFO03H CRTOUT EQU OF1OOH
IF DEVICE EQ TTY
CALL TTYOUT ELSE
CALL CRTOUT ENDIF
Properly
balancedIF'S,
ELSE'S, and ENDIF's can becompletely
containedwithin
the boundariesof outer
encQmpassingconditional
assembly groups. Thestructure
outlined
below showsproperly
nested IF, ELSE, and ENDIF statements:IF exp#1 group #1 IF exp#2 group#2
ELSE
group#3
ENDIF
group#4
ELSE
group#5 IF exp#3 group#6
ENDIF
group#7
CHAPTER 5: PSEUIXJ-OPS
where group 1
through
7 are sequencesof statements to
beconditionally
assembled, and exp#1 through exp#3 are expressions whichcontrol
theconditional
assembly.If
exp#1is true,
then group#1 and group#4 are always assembled, and group 5,6, and 7will
be skipped. Further,if
exp#l and exp#2 are bothtrue,
then group#2will
also be includedin
the assembly, otherwise group#3will
beincluded.
If
exp#1 produced afalse value,
groups 1, 2,3, and 4
will
beskipped,
and group 5 and 7will
always be assembled.If
under thesecircumstances,
exp#3is true
then group#6will
also be includedwith
5 and 7, otherwiseit
will
beskipped
in
the assembly.Conditional
assemblyof
this
sort
can be nested upto eight
levels (i.e., there
can be upto eight
pending IFSor
ELSEswith
unresolved
ENDIFSat
anypoint
in the assembly), but usually
becomes
unreadable
after
twoor three levels of nesting.
Thenesting level
restriction
also holds for
pending IFS and ELSEsduring macro
evaluation.
Nestinglevel overflow
will
produce anerror
during assembly.5.4 LINKAGE PSEUDO-OPS
EXTRN: The EXTeR.N.al pseudo-op
identifies
symbolswhichare
de-fined in
someother
program but are usedin
the current- program. The formis:
EXTRN symbol
{,syñbol...}
where symbol
is
the symbol being declared asexternal.
Multiple
symbols may be declaredin
the same statement by separating themwith
commas. Also,if
a symbolin
an expressionis suffixed with
one
or
two #signs,
thenthe
symbolis treated
as anexternal.
EXT
is
a synonymfor
EXTRN.NAME: The NAME pseudo-op takes the form: NAME symbol
where symbol
is
therelocatable
module name. This nameis
usedby the
linking
loader andlibrary
managerto identify
the modulefor
selective
loading or manipulation.
Onlythe
first
six
characters aresignificant
in
the module name.In
the absence ofthe NAME pseudo-op, up
to
thefirst
six
charactersof
the programname are used.
PUBLIC: The PUBLIC pseudo-op
identifies
those symbolswithin
thecurrent
program which areto
be made accessibleto
other programs asexternal
symbols.This
directive
has noeffect
onthe
assembly processfor
thecurrent
program, but merely records the name andvalue of the
identified
symbols onthe object
file
for
later
use by thelinking
loader. Apublic
symbol must be definedCHAPTER 5: PSEUDO-OPS
.REQUEST: Request a
library
search. The formis:
.REQUEST filename{,fi1ename...}
This
pseudo-op sends arequest
to
ZLINKor
anyMicrosoft
compatible
loader to
searchthe filenames
in the
list
for
undefinedexternal
symbols. The filenamein
thelist
should notinclude
filetypes
or device designation.
ZLINK assumesthe
default
extension .REL and thecurrently
loggeddisk drive.
5.5 REIÁJCATICN BASE PSEUDO-OPS
ASEG: The Absolute SEGment pseudo-op never has operands. ASEG
generates
non-relocatable
code.ASEG
sets the location
counter to
anabsolute
segment(actual
address)
of
memory. The ASEGwill
default
to
O, whichcould
cause the module
to write
overpart of
the oFerating system.It
is
recommendedthat
each ASEG befollowed with
an ORG statementset
at
1OOHor
higher.COMMON: COMMON statements are non-executable, storage
allocating
statements.
COMMONassigns variables,
arrays,
anddata to
astorage area
called
COMMON storage. Thisallows various
programmodules
to
sharethe
samestoragearea.
Thelengthof
aCOMMONarea
is the
numberof bytes required to contain the variables,
arrays, anddata declared in the
COMMONblock,
which ends whenanother
relocation
base pseudo-opis
encountered.CSEG: The C.ode SEGment
directive
never has an operand. Codeassembled
in
CodeRelative
mode can be loadedinto
ROM/PROM.CSEG resets the
location
counterto
the coderelative
segmentof
memory. The
location
will
bethat of the
last
CSEG(defaultto
O), unless an ORG
is
doneafter
the CSEGto
change thelocation.
However
the
ORGstatement
doesnot set
ahardabsoluteaddress
under CSEG mode. An ORG statement under CSEG causes the
assem-bler
to
addthe
numberof bytes specified
bythe expression
argumentin the
ORGstatement to the
last
CSEG address loaded.For example,
if
ORG 25is given,
25bytes
will
be addedto the
current
CSEGlocation.
ThencsEgwill
be loaded. Theclearing
effect of
the ORG statementfollowing
CSEG (and DSEG) can be usedto
give the module anoffset.
Rationalefor
notallowing
ORGto
set an absolute address
for
CSEGis to
keep the CSEGrelocatable.
CSEGis
thedefault
modeof
the assembler. ZWsembly beginswith
a CSEGautomatically
executed, andthe location
counter in the
Code
Relative
mode,pointing to location
Ointhe
CodeRelative
segment
of
memory.All
subsequentinstructions
will
be assembledinto the
CodeRelative
segmentof
memoryuntil
ASEG, DSEG,or
COMMON