OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [zmac/] [zmac.html] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
<H3>Overview of zmac</H3>
2
zmac is a Z-80 macro cross-assembler. It has all the features you'd
3
expect. It assembles the specified input file (with a '.z' extension
4
if there is no pre-existing extension and the file as given doesn't
5 21 gdevic
exist) and produces program output in many different <A HREF="#format">formats</A>.
6 3 gdevic
It also produces a nicely-formatted
7
listing of the machine code and cycle counts alongside the source
8
in a ".lst" file.
9
<P>
10 21 gdevic
To reduce clutter and command line option usage, by default all zmac output is put
11 3 gdevic
into an (auto-created) <TT>zout</TT> subdirectory.  For <TT>file.z</TT> the listing
12
will be in <TT>zout/file.lst</TT>, the TRS-80 executable format in <TT>zout/file.cmd</TT>
13 21 gdevic
and so on.  For more friendly usage in make files and integrated development
14
environments the <TT>-o</TT>, <TT>--oo</TT>, <TT>--xo</TT> and <TT>--xd</TT> options may be used to select
15
sepcific output file formats and where they are written.
16 3 gdevic
<P>
17
<A HREF="#undoc">Undocumented</A> Z-80 instructions are supported as well as 8080 code.
18
<P>
19
zmac strives to be a powerful assembler with expressions familiar to C
20
programmers while providing good backward compatibility with original
21
assemblers such as Edtasm, MRAS and Macro-80.
22
<HR>
23
<H3>Usage</H3>
24
zmac
25
[ --help ]
26
[ --version ]
27
[ --dep ]
28
[ --mras ]
29 21 gdevic
[ --od dir ]
30
[ --oo sfx1,sfx2 ]
31
[ --xo sfx1,sfx2 ]
32 3 gdevic
[ --rel ]
33 21 gdevic
[ --rel7 ]
34 3 gdevic
[ --doc ]
35
[ --zmac ]
36
[ -8bcefghijJlLmnopstz ]
37
[ filename[.z] ]
38
<P>
39
<H3>Options</H3>
40
<P>
41
<TABLE>
42
<TR><TD VALIGN="TOP"><PRE>--help </PRE></TD><TD>Display a list of options and a terse description of what the options do. </TD></TR>
43
<TR><TD VALIGN="TOP"><PRE>--version </PRE></TD><TD>Print zmac version name. </TD></TR>
44 21 gdevic
<TR><TD VALIGN="TOP"><PRE>--mras </PRE></TD><TD>MRAS compatibility mode.  Any <TT>?</TT> in a label will be expanded to the current module identifier as set by <TT>*mod</TT>. Operator <A HREF="#mrasord">precedence</A> and results are changed. </TD></TR>
45
<TR><TD VALIGN="TOP"><PRE>--od dir </PRE></TD><TD>Place output files in <TT>dir</TT> instead of the default "zout" subdirectory. Creates <TT>dir</TT> if necessary. </TD></TR>
46
<TR><TD VALIGN="TOP"><PRE>--oo hex,cmd </PRE></TD><TD>Output only the the file types by suffix.  Multiple --oo arguments may be used.  "--oo lst,cas" is equivalent to "--oo lst --oo cas". See "Output Formats" for a list of output types by <A HREF="#format">suffix</A>. </TD></TR>
47
<TR><TD VALIGN="TOP"><PRE>--xo tap,wav </PRE></TD><TD>Do not output the file type types listed by suffix.  </TD></TR>
48
<TR><TD VALIGN="TOP"><PRE>--rel </PRE></TD><TD>Output ".rel" (relocatable object file) format only.  Exported symbols are truncated to length 6. </TD></TR>
49
<TR><TD VALIGN="TOP"><PRE>--rel7 </PRE></TD><TD>Output ".rel" (relocatable object file) format only.  Exported symbols are truncated to length 7. </TD></TR>
50 3 gdevic
<TR><TD VALIGN="TOP"><PRE>--zmac </PRE></TD><TD>zmac compatibility mode.  <TT>defl</TT> labels are undefined after each pass. Quotes and double quotes are stripped from macro arguments before expansion. <TT>$</TT> is ignored in identifiers allowing <TT>foo$bar</TT> to construct identifiers in macro expansions.  Use <TT>`</TT> (backquote) instead in normal mode.  Labels starting with <TT>"."</TT> are temporary and are reset whenever a non-temporary label is defined (thus they may be reused).  Labels starting with <TT>"_"</TT> are local to their file thus avoid multiple definition when brought in with <TT>include</TT>. </TD></TR>
51 21 gdevic
<TR><TD VALIGN="TOP"><PRE>--dep </PRE></TD><TD>Print all files read by <TT>include</TT>, <TT>incbin</TT> and <TT>import</TT>. </TD></TR>
52 3 gdevic
<TR><TD VALIGN="TOP"><PRE>--doc </PRE></TD><TD>Print this documentation in HTML format to standard output. </TD></TR>
53 21 gdevic
<TR><TD VALIGN="TOP"><PRE>-Pk=number </PRE></TD><TD>Set <TT>@@k</TT> to the given numeric value before assembly.  Up to 10 parameters can be set from 0 though 9.  <TT>-Pk</TT> is shorthand for <TT>-Pk=-1</TT>. For example, <TT>P4=$123</TT> effectively puts <TT>@@4 equ $123</TT> at the top of the first file. </TD></TR>
54
<TR><TD VALIGN="TOP"><PRE>-8 </PRE></TD><TD>Accept 8080 mnemonics preferentially and use 8080 instruction timings. Equivalent to <TT>.8080</TT> pseudo-op. </TD></TR>
55 3 gdevic
<TR><TD VALIGN="TOP"><PRE>-b </PRE></TD><TD>Don't generate any machine code output at all. </TD></TR>
56 21 gdevic
<TR><TD VALIGN="TOP"><PRE>-c </PRE></TD><TD>Don't display cycle counts in the listing. </TD></TR>
57 3 gdevic
<TR><TD VALIGN="TOP"><PRE>-e </PRE></TD><TD>Omit the "error report" section in the listing. </TD></TR>
58
<TR><TD VALIGN="TOP"><PRE>-f </PRE></TD><TD>List instructions not assembled due to "<TT>if</TT>" expressions being false. (Normally these are not shown in the listing.) </TD></TR>
59
<TR><TD VALIGN="TOP"><PRE>-g </PRE></TD><TD>List only the first line of equivalent hex for a source line. </TD></TR>
60
<TR><TD VALIGN="TOP"><PRE>-h </PRE></TD><TD>Display a list of options and a terse description of what the options do. (same as --help) </TD></TR>
61 21 gdevic
<TR><TD VALIGN="TOP"><PRE>-i </PRE></TD><TD>Don't list files included with <TT>include</TT>, <TT>read</TT> or <TT>import</TT>. </TD></TR>
62 3 gdevic
<TR><TD VALIGN="TOP"><PRE>-I dir </PRE></TD><TD>Add <TT>dir</TT> to the end of the include file search path. </TD></TR>
63
<TR><TD VALIGN="TOP"><PRE>-j </PRE></TD><TD>Promote relative jumps and <TT>DJNZ</TT> to absolute equivalents as needed. </TD></TR>
64
<TR><TD VALIGN="TOP"><PRE>-J </PRE></TD><TD>Error if an absolute jump could be replaced with a relative jump. </TD></TR>
65 21 gdevic
<TR><TD VALIGN="TOP"><PRE>-l </PRE></TD><TD>List to standard output. </TD></TR>
66 3 gdevic
<TR><TD VALIGN="TOP"><PRE>-L </PRE></TD><TD>Generate listing no matter what. Overrides any conflicting options. </TD></TR>
67
<TR><TD VALIGN="TOP"><PRE>-m </PRE></TD><TD>List macro expansions. </TD></TR>
68
<TR><TD VALIGN="TOP"><PRE>-n </PRE></TD><TD>Omit line numbers from listing. </TD></TR>
69 21 gdevic
<TR><TD VALIGN="TOP"><PRE>-o filename.cmd </PRE></TD><TD>Output only the named file.  Multiple "-o" options can be used to name a set of different files. </TD></TR>
70 3 gdevic
<TR><TD VALIGN="TOP"><PRE>-p </PRE></TD><TD>Use a few linefeeds for page break in listing rather than ^L. </TD></TR>
71
<TR><TD VALIGN="TOP"><PRE>-P </PRE></TD><TD>Output listing for a printer with headers, multiple symbols per column, etc. </TD></TR>
72
<TR><TD VALIGN="TOP"><PRE>-s </PRE></TD><TD>Omit the symbol table from the listing. </TD></TR>
73
<TR><TD VALIGN="TOP"><PRE>-t </PRE></TD><TD>Only output number of errors instead list of each one. </TD></TR>
74 21 gdevic
<TR><TD VALIGN="TOP"><PRE>-z </PRE></TD><TD>Accept Z-80 mnemonics preferentially and use Z-80 instruction timings. Equivalent to <TT>.z80</TT> pseudo-op. </TD></TR>
75 3 gdevic
</TABLE>
76
<HR>
77
<H3>Input Format</H3>
78
<P>
79
zmac uses the standard Zilog mnemonics, and the pseudo-ops are also
80
largely as you'd expect.
81
<P>
82
A "<TT>.</TT>" may optionally preceeed any psuedo-op.
83
For example, "<TT>.org</TT>" and "<TT>org</TT>" are treated as equivalent.
84
<P>
85
Input can be upper or lowercase.
86
<P>
87
Comments start with <TT>;</TT> and carry on to the end of the line.
88
<P>
89
Number constants can take a trailing h or a leading $ or 0x for hex,
90
a trailing b for binary, a trailing o or q for octal, or a trailing
91
d for decimal.
92
<P>
93
<TT>'LH'</TT> (any length 2 string) can be treated as a number whose value
94
is <TT>'H'</TT> * 256 + <TT>'L'</TT>.
95
<P>
96
Labels are declared with <TT>label:</TT> or just <TT>label</TT> - indentation is unimportant.
97
Labels can be up to 40 chars long.  They can start with and contain
98
letters, digits, <TT>$</TT>, <TT>.</TT>, <TT>?</TT>, <TT>@</TT> and _.  Ambiguous identifiers like
99
<TT>$FCB</TT> will be treated as hex constants unless defined as a label.  Labels
100
declared with two colons (<TT>label::</TT>) make the label public.
101
<P>
102 21 gdevic
Single quotes are ignored at the end of identifiers allowing non-binding
103
<A HREF="#prime">notation</A> indicating alternate register use during heavy applications
104
of <TT>exx</TT> and <TT>ex</TT>.
105
<P>
106 3 gdevic
Here is how other things work.  Numbers are used as examples, but a full
107
<A HREF="#expr">expression</A> can be used in their place.
108
<P>
109
<H4>Data</H4>
110
<P>
111
<TT>defb 42</TT>
112 21 gdevic
<BLOCKQUOTE>A byte.  <TT>ascii</TT>, <TT>byte</TT>, <TT>db</TT>, <TT>defm</TT>, <TT>dm</TT> and <TT>text</TT> are synonyms.
113 3 gdevic
</BLOCKQUOTE>
114
<P>
115
<TT>defb 'foobar'</TT>
116
<BLOCKQUOTE>An ASCII character string (not NUL-terminated).
117
Double quotes can also be used.
118
</BLOCKQUOTE>
119
<P>
120
<TT>defb 'Who needs anything more than CP/M?',13,10,'$'</TT>
121
<BLOCKQUOTE>Strings and bytes can mix together.
122
</BLOCKQUOTE>
123
<P>
124
<TT>defw 2112</TT>
125
<P>
126
<TT>defw $123,0x456</TT>
127
<BLOCKQUOTE>A word (16 bits).  <TT>word</TT> and <TT>dw</TT> are synonyms.
128
</BLOCKQUOTE>
129
<P>
130
<TT>defd $12345678</TT>
131
<BLOCKQUOTE>A double word (32 bits). <TT>dword</TT> is a synonym.
132
</BLOCKQUOTE>
133
<P>
134
<TT>defs 500</TT>
135
<BLOCKQUOTE>Skip output ahead 500 bytes.  This will insert 500 zeros in the ".ams"
136
and ".cim" output files or if inside a ".phase" section.
137
<TT>block</TT>, <TT>ds</TT> and <TT>rmem</TT> are synonyms.
138
</BLOCKQUOTE>
139
<P>
140
<TT>dc 'string'</TT>
141
<BLOCKQUOTE>Like <TT>ascii</TT> but accepts only a single string and the high bit of the
142 21 gdevic
last character will be set. <TT>bytes</TT> is a synonym.
143 3 gdevic
</BLOCKQUOTE>
144
<P>
145
<TT>dc count,value</TT>
146
<BLOCKQUOTE>Repeat the byte <TT>value</TT> a total of <TT>count</TT> times.  Similar to <TT>defs</TT>
147
except that memory is always filled with <TT>value</TT>.
148
</BLOCKQUOTE>
149
<P>
150
<TT>incbin file</TT>
151
<BLOCKQUOTE>Inserts the raw contents of the file into the assembly.  Simpler for
152
large amounts of data.
153
</BLOCKQUOTE>
154
<P>
155
<H4>Symbols</H4>
156
<P>
157
<TT>label equ 100</TT>
158
<BLOCKQUOTE>Define a symbol to have a fixed value.  The symbol can be used before it
159
is defined.  A symbol defined with <TT>equ</TT> or as a label can be defined only
160
once, except that a symbol defined with <TT>equ</TT> may be redefined to the
161
same value.
162
</BLOCKQUOTE>
163
<P>
164 21 gdevic
<TT>varname defl 200</TT>
165 3 gdevic
<BLOCKQUOTE>Define a symbol to have a changeable value.  The symbol cannot be used
166
before it is defined, and it can be redefined to a different value later
167 21 gdevic
with another <TT>defl</TT>. <TT>aset</TT>, <TT>set</TT> and <TT>=</TT> are synonyms (despite <TT>set</TT>
168
also being a Z-80 mnemonic).
169 3 gdevic
</BLOCKQUOTE>
170
<P>
171 21 gdevic
<TT>varname OP = expression</TT>
172
<BLOCKQUOTE>Shorthand for <TT>varname defl varname OP expression</TT>.  Allows for C-like
173
handling of variable such as <TT>var += 5</TT>.  <TT>OP</TT> can be <TT>+</TT>, <TT>-</TT>, <TT>*</TT>, <TT>/</TT>,
174
<TT>%</TT>, <TT>&amp;</TT>, <TT>|</TT>, <TT>^</TT>, <TT>&lt;&lt;</TT>, <TT>&gt;&gt;</TT>, <TT>&amp;&amp;</TT> or <TT>||</TT>.
175
</BLOCKQUOTE>
176
<P>
177
<TT>varname++</TT>
178
<BLOCKQUOTE>Shorthand for <TT>varname defl varname + 1</TT>
179
</BLOCKQUOTE>
180
<P>
181
<TT>varname--</TT>
182
<BLOCKQUOTE>Shorthand for <TT>varname defl varname - 1</TT>
183
</BLOCKQUOTE>
184
<P>
185 3 gdevic
<TT>min</TT>
186
<P>
187
<TT>max</TT>
188
<BLOCKQUOTE>Same as <TT>defl</TT> except that the symbol is defined as the
189
smaller or bigger of two comma-separated expressions.
190
</BLOCKQUOTE>
191
<P>
192
<TT>*mod</TT>
193
<BLOCKQUOTE>Increment the internal module name string.  The first time this results
194
in "a".  Then "b", "c", ... "z".  Then "aa", "ab", "ac", etc. all the way
195
up to "zzzz".  The module name string is used in <TT>--mras</TT> mode where "?" in
196
label names is replaced with the current module name.
197
</BLOCKQUOTE>
198
<P>
199
<TT>extern lab1,lab2,...</TT>
200
<BLOCKQUOTE>The listed labels are defined in an external module for later linking.
201
No effect unless zmac is producing ".rel" output.
202
<TT>ext</TT> and <TT>extrn</TT> are synonyms.
203
</BLOCKQUOTE>
204
<P>
205
<TT>public lab1,lab2,...</TT>
206
<BLOCKQUOTE>The given labels will be visible to external modules when linking.
207
No effect unless zmac is producing ".rel" output.
208
<TT>global</TT> and <TT>entry</TT> are synonyms.
209
</BLOCKQUOTE>
210
<P>
211 21 gdevic
<TT>label ++</TT>
212
<BLOCKQUOTE>Equivalent to <TT>label defl label + 1</TT>.
213
</BLOCKQUOTE>
214
<P>
215
<TT>label --</TT>
216
<BLOCKQUOTE>Equivalent to <TT>label defl label - 1</TT>.
217
</BLOCKQUOTE>
218
<P>
219
<TT>label += 10</TT>
220
<P>
221
<TT>label -= 10</TT>
222
<P>
223
<BLOCKQUOTE>Equivalent to <TT>label defl label + 10</TT> and <TT>label defl label - 10</TT> respectively.
224
Also works for <TT>*=</TT>, <TT>/=</TT>, <TT>%=</TT>, <TT>|=</TT>, <TT>&amp;=</TT>, <TT>^=</TT>, <TT>&lt;&lt;=</TT> and <TT>&gt;&gt;=</TT>.
225
</BLOCKQUOTE>
226
<P>
227 3 gdevic
<H4>Location Control</H4>
228
<P>
229
<TT>org 9000h</TT>
230
<BLOCKQUOTE>Set the address to assemble to 0x9000.
231
</BLOCKQUOTE>
232
<P>
233
<TT>phase address</TT>
234
<BLOCKQUOTE>Continue to produce code and data for loading at the current address
235
but assemble instructions and define labels as if they originated at
236
the given address.  Useful when producing code that will be copied to
237
a different location before being executed (e.g., an overlay).
238
</BLOCKQUOTE>
239
<P>
240
<TT>dephase</TT>
241
<BLOCKQUOTE>End <TT>phase</TT> mode assembly.
242
</BLOCKQUOTE>
243
<P>
244
<TT>aseg</TT>
245
<TT>cseg</TT>
246
<TT>dseg</TT>
247
<BLOCKQUOTE>Switch to the absolute, code and data segments respectively.
248
No effect unless zmac is producing ".rel" output.
249
</BLOCKQUOTE>
250
<P>
251 21 gdevic
<TT>common /name/</TT>
252
<BLOCKQUOTE>Set the address to the start of the selected common block.  The blank
253
common block will be selected if name is empty or all blanks or
254
omitted entirely.
255
No effect unless zmac is producing ".rel" output.
256
</BLOCKQUOTE>
257
<P>
258 3 gdevic
<H4>Input Control</H4>
259
<P>
260
<TT>end</TT>
261
<BLOCKQUOTE>Ends the input.  Any lines after an <TT>end</TT> are silently ignored.
262
If an arg is given, it declares the entry address for the program.
263
This has no effect in ".cim" output. In ".hex" output
264
it generates an S-record directing 0 bytes of data to be loaded
265 21 gdevic
at the given address.  It is required for ".500.cas", ".1000.cas"
266
and ".1500.cas" output.
267 3 gdevic
</BLOCKQUOTE>
268
<P>
269
<TT>if</TT> ... [ <TT>else</TT> ... ] <TT>endif</TT>
270
<BLOCKQUOTE>For conditional assembly. If you do <TT>if foo</TT> and <TT>foo</TT> evaluates to
271
zero, all the lines up until the next corresponding <TT>else</TT> or <TT>endif</TT>
272
are completely ignored.  Conversely, if <TT>foo</TT> evaluates to non-zero, any
273
lines from a corresponding <TT>else</TT> to the <TT>endif</TT> are ignored.  Ifs can
274
be nested.  <TT>cond</TT>/<TT>endc</TT> are synonyms for <TT>if</TT>/<TT>endif</TT>.
275
</BLOCKQUOTE>
276
<P>
277 21 gdevic
<TT>ifdef symbol</TT>
278
<BLOCKQUOTE>Like <TT>if</TT>, but tests if <TT>symbol</TT> has been defined.  Declaring a symbol
279
as external counts as it being defined.
280
</BLOCKQUOTE>
281
<P>
282
<TT>ifndef symbol</TT>
283
<BLOCKQUOTE>Like <TT>if</TT>, but tests if <TT>symbol</TT> has not yet been defined.
284
</BLOCKQUOTE>
285
<P>
286
<TT>import file</TT>
287
<BLOCKQUOTE>Like <TT>include</TT> but will only bring in the file once.  File tracking is done
288
using only the file name so, for example, an <TT>import file</TT> will stop
289
both <TT>import ./file</TT> and <TT>import dir/file</TT> even if they actually refer to
290
different files.
291
</BLOCKQUOTE>
292
<P>
293 3 gdevic
<TT>include file</TT>
294
<BLOCKQUOTE>Include a file. Like C's (well, cpp's) #include and follows the same
295
include path search rules, but the filename arg
296
lacks the angle brackets or quotes (though single or double quotes may be used).
297 21 gdevic
<TT>read</TT> is a synonym.  <TT>*include file</TT> also works if started in the first
298
column.  In <TT>--mras</TT> mode <TT>".asm"</TT> will be added if <TT>file</TT> has
299
no suffix.
300 3 gdevic
</BLOCKQUOTE>
301
<P>
302 21 gdevic
<TT>maclib file</TT>
303
<BLOCKQUOTE>Like <TT>include</TT> but adds <TT>.lib</TT> to the file name so includes <TT>file.lib</TT>.
304
</BLOCKQUOTE>
305
<P>
306 3 gdevic
<TT>comment X</TT>
307
<BLOCKQUOTE>Suspend assembly until the next occurence of character <TT>X</TT> on a line.
308
The rest of the line will be ignored.  A multi-line comment.
309
</BLOCKQUOTE>
310
<P>
311
<TT>assert expr</TT>
312
<BLOCKQUOTE>Stop assembly if <TT>expr</TT> is non-zero.
313
</BLOCKQUOTE>
314
<P>
315
<H4>Cycle Counting</H4>
316
<P>
317
<TT>sett expr</TT>
318
<BLOCKQUOTE>Set the current T-state count to <TT>expr</TT>. <TT>tstate</TT> is a synonym.
319
</BLOCKQUOTE>
320
<P>
321
<TT>setocf expr</TT>
322
<BLOCKQUOTE>Set the current opcode fetch count to <TT>expr</TT>.
323
</BLOCKQUOTE>
324
<P>
325
<H4>Code Generation</H4>
326
<P>
327
<TT>8080</TT>
328
<BLOCKQUOTE>Make cycle counting operators return 8080 cycle counts and
329
interpret any ambiguous assembly statements as Intel 8080 mnemonics.
330
<TT>CP</TT> will be interpreted as "call on positive" and <TT>JP</TT> as "jump on positive".
331
</BLOCKQUOTE>
332
<P>
333
<TT>z80</TT>
334
<BLOCKQUOTE>Make cycle counting operators return Z-80 cycle counts and
335
interpret any ambiguous assembly statements as Zilog Z-80 mnemonics.
336
<TT>CP</TT> will be interpreted as "compare accumulator" and <TT>JP</TT> as "jump unconditionally".
337
</BLOCKQUOTE>
338
<P>
339
<TT>jperror enable</TT>
340
<BLOCKQUOTE>If <TT>enable</TT> is non-zero, turn on errors when <TT>JR</TT> instructions could be used
341
instead of <TT>JP</TT>, off otherwise.  Used to check existing code for situations
342
where shorter code could be generated.  Same as <TT>-J</TT> option.
343
No effect if in 8080 mode.
344
</BLOCKQUOTE>
345
<P>
346
<TT>jrpromote enable</TT>
347
<BLOCKQUOTE>If <TT>enable</TT> is non-zero, <TT>JR</TT> and <TT>DJNZ</TT> instructions will be promoted to
348
equivalent <TT>JP</TT> and <TT>DEC&nbsp;B</TT>, <TT>JP&nbsp;NZ</TT> instructions if the relative branch
349
offset is out of range.  If <TT>enable</TT> is zero, promotion is disabled.
350
Same as the <TT>-j</TT> option.
351
No effect if in 8080 mode.
352
</BLOCKQUOTE>
353
<P>
354
<H4>Undocumented <A NAME="undoc">Instructions</A></H4>
355
<P>
356
Most Z-80 chips support a number of undocumented instructions that were part of
357
the original design but not made an offical part of the Zilog specification.
358
These instructions may not be supported by all Z-80 chips, especially
359
licensed variants, but are fairly widely available nonetheless.
360
<P>
361
<TT>sl1 r</TT>
362
<BLOCKQUOTE>Same as <TT>sla r</TT> but shifts a 1 into the lower bit of <TT>r</TT> rather than a 0.
363
</BLOCKQUOTE>
364
<P>
365
<TT>in (c)</TT>
366
<BLOCKQUOTE>Inputs a byte from port <TT>c</TT> but does not store the value.  Flags are still
367
set as with the normal <TT>in r,(c)</TT> instruction.
368
</BLOCKQUOTE>
369
<P>
370
<TT>out (c),0</TT>
371
<BLOCKQUOTE>Outputs a zero to port <TT>c</TT>.
372
</BLOCKQUOTE>
373
<P>
374
<TT>bit/set/res n,(ix+d),r</TT>
375
<P>
376
<TT>rlc/rrc/rl/rr/sla/sl1/sra/srl (iy+d),r</TT>
377
<BLOCKQUOTE>Same as the corresponding operation on just <TT>(ix+d)</TT> or <TT>(iy+d)</TT> but with
378
the result being stored both into <TT>(ix+d)</TT> and register <TT>r</TT>.  Except for <TT>bit</TT>
379
which has no effect on <TT>r</TT>. zmac supports the syntax to allow those
380
instruction patterns to be generated.
381
</BLOCKQUOTE>
382
<P>
383
The upper and lower bytes of the <TT>ix</TT> and <TT>iy</TT> can be used in a number of
384
instructions much in the same way as <TT>d</TT> and <TT>e</TT> correspond to the upper and
385
lower bytes of <TT>de</TT>.  zmac names these <TT>ixh</TT>, <TT>ixl</TT>, <TT>iyh</TT> and <TT>iyl</TT> and
386
are referred to generically as <TT>ixylh</TT> here.
387
<P>
388
<TT>inc/dec/add/adc/sub/sbc/and/xor/or/cp ixylh</TT>
389
<BLOCKQUOTE>Arithmetic or logical operation on <TT>ix</TT> or <TT>iy</TT> high or low byte.
390
</BLOCKQUOTE>
391
<P>
392
<TT>ld a/b/c/d/e,ixylh</TT>
393
<BLOCKQUOTE>Load register with <TT>ix</TT> or <TT>iy</TT> high or low byte.
394
</BLOCKQUOTE>
395
<P>
396
<TT>ld ixylh,a/b/c/d/e</TT>
397
<BLOCKQUOTE>Load <TT>ix</TT> or <TT>iy</TT> high or low byte with register.
398
</BLOCKQUOTE>
399
<P>
400
<TT>pfix</TT>
401
<P>
402
<TT>pfiy</TT>
403
<BLOCKQUOTE>Output $DD and $FD prefix bytes.  The Z-80 allows multiple prefix bytes
404
for IX and IY instructions.  This allows you to specify them abstractly.
405
There is little purpose except for delaying an interrupt or confusing
406
disassemblers.
407
</BLOCKQUOTE>
408
<P>
409
<H4>Miscellaneous</H4>
410
<P>
411 21 gdevic
<TT>pragma str ...</TT>
412
<BLOCKQUOTE>Like C's #pragma, a generic hook for special purpose operations.  Only two
413
are currently defined.
414
</BLOCKQUOTE>
415
<P>
416
<BLOCKQUOTE><TT>pragma bds rest-of-line</TT> to
417
output <TT>rest-of-line</TT> to the <TT>.bds</TT> output file.
418
</BLOCKQUOTE>
419
<P>
420
<BLOCKQUOTE><TT>pragma mds rest-of-line</TT> to
421
output <TT>rest-of-line</TT> to the <TT>.mds</TT> output file.
422
</BLOCKQUOTE>
423
<P>
424
<BLOCKQUOTE>The <TT>.bds</TT> output format supports setting initial values for Z-80 registers
425
and I/O ports so <TT>pragma</TT> gives you access to that.
426
</BLOCKQUOTE>
427
<P>
428
<BLOCKQUOTE>The <TT>.mds</TT> output format is a MAME debug script thus additional initial
429
debugging commands may be output.  Of particular use on the TRS-80 Model II
430
is <TT>pragma mds ib@$ff=1</TT> which maps page 1 of RAM into $8000 .. $FFFF
431
and thus allows programs to load into that area.
432
</BLOCKQUOTE>
433
<P>
434 3 gdevic
<TT>name str</TT>
435 21 gdevic
<BLOCKQUOTE>Set the name of the output module to <TT>str</TT>.  For compatibility reasons
436 3 gdevic
<TT>str</TT> may be parenthesized (e.g., "<TT>name ('foo')</TT>").  Not all output
437
formats support an internal name and many have severe length limits.
438
</BLOCKQUOTE>
439
<P>
440
<TT>rsym</TT> and <TT>wsym</TT>
441
<BLOCKQUOTE>Read/write a symbol file. These simply load/save the currently defined
442
symbols from/to the file specified (in a non-portable format). <TT>rsym</TT>
443
takes place at the point it is encountered in the file (on the first
444
pass); <TT>wsym</TT> is delayed until assembly has finished.
445
</BLOCKQUOTE>
446
<P>
447
<H4>Listing Pseudo-ops</H4>
448
<P>
449
There are several pseudo-ops for controlling the listing. None of
450
these ops appear in the listing themselves:
451
<P>
452
<TT>eject</TT>
453
<BLOCKQUOTE>Start a new listing page.
454
</BLOCKQUOTE>
455
<P>
456
<TT>nolist</TT>
457
<BLOCKQUOTE>Do nothing. This can be used to have a comment in the source but not
458
the listing, I suppose.
459
</BLOCKQUOTE>
460
<P>
461
<TT>elist</TT>, <TT>flist</TT>, <TT>glist</TT>, <TT>mlist</TT>
462
<BLOCKQUOTE>These have the same effect as the similarly-named command-line
463
options, though possibly with the sense reversed depending on the
464
default. Use an arg &gt;0 (or no arg) to enable, and an arg &lt;0 to
465
disable.
466
</BLOCKQUOTE>
467
<P>
468 21 gdevic
<TT>list arg</TT>
469
<BLOCKQUOTE>Turns output to listing file (.list) off if <TT>arg</TT> &lt; 0 or on if <TT>arg</TT> &gt; 0.
470
If no <TT>arg</TT> supplied then listing is enabled.
471
Use this to avoid listing certain parts of the source.
472
In <TT>--mras</TT> mode <TT>arg</TT> must be either <TT>on</TT> or <TT>off</TT> and
473
<TT>*list</TT> can be used if started in the first column.
474 3 gdevic
</BLOCKQUOTE>
475
<P>
476
<TT>title</TT>
477
<BLOCKQUOTE>Set title (used in listing and symbol file).
478
</BLOCKQUOTE>
479
<P>
480 21 gdevic
<TT>space arg</TT>
481 3 gdevic
<BLOCKQUOTE>Output arg blank lines in the listing, or one line if no arg is given.
482
</BLOCKQUOTE>
483
<P>
484
<HR>
485
<P>
486
<H3><A NAME="expr">Expressions</A></H3>
487
<P>
488
Expressions feature a full set of C operators with the same precedence
489
rules and some common assembler extensions and names.
490
Here is the complete list of operators, highest-precedence first.
491
Operators separated only by a space are synonyms; for example, <TT>~</TT>
492
is the same as <TT>not</TT>.
493
<P>
494
<TT>!</TT> (logical), <TT>~ not</TT> (bitwise), <TT>+</TT> (unary), <TT>-</TT> (unary), <TT>low</TT>, <TT>high</TT>, <TT>t</TT>, <TT>tilo</TT>, <TT>tihi</TT>, <TT>ocf</TT>
495
<P>
496
<TT>*</TT>, <TT>/</TT>, <TT>% mod</TT>
497
<P>
498
<TT>+</TT>, <TT>-</TT>
499
<P>
500
<TT>&lt;&lt; shl</TT>, <TT>&gt;&gt; shr</TT>
501
<P>
502
<TT>&lt; lt</TT>, <TT>&gt; gt</TT>, <TT>&lt;= le</TT>, <TT>&gt;= ge</TT>
503
<P>
504
<TT>== = eq</TT>, <TT>!= &lt;&gt; ne</TT>
505
<P>
506
<TT>&amp; and</TT> (bitwise)
507
<P>
508
<TT>^ xor</TT> (bitwise)
509
<P>
510
<TT>| or</TT> (bitwise)
511
<P>
512
<TT>&amp;&amp;</TT>
513
<P>
514
<TT>||</TT>
515
<P>
516
<TT>? :</TT>  (ternary choice operator)
517
<P>
518 21 gdevic
<A NAME="mrasord">Expressions</A> change significantly in <TT>--mras</TT> mode:
519
<BLOCKQUOTE>Evaluation is strictly left to right.  Except for <TT>and</TT>, <TT>or</TT>,
520
<TT>xor</TT> and <TT>=</TT>.  This doesn't break compatibility as original MRAS
521
source code only allows <TT>.and.</TT>, <TT>.or.</TT> and <TT>.xor.</TT> but the precedence
522
difference may surprise if code is added.
523
</BLOCKQUOTE>
524
<P>
525
<BLOCKQUOTE><TT>!</TT> is bitwise OR instead of logical not.
526
</BLOCKQUOTE>
527
<P>
528
<BLOCKQUOTE><TT>&lt;</TT> is left shift (or right shift when shift amount is negative)
529
</BLOCKQUOTE>
530
<P>
531
<BLOCKQUOTE>MRAS operators (<TT>.and.</TT> <TT>.eq.</TT> <TT>.ge.</TT> <TT>.gt.</TT> <TT>.high.</TT> <TT>.le.</TT> <TT>.low.</TT>
532
<TT>.lt.</TT> <TT>.mod.</TT> <TT>.ne.</TT> <TT>.not.</TT> <TT>.or.</TT> <TT>.shl.</TT> <TT>.shr.</TT> <TT>.xor.</TT>)
533
are recognized even if apparently in identifers.  (e.g., <TT>a.or.b</TT> is
534
seen as <TT>a .or. </TT>b).
535
</BLOCKQUOTE>
536
<P>
537
<BLOCKQUOTE>Logical operators return -1 for true and 0 for false.  Normally
538
zmac, like C, uses 1 for true.
539
</BLOCKQUOTE>
540
<P>
541 3 gdevic
You can use normal parentheses or square brackets to override
542
the precedence rules. Square brackets can be used where parentheses would
543
conflict with Z-80 mnemonic syntax, but this is not necessary in any
544
practical case.
545
<P>
546
The <TT>?</TT> may need spaces around it to distinguish it from a label that
547
has <TT>?</TT> in it.
548
<P>
549
The unary operators not familiar to C programmers:
550
<P>
551
<TABLE>
552
<TR><TD VALIGN="TOP"><PRE>low expr </PRE></TD><TD>Returns low 8 bits of <TT>expr</TT> </TD></TR>
553
<TR><TD VALIGN="TOP"><PRE>high expr </PRE></TD><TD>Returns high 8 bits of <TT>expr</TT> </TD></TR>
554
<TR><TD VALIGN="TOP"><PRE>t expr </PRE></TD><TD>Current count of T-states up to memory location <TT>expr</TT> </TD></TR>
555
<TR><TD VALIGN="TOP"><PRE>tilo expr </PRE></TD><TD>Low count of T-states used by instruction at memory location <TT>expr</TT> </TD></TR>
556
<TR><TD VALIGN="TOP"><PRE>tihi expr </PRE></TD><TD>High count of T-states used by instruction at memory location <TT>expr</TT> </TD></TR>
557
<TR><TD VALIGN="TOP"><PRE>ocf expr </PRE></TD><TD>Current count of opcode fetches up to memory location <TT>expr</TT> </TD></TR>
558
</TABLE>
559
<HR>
560
<H3>Macros</H3>
561
The following defines a macro named m with zero or more formal parameters
562
<TT>p1</TT>, <TT>p2</TT>, ..., <TT>pn</TT>, zero or more local symbols <TT>?s1</TT>, <TT>?s2</TT>, ..., <TT>?sm</TT>,
563
and body <TT>b1</TT>, <TT>b2</TT>, ...:
564
<P>
565
<TABLE>
566
<TR><TD VALIGN="TOP"><PRE><TT>m macro p1, p2, ..., pn, ?s1, ?s2, ..., ?sm</TT> </PRE></TD><TD> </TD></TR>
567
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;b1</TT> </PRE></TD><TD> </TD></TR>
568
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;b2</TT> </PRE></TD><TD> </TD></TR>
569
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;...</TT> </PRE></TD><TD> </TD></TR>
570
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;endm</TT> </TD></TR>
571
</TABLE>
572
<P>
573
The macro is called by writing:
574
<BLOCKQUOTE><TT>m v1, v2, ..., vn</TT>
575
</BLOCKQUOTE>
576
<P>
577
A macro call expands to the text of the macro's body, with each
578
occurrence of a formal parameter <TT>pk</TT> replaced by the corresponding
579
value <TT>vk</TT>, and with each local symbol <TT>?sk</TT> replaced by a new, unique
580
symbol invented for this call.  Invented symbols begin with <TT>?</TT>,
581
so you should avoid using such symbols elsewhere in your program.
582
<P>
583
zmac currently does not check that you have provided the right number
584
of parameters when calling a macro.  If you provide too few, unmatched
585
formals are replaced with the empty string.  If you provide too
586
many, the additional values begin to replace local symbols as if
587
they were ordinary parameters.  (This could be considered a feature.)
588
After the local symbols are all replaced, additional parameters
589
are silently ignored.
590
<P>
591
For compatibility with Macro-80, the first line of a macro definition can
592
list other labels that will be treated locally:
593
<P>
594
<BLOCKQUOTE><TT>&nbsp;&nbsp;&nbsp;local lab1,lab2,...</TT>
595
</BLOCKQUOTE>
596
<P>
597
Each time the macro is expanded the local labels are replaced with unique
598
names thus avoiding multiple definition problems.
599
<P>
600 21 gdevic
For compatability with MRAS, macro arguments may be preceeded by <TT>#</TT>
601 3 gdevic
in their definition and use.
602
<P>
603
Any <TT>`</TT> (backquote) in a macro is ignored thus allowing a macro to
604
construct identifiers.  For example:
605
<P>
606
<TABLE>
607
<TR><TD VALIGN="TOP"><PRE><TT>move macro dir</TT> </PRE></TD><TD> </TD></TR>
608
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ld`dir`r</TT> </PRE></TD><TD> </TD></TR>
609
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endm</TT> </TD></TR>
610
</TABLE>
611
<P>
612
Invoking <TT>move i</TT> will construct a <TT>ldir</TT> block move instruction.
613 21 gdevic
<P>
614
For compatibility, <TT>&amp;</TT> can also be used as in MAC to concatenate
615
macro parameters.  This conflicts with zmac's bitwise and operator but
616
you can use the <TT>and</TT> synonym in macros to avoid the conflict.
617
<P>
618
In <TT>--mras</TT> mode arguments will be expanded even if they are inside other
619
identifiers.  The <TT>move</TT> could be written:
620
<P>
621
<TABLE>
622
<TR><TD VALIGN="TOP"><PRE><TT>move macro dir</TT> </PRE></TD><TD> </TD></TR>
623
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lddirr</TT> </PRE></TD><TD> </TD></TR>
624
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endm</TT> </TD></TR>
625
</TABLE>
626
<P>
627
Macro definitions can contain macro definitions which will be defined
628
when the outer macro is first exapnded.  Macros can be redefined as
629
well.
630
<P>
631
Macro expansion continues to the <TT>endm</TT> directive but can be stopped
632
prematurely by the <TT>exitm</TT> directive.  Typically the <TT>exitm</TT> is inside
633
some conditional part of the macro.
634
<P>
635
Parameters passed to a macro can be empty and are tested with the <TT>nul</TT>
636
operator:
637
<P>
638
<TABLE>
639
<TR><TD VALIGN="TOP"><PRE><TT>if nul &amp;par</TT> </PRE></TD><TD> </TD></TR>
640
<TR><TD VALIGN="TOP"><PRE><TT>...</TT> </PRE></TD><TD> </TD></TR>
641
<TR><TD VALIGN="TOP"><PRE><TT>endif</TT> </TD></TR>
642
</TABLE>
643
<P>
644
Macro parameters can contain commas if grouped inside <TT>&lt;</TT> and <TT>&gt;</TT>.
645
Or a comma can be escaped with <TT>^</TT> which can also escape spaces and other
646
special characters.  It is also be put in front of a macro parameter
647
name inside the expansion to suppress the replacement by its value.
648
<P>
649
Expansion of parameters in a macro body is purely textual.  This can
650
lead to surprises in complex situations.  The <TT>%</TT> character can be used
651
to force a macro parameter to be replaced with the evaluation of it
652
as an expression.
653
<P>
654
<P>
655
<H4>Inline Macros</H4>
656
<P>
657
zmac supports the commonly available <TT>rept</TT>, <TT>irp</TT> and <TT>irpc</TT> inline macros
658
<P>
659
<TT>rept</TT> repeats its block the given number of times.  This will output 10
660
<TT>nop</TT> instructions:
661
<P>
662
<TABLE>
663
<TR><TD VALIGN="TOP"><PRE><TT>rept 10</TT> </PRE></TD><TD> </TD></TR>
664
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nop</TT> </PRE></TD><TD> </TD></TR>
665
<TR><TD VALIGN="TOP"><PRE><TT>endm</TT> </TD></TR>
666
</TABLE>
667
<P>
668
<TT>irpc</TT> runs through a string of letters assigned them to a variable and
669
expanding the macro block each time.  For example, this will load 7 into
670
registers <TT>b</TT>, <TT>d</TT> and <TT>h</TT>:
671
<P>
672
<TABLE>
673
<TR><TD VALIGN="TOP"><PRE><TT>irpc reg,bdh</TT> </PRE></TD><TD> </TD></TR>
674
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ld &amp;reg,7</TT> </PRE></TD><TD> </TD></TR>
675
<TR><TD VALIGN="TOP"><PRE><TT>endm</TT> </TD></TR>
676
</TABLE>
677
<P>
678
<TT>irp</TT> runs through a list of parameters assiging each entry to a variable
679
and expanding the macro block.  Here we load <TT>bc</TT>, <TT>de</TT> and <TT>hl</TT> with 0:
680
<P>
681
<TABLE>
682
<TR><TD VALIGN="TOP"><PRE><TT>irp rpair,&lt;bc,de,hl&gt;</TT> </PRE></TD><TD> </TD></TR>
683
<TR><TD VALIGN="TOP"><PRE><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ld &amp;rpair,0</TT> </PRE></TD><TD> </TD></TR>
684
<TR><TD VALIGN="TOP"><PRE><TT>endm</TT> </TD></TR>
685
</TABLE>
686
<P>
687
Lists can be nested.  Here's an example of and <TT>irp</TT> passing lists on down
688
to another <TT>irp</TT>:
689
<P>
690
<TABLE>
691
<TR><TD VALIGN="TOP"><PRE><TT>irp listlist,&lt;&lt;one,two,three&gt;,&lt;four,five,six&gt;&gt;</TT> </PRE></TD><TD> </TD></TR>
692
<TR><TD VALIGN="TOP"><PRE><TT>irp list,&lt;listlist&gt;</TT> </PRE></TD><TD> </TD></TR>
693
<TR><TD VALIGN="TOP"><PRE><TT>ascii '&amp;list'</TT> </PRE></TD><TD> </TD></TR>
694
<TR><TD VALIGN="TOP"><PRE><TT>endm</TT> </PRE></TD><TD> </TD></TR>
695
<TR><TD VALIGN="TOP"><PRE><TT>endm</TT> </TD></TR>
696
</TABLE>
697
<P>
698
<P>
699 3 gdevic
<HR>
700
<H3>Compatibility</H3>
701
<P>
702
zmac is broadly compatible with many original Z-80 and 8080 assemblers
703
because it accepts many different names for common operations and has
704
liberal identifier and numeric formats.  It also accepts most simple
705
usage of macros.
706
<P>
707
When assembling old code keep these portability problems in mind.
708
<P>
709
Expression order of evaluation may be different.  zmac uses C semantics
710
more order of evaluation but assemblers often used simple left to right
711
ordering.  zmac will evaluate <TT>2+2*3</TT> as <TT>8</TT> where other assemblers will
712 21 gdevic
yield <TT>12</TT>.  However, in <TT>--mras</TT> mode expressions are evaluated strictly
713
left-to-right for compatibility.
714 3 gdevic
<P>
715
zmac has no support operating on strings in macros.  Assemblers like Macro-80
716
could perform conditional tests on strings.
717
<P>
718
Advanced macros are unlikely to work.  zmac hasn't advanced to the state where
719 21 gdevic
all the possible ways of substituting parameters are supported.
720 3 gdevic
<P>
721
Consult the original assembler manual.  zmac error messages won't help you
722
figure out what an unknown assembler command is supposed to do.
723
<P>
724
Compare against original output.  The very safest thing to do when porting
725
assembly code is to compare the binary output of zmac against that produced
726
by the original assembler.  This way you can ensure everything has been
727
interpreted correctly.  Only once that has been achieved should you modify
728
the code.
729
<HR>
730
<H3>Errors and Warnings</H3>
731
<P>
732
Any errors or warnings encountered during assembly are reported to standard
733
error and in the listing file.  The errors output immediately give the source
734
file and line number containing the error.  In listings the error letter
735
and message appear just after the line containing the error.
736
<P>
737
<TABLE>
738
<TR><TD VALIGN="TOP"><PRE>B </PRE></TD><TD>Balance error </TD></TR>
739
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>A string is missing an closing quote or an <TT>if</TT> is missing an <TT>endif</TT> </TD></TR>
740
<TR><TD VALIGN="TOP"><PRE>E </PRE></TD><TD>Expression error </TD></TR>
741
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An expression did not parse or attempts a divide or modulus by 0. </TD></TR>
742
<TR><TD VALIGN="TOP"><PRE>F </PRE></TD><TD>Syntax error </TD></TR>
743
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>General problem with the syntax on a line.  Sometimes extra explanation will be printed on standard output. </TD></TR>
744
<TR><TD VALIGN="TOP"><PRE>I </PRE></TD><TD>Digit error </TD></TR>
745
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>A numeric constant has too many digits to be represented as a 32 bit number. </TD></TR>
746
<TR><TD VALIGN="TOP"><PRE>M </PRE></TD><TD>Mult. def. error </TD></TR>
747
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>A symbol has been defined more than once and those values differ. </TD></TR>
748
<TR><TD VALIGN="TOP"><PRE>P </PRE></TD><TD>Phase error </TD></TR>
749
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>On the second or subsequent assembly passes the assembly has changed significantly.  Most commonly it means an <TT>if</TT> has changed conditions but can also happen when labels or equated values do not converge to a fixed value. </TD></TR>
750
<TR><TD VALIGN="TOP"><PRE>U </PRE></TD><TD>Undeclared error </TD></TR>
751
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An undeclared symbol was used in an expression or <TT>public</TT> statement. </TD></TR>
752
<TR><TD VALIGN="TOP"><PRE>V </PRE></TD><TD>Value error </TD></TR>
753
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An invalid value was given to a statement.  Often this means using less than -128 or greater then 255 in a <TT>defb</TT> or less than -32768 or greater than 65535 in a <TT>defw</TT>.  Or similar invalid values used Z-80/8080 opcodes requiring an 8 or 16 bit value (and other restrictions like 0 to 7 for <TT>BIT</TT>). Also if a relative jump is out of range or if a negative value is given in <TT>defs</TT> or <TT>dc</TT>. </TD></TR>
754
<TR><TD VALIGN="TOP"><PRE>O </PRE></TD><TD>Phase/Dephase error </TD></TR>
755
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD><TT>phase</TT> was used within another <TT>phase</TT> or <TT>dephase</TT> without <TT>phase</TT>. Or if <TT>org</TT> is used within <TT>phase</TT>. </TD></TR>
756
<TR><TD VALIGN="TOP"><PRE>A </PRE></TD><TD>Assertion failure error </TD></TR>
757
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An assert statement evaluated to zero. </TD></TR>
758
<TR><TD VALIGN="TOP"><PRE>J </PRE></TD><TD>Use JR error </TD></TR>
759
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An absolute jump instruction was used where relative jump was in range of the destination address.  Only generated if <TT>-j</TT> or <TT>jrpromote</TT> is in effect. </TD></TR>
760
<TR><TD VALIGN="TOP"><PRE>R </PRE></TD><TD>Not relocatable error </TD></TR>
761
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An expression was used that must be generated at link time but cannot be handled by the ".rel" format.  For instance, an <TT>org</TT> to a symbol in the data segment when in the code segment.  Or a relative jump to a different segment.  The ".rel" format can evaluate expressions at link time using the <TT>high</TT>, <TT>low</TT>, <TT>not</TT>, <TT>-</TT>, <TT>+</TT>, <TT>*</TT>, <TT>/</TT> and <TT>%</TT> operators. zmac is clever enough to use <TT>high</TT> or <TT>low</TT> in place of <TT>&amp; $ff00</TT> and <TT>&amp; 255</TT>.  But it won't replace a <TT>shl</TT> with a multiply. </TD></TR>
762
<TR><TD VALIGN="TOP"><PRE>G </PRE></TD><TD>Register usage error </TD></TR>
763
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>A invalid register was given to an instruction.  For example, <TT>LD B,(DE)</TT> or <TT>ADD HL,IX</TT>. </TD></TR>
764
<TR><TD VALIGN="TOP"><PRE>Z </PRE></TD><TD>Z-80 instruction in 8080 mode error </TD></TR>
765
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>An instruction was assembled that is only valid on the Z-80 but <TT>.8080</TT> (or <TT>-8</TT>) mode is in effect.  However, use use of Z-80 mnemonics that output valid 8080 instructions is always OK. </TD></TR>
766
<TR><TD VALIGN="TOP"><PRE>H </PRE></TD><TD>$hex constant interpreted as symbol warning </TD></TR>
767
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>A symbol such as <TT>$FCB</TT> has been defined even though it could appear to be a hexadecimal constant.  zmac will treat <TT>$FCB</TT> as symbol for the entire assembly which could be rather surprising if that were not the intent. </TD></TR>
768
<TR><TD VALIGN="TOP"><PRE>N </PRE></TD><TD>Not implemented warning </TD></TR>
769
<TR><TD VALIGN="TOP"><PRE>&nbsp; </PRE></TD><TD>For statements that have been added as parse rules but have no effect. The only current example is <TT>subttl</TT> which sets the sub title of a listing in certain assemblers. </TD></TR>
770
</TABLE>
771
<P>
772
<HR>
773
<H3>Output <A NAME="format">Formats</A></H3>
774
<P>
775 21 gdevic
Except for ".rel", zmac writes every known output when assembling by default.
776
This is no burden on modern computers and saves having to meticulously select
777
the desired output format.
778 3 gdevic
<P>
779
".rel" is a special case since that format is intended for linking and
780 21 gdevic
can have undefined external symbols which would be errors in the other formats.
781
Conversely, a simple "org $8000" will be an error for ".rel" output as it
782
defaults to the code segment where absolute origin statements are forbidden.
783 3 gdevic
<P>
784 21 gdevic
If ".rel" is selected for output either by <TT>--relopt</TT> or with
785
<TT>--oo rel</TT> or <TT>-o file.rel</TT> then all other output formats are suppressed
786
(except the ".lst" source file listing).
787
<P>
788 3 gdevic
<TABLE>
789
<TR><TD VALIGN="TOP"><PRE>.ams </PRE></TD><TD>AMSDOS executable format for Amstrad computers. </TD></TR>
790 21 gdevic
<TR><TD VALIGN="TOP"><PRE>.bds </PRE></TD><TD>For source-level debugging in <A HREF="http://www.48k.ca/trs80gp.html">trs80gp</A> </TD></TR>
791
<TR><TD VALIGN="TOP"><PRE>.1500.cas </PRE></TD><TD>TRS-80 high-speed (1500 baud) cassette SYSTEM file.  The internal name of the file is the source file name shortened to 6 characters with suffixes removed.  Requires an entry address. </TD></TR>
792
<TR><TD VALIGN="TOP"><PRE>.250.cas </PRE></TD><TD>TRS-80 250 baud cassette Level I CLOAD file.  If your program has an entry address and $41FE does not contain that entry address then the file will be loaded at $41FE with relocation code added to move it to the desired location. </TD></TR>
793
<TR><TD VALIGN="TOP"><PRE>.500.cas </PRE></TD><TD>TRS-80 low-speed (500 baud) cassette SYSTEM file.  The internal name of the file is the source file name shortened to 6 characters with suffixes removed. Requires an entry address. </TD></TR>
794
<TR><TD VALIGN="TOP"><PRE>.1000.cas </PRE></TD><TD>Identical to 500 baud but intended for double-speed LNW-80 which can can load cassette files at double speed for an effective 1000 baud rate. Requires an entry address. </TD></TR>
795 3 gdevic
<TR><TD VALIGN="TOP"><PRE>.cim </PRE></TD><TD>Core In-Memory image.  A raw binary format with the first byte corresponding to the lowest generated code or data and proceeding contiguously until the highest address generated.  Any gaps are filled with zeros.  Typically used for CP/M where all executables start at address 256 or for ROM images. </TD></TR>
796
<TR><TD VALIGN="TOP"><PRE>.cmd </PRE></TD><TD>TRS-80 DOS executable file format as used by all major DOSes on the TRS-80 (TRS-DOS, LDOS, MULTIDOS, NEWDOS, etc.) </TD></TR>
797
<TR><TD VALIGN="TOP"><PRE>.hex </PRE></TD><TD>Intel hex record format. </TD></TR>
798
<TR><TD VALIGN="TOP"><PRE>.rel </PRE></TD><TD>Relocatable object module format as produced by MACRO-80 and other assemblers. </TD></TR>
799 21 gdevic
<TR><TD VALIGN="TOP"><PRE>.tap </PRE></TD><TD>ZX Spectrum cassette tape format. </TD></TR>
800
<TR><TD VALIGN="TOP"><PRE>.1500.wav </PRE></TD><TD>Same as .1500.cas but in ready-to-play audio format. </TD></TR>
801
<TR><TD VALIGN="TOP"><PRE>.250.wav </PRE></TD><TD>Same as .250.cas but in ready-to-play audio format. </TD></TR>
802
<TR><TD VALIGN="TOP"><PRE>.500.wav </PRE></TD><TD>Same as .500.cas but in ready-to-play audio format. </TD></TR>
803
<TR><TD VALIGN="TOP"><PRE>.1000.wav </PRE></TD><TD>Same as .1000.cas but in ready-to-play audio format. </TD></TR>
804
<TR><TD VALIGN="TOP"><PRE>.mds </PRE></TD><TD>MAME debug script (e.g., mame trs80 -d -debugscript zout/prog.mds) </TD></TR>
805 3 gdevic
</TABLE>
806
<P>
807
<HR>
808
<H3>Miscellaneous</H3>
809
In the symbol table listing, the <TT>=</TT> prefix is given for those symbols
810 21 gdevic
defined by <TT>equ</TT> or <TT>defl</TT>.  The <TT>/</TT> prefix is shown for common blocks.
811
<P>
812
The <TT>.rel</TT> file format can store symbol names of up to 7 characters in length.
813
However, MACRO-80 truncates symbols to 6 characters so that it has one
814
character in reserve for extending linking operations such as subtracting
815
two externals from each other.  To be compatible (and sensible), <TT>--rel</TT>
816
truncates externals to 6 characters.  For MRAS compatibility, <TT>--mras</TT>
817
truncates symbols to 7 characters.  This is not a problem for MRAS as it
818
doesn't support extended linking.  But necessary if you want zmac to produce
819
<TT>.rel</TT> files that will link with MRAS generated <TT>.rel</TT> files.  The <TT>--rel7</TT>
820
option sets symbol truncation to 7 characters so you can assemble files
821
that will link with MRAS output.  However, it will break extended linking
822
on labels longer than 6 characters.
823
<P>
824
The <A NAME="prime">ignoring</A> of single quotes can be handy for tracking alternate
825
register usage.  Consider the following code fragment:
826
<P>
827
<TABLE>
828
<TR><TD VALIGN="TOP"><PRE><TT>ld    a,(hl)</TT> </PRE></TD><TD> </TD></TR>
829
<TR><TD VALIGN="TOP"><PRE><TT>rra</TT> </PRE></TD><TD> </TD></TR>
830
<TR><TD VALIGN="TOP"><PRE><TT>exx</TT> </PRE></TD><TD> </TD></TR>
831
<TR><TD VALIGN="TOP"><PRE><TT>ld    a,(hl')</TT> </PRE></TD><TD> </TD></TR>
832
<TR><TD VALIGN="TOP"><PRE><TT>ex    af,af'</TT> </PRE></TD><TD> </TD></TR>
833
<TR><TD VALIGN="TOP"><PRE><TT>ld    a',(hl') </PRE></TD><TD> </TD></TR>
834
<TR><TD VALIGN="TOP"><PRE></TT>rra'<TT> </PRE></TD><TD> </TD></TR>
835
<TR><TD VALIGN="TOP"><PRE></TT>ex    af,af'<TT> </PRE></TD><TD> </TD></TR>
836
<TR><TD VALIGN="TOP"><PRE></TT>djnz' loop<TT> </PRE></TD><TD> </TD></TR>
837
<TR><TD VALIGN="TOP"><PRE></TT>ld    d',e'<TT> </PRE></TD><TD> </TD></TR>
838
<TR><TD VALIGN="TOP"><PRE></TT>exx<TT> </TD></TR>
839
</TABLE>
840
<P>
841
Although zmac does nothing but ignore the single quotes they are useful for
842
indicating which register we're talking using.  A more advanced mode
843
where zmac pays attention to the trailing quotes and emits exchange instrucitons
844
as needed has been considered.
845
<P>
846 3 gdevic
<HR>
847
<H3>Exit Status</H3>
848
<P>
849
<TABLE>
850
<TR><TD VALIGN="TOP"><PRE>0 </PRE></TD><TD>No errors. </TD></TR>
851
<TR><TD VALIGN="TOP"><PRE>1 </PRE></TD><TD>One or more errors were found during assembly, or zmac exited with a fatal error. </TD></TR>
852
</TABLE>
853
<P>
854
<HR>
855
<H3>Credits</H3>
856 21 gdevic
Bruce Norskog originally wrote zmac in 1978.
857 3 gdevic
<P>
858
Updates and bugfixes over the years by John Providenza, Colin Kelley,
859
and more recently by Russell Marks, Mark RISON, Chris Smith,
860
Matthew Phillips and Tim Mann.
861
<P>
862
Extensive modifications for cycle counting, multiple output formats,
863
".rel" output, 8080 mode and older assembler compatibilty were written
864
by George Phillips.
865
<P>
866
This document was based on Russell Marks zmac man page which had
867
tweaks by Mark RISON and Tim Mann.  George Phillips converted it to HTML
868 21 gdevic
and documented the new features and some older ones (e.g., </TT>phase<TT>/</TT>dephase<TT>).
869
</TT>
870
<p xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
871
  <a rel="license"
872
     href="http://creativecommons.org/publicdomain/zero/1.0/">
873
    <img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
874
  </a>
875
  <br />
876
  To the extent possible under law,
877
  <a rel="dct:publisher"
878
     href="http://48k.ca/zmac.html">
879
    <span property="dct:title">George Phillips</span></a>
880
  has waived all copyright and related or neighboring rights to
881
  <span property="dct:title">zmac macro cross assembler for the Zilog Z-80 microprocessor</span>.
882
This work is published from:
883
<span property="vcard:Country" datatype="dct:ISO3166"
884
      content="CA" about="http://48k.ca/zmac.html">
885
  Canada</span>.
886
</p>
887
 
888 3 gdevic
<!--
889
  If you ran "zmac --doc" you may want to send the output
890
  to a file using "zmac --doc >zmac.html" and then open
891
  zmac.html in your web browser.
892
-->

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.