1 |
20 |
bporcella |
Kingswood Software Development Tools AS80
|
2 |
|
|
-------------------------------------------------------------------------
|
3 |
|
|
|
4 |
|
|
NAME
|
5 |
|
|
as80 - assembler for 8080, 8085 and Z80 microprocessors.
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
SYNOPSIS
|
9 |
|
|
as80 [-cdghilnopqstvwxz] file
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
DESCRIPTION
|
13 |
|
|
This documentation is for as80 [1.10].
|
14 |
|
|
Copyright 1990-1994, Frank A. Vorstenbosch, Kingswood Software.
|
15 |
|
|
|
16 |
|
|
AS80 is an assembler for the Intel 8080/8085 and Zilog Z80
|
17 |
|
|
microprocessors. It reads input from an ASCII text file, assembles
|
18 |
|
|
this into memory, and then writes a listing and a binary or hex file.
|
19 |
|
|
|
20 |
|
|
AS80 is case sensitive, not only does it differentiate between the
|
21 |
|
|
labels XYZ and xyz, but it also requires all (pseudo) instruction and
|
22 |
|
|
register names to be lower case. This way, the listing is the most
|
23 |
|
|
readable. Option -i can be used to make the assembler case insensitive.
|
24 |
|
|
Alternatively, the included TOLOWER program can be used to convert
|
25 |
|
|
sources to lower case.
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
OPTIONS
|
29 |
|
|
As80 recognizes the following options:
|
30 |
|
|
|
31 |
|
|
-c Show number of cycles per instruction in listing. This
|
32 |
|
|
decreases the number of columns available for listing by 5.
|
33 |
|
|
The number of cycles is printed between brackets [ and ].
|
34 |
|
|
|
35 |
|
|
-d
|
36 |
|
|
Define a label before the first source line is read. If
|
37 |
|
|
no name is specified, DEBUG is defined. The label is
|
38 |
|
|
EQUated to be 1.
|
39 |
|
|
|
40 |
|
|
-g Generate source-level debug information file. This file
|
41 |
|
|
can then be used in in-system debugging or a software
|
42 |
|
|
simulator.
|
43 |
|
|
|
44 |
|
|
-h
|
45 |
|
|
Specify height of page for listing. This option determines
|
46 |
|
|
the number of lines per printed page. Each page has a header
|
47 |
|
|
and is terminated by a form-feed character. The special
|
48 |
|
|
case -h0 indicates an infinite page length. In this case,
|
49 |
|
|
page breaks are only inserted between the two passes and
|
50 |
|
|
the symbol table (if present).
|
51 |
|
|
|
52 |
|
|
-i Ignore case in opcodes. In this way, the assembler does not
|
53 |
|
|
differentiate between 'add' and 'ADD', for example. Labels
|
54 |
|
|
are still case sensitive.
|
55 |
|
|
|
56 |
|
|
-l Generate pass 2 listing.
|
57 |
|
|
|
58 |
|
|
-l
|
59 |
|
|
Listing file name. The listing file is used for pass 1 and
|
60 |
|
|
pass 2 listing, for the symbol table (printed between the
|
61 |
|
|
two passes), and some statistics. When neither -p nor -t
|
62 |
|
|
is specified, and -l is given, then the assembler
|
63 |
|
|
automatically generates a pass 2 listing. When -p or -t is
|
64 |
|
|
specified, an additional -l should be given is a pass 2
|
65 |
|
|
listing is required. The filename - can be used to direct
|
66 |
|
|
the listing to standard output.
|
67 |
|
|
|
68 |
|
|
-l Generate pass 2 listing.
|
69 |
|
|
|
70 |
|
|
-m Show macro expansions in listing. Macro lines are prefixed
|
71 |
|
|
by a > sign.
|
72 |
|
|
|
73 |
|
|
-n Disable optimizations. When this option is specified no
|
74 |
|
|
optimizations will be done, even when the OPT pseudo-
|
75 |
|
|
instruction is used in the source code.
|
76 |
|
|
|
77 |
|
|
-o
|
78 |
|
|
Specify binary or s-records output file name. The assembler
|
79 |
|
|
automatically adds ".bin" for binary output or ".s19" for
|
80 |
|
|
s-records output when no extension is given.
|
81 |
|
|
|
82 |
|
|
-p Generate pass 1 listing. This may be used to examine any
|
83 |
|
|
optimizations/bugs generated in pass 2.
|
84 |
|
|
|
85 |
|
|
-q Quiet mode. No running line counter is displayed on standard
|
86 |
|
|
error output.
|
87 |
|
|
|
88 |
|
|
-s Write s-records instead of binary file. The s-records file
|
89 |
|
|
contains data for (only) the used memory; the binary file
|
90 |
|
|
begins at the lowest used address, and continues up to the
|
91 |
|
|
highest used address; filling unused memory between these
|
92 |
|
|
two addresses with either $ff or $00.
|
93 |
|
|
|
94 |
|
|
-s2 Write intel-hex file instead of binary file. The intel-hex
|
95 |
|
|
file contains data for (only) the used memory.
|
96 |
|
|
|
97 |
|
|
-t Generate symbol table. The symbol table is listed between
|
98 |
|
|
passes one and two, displaying the name, hexadecimal and
|
99 |
|
|
decimal value of each label, using 4-digit hexadecimal
|
100 |
|
|
numbers where possible, otherwise 8-digit numbers. The
|
101 |
|
|
decimal value is followed by an asterisk if the label is
|
102 |
|
|
redefinable (defined using SET instead of EQU).
|
103 |
|
|
|
104 |
|
|
-v Verbose mode. More information is displayed on standard
|
105 |
|
|
output.
|
106 |
|
|
|
107 |
|
|
-w
|
108 |
|
|
Specify column width. Normally, the listing is printed using
|
109 |
|
|
79 columns for output to a 80-column screen or printer. If
|
110 |
|
|
the -w option is given without a number following it, then
|
111 |
|
|
the listing will be 131 columns wide, otherwise it will be
|
112 |
|
|
the number of colulmns specified (between 60 and 200).
|
113 |
|
|
|
114 |
|
|
-x1 Use 8085 extensions. The 8085 CPU has two additional
|
115 |
|
|
instructions and different cycle counts, but is otherwise
|
116 |
|
|
software compatible to the 8080. When this option is not
|
117 |
|
|
specified the assembler rejects the RIM and SIM instructions.
|
118 |
|
|
|
119 |
|
|
-x or
|
120 |
|
|
-x2
|
121 |
|
|
Use Z80 extensions. The Z80 has many additional instructions
|
122 |
|
|
and addressing modes, but is otherwise software compatible to
|
123 |
|
|
the 8080. When this option is not specified the assembler
|
124 |
|
|
rejects all Z80 new instructions and addressing modes.
|
125 |
|
|
|
126 |
|
|
-x3 Use Z80 extensions and index register byte instructions.
|
127 |
|
|
The IX and IY registers were originally intended to be
|
128 |
|
|
split in IXH/IXL and IYH/IYL register pairs. For some
|
129 |
|
|
reason (bug in original mask set?) these instructions were
|
130 |
|
|
not included by Zilog in the programming manuals, but
|
131 |
|
|
they do work on all CPUs I've seen. Your mileage may vary.
|
132 |
|
|
Note that these extensions do NOT work on the Z180/181 and
|
133 |
|
|
H64180, but they DO (and are documented) on the Z280.
|
134 |
|
|
|
135 |
|
|
-z Fill unused memory with zeros. Normally when a binary file
|
136 |
|
|
is generated, unused bytes between the lowest and highest
|
137 |
|
|
used addresses are filled with $ff, the unprogrammed state
|
138 |
|
|
of EPROMs. If this is not wanted, the -z option can be used
|
139 |
|
|
to initialize this memory to $00. With s-records, unused
|
140 |
|
|
memory is not output to the file, and this option forces the
|
141 |
|
|
creation of an S9 (start address) record instead, even if no
|
142 |
|
|
start address is specified in the file with the END pseudo-
|
143 |
|
|
instruction.
|
144 |
|
|
|
145 |
|
|
Commandline options can be catenated, but no other option can follow
|
146 |
|
|
one that may have a parameter. Thus:
|
147 |
|
|
-tlfile
|
148 |
|
|
is correct (specifying symbol table and pass 2 listing), but
|
149 |
|
|
-h5t
|
150 |
|
|
is not.
|
151 |
|
|
|
152 |
|
|
It is possible to discard any of the the output files by specifying
|
153 |
|
|
the name 'nul'.
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
EXPRESSIONS
|
157 |
|
|
|
158 |
|
|
The assembler recognizes most C-language expressions. The operators
|
159 |
|
|
are listed here in order of precedence, highest first:
|
160 |
|
|
|
161 |
|
|
() braces to group subexpressions
|
162 |
|
|
* $ current location counter
|
163 |
|
|
unary + - ! ~ unary + (no-operation), negation, logical NOT,
|
164 |
|
|
binary NOT
|
165 |
|
|
* / % multiplication, division, modulo
|
166 |
|
|
+ - addition, subtraction
|
167 |
|
|
<< >> shift left, shift right
|
168 |
|
|
< > <= >= comparison for greater/less than
|
169 |
|
|
= != comparison for equality (== can be used for =)
|
170 |
|
|
& binary AND
|
171 |
|
|
^ binary XOR
|
172 |
|
|
| binary OR
|
173 |
|
|
&& logical AND
|
174 |
|
|
|| logical OR
|
175 |
|
|
hi lo high byte, low byte
|
176 |
|
|
|
177 |
|
|
The logical NOT (!) evaluates to zero if the parameter is nonzero,
|
178 |
|
|
and vice versa. The binary NOT (~) complements all the bits in its
|
179 |
|
|
parameter. Logical AND (&&) and OR (||) operators evaluate to one
|
180 |
|
|
if both resp. at least one argument is nonzero. These two operators
|
181 |
|
|
evaluate both arguments, unlike the C-language versions.
|
182 |
|
|
|
183 |
|
|
Note: the asterisk is both used as the multiplication operator, and
|
184 |
|
|
as symbol for the current location. The assembler determines from
|
185 |
|
|
the context which is which. Thus:
|
186 |
|
|
|
187 |
|
|
5**
|
188 |
|
|
|
189 |
|
|
is a valid expression, evaluating to five times the current location
|
190 |
|
|
counter, and:
|
191 |
|
|
|
192 |
|
|
2+*/2
|
193 |
|
|
|
194 |
|
|
is too, evaluating to the current location counter divided by two, to
|
195 |
|
|
which two is added. In the same way, the % sign is both used as the
|
196 |
|
|
modulo operator and the prefix for binary numbers.
|
197 |
|
|
|
198 |
|
|
Numbers can be specified in any number base between 2 and 36.
|
199 |
|
|
Decimal numbers can be used without a prefix, hexadecimal numbers
|
200 |
|
|
can be prefixed by $, octal numbers by @, and binary numbers by %.
|
201 |
|
|
Other number bases can be used by using the following format:
|
202 |
|
|
#,
|
203 |
|
|
where the base is the number base to use (must be specified in
|
204 |
|
|
decimal), and number is the value. Thus:
|
205 |
|
|
1000 - decimal number, value 10*10*10=1000
|
206 |
|
|
%1000 - binary number, value 2*2*2=8
|
207 |
|
|
@1000 - octal number, value 8*8*8=512
|
208 |
|
|
$1000 - hexadecimal number, value 16*16*16=4096
|
209 |
|
|
#1000 - hexadecimal number, value 16*16*16=4096
|
210 |
|
|
0b1000 - binary number, value 2*2*2=8
|
211 |
|
|
0x1000 - hexadecimal number, value 16*16*16=4096
|
212 |
|
|
2#1000 - binary number, value 2*2*2=8
|
213 |
|
|
4#1000 - base-4 number, value 4*4*4=64
|
214 |
|
|
7#1000 - base-7 number, value 7*7*7=343
|
215 |
|
|
36#1000 - base-36 number, value 36*36*36=444528
|
216 |
|
|
For number bases greater than 10, additional digits are represented
|
217 |
|
|
by letters, starting from A. Both lower and upper case letters can
|
218 |
|
|
be used.
|
219 |
|
|
11#aa = 120
|
220 |
|
|
16#ff = 255
|
221 |
|
|
25#oo = 624
|
222 |
|
|
36#zz = 1295
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
PSEUDO-INSTRUCTIONS
|
226 |
|
|
|
227 |
|
|
align
|
228 |
|
|
|
229 |
|
|
Align fills zero or more bytes with zeros until the new address
|
230 |
|
|
modulo equals zero. If the expression is not present,
|
231 |
|
|
align fills zero or one bytes with zeros until the new address
|
232 |
|
|
is even.
|
233 |
|
|
|
234 |
|
|
Example 1:
|
235 |
|
|
align 256 ; continue assembly on the
|
236 |
|
|
; next 256-byte page
|
237 |
|
|
|
238 |
|
|
Example 2:
|
239 |
|
|
align ; make sure table begins
|
240 |
|
|
Table dw 1,2,3 ; on an even address
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
bss
|
245 |
|
|
|
246 |
|
|
Put all following data in the bss segment. Only data pseudo-instructions
|
247 |
|
|
can be used in the bss segment, and these only increment the location
|
248 |
|
|
counter. It is up to the programmer to initialize the bss segment. The
|
249 |
|
|
bss segment is especially meaningful in a ROM based system where
|
250 |
|
|
variables must be placed in RAM, and RAM is not automatically initialized.
|
251 |
|
|
|
252 |
|
|
The assembler internally maintains three separate location counters,
|
253 |
|
|
one for the code segment, one for the data segment and one for the
|
254 |
|
|
uninitialized data segment. The user is responsible for not overlapping
|
255 |
|
|
the segments by setting appropriate origins. The code, data and bss
|
256 |
|
|
pseudo-instructions can be used to interleave code and data in the source
|
257 |
|
|
listing, while separating the three in the generated program. The
|
258 |
|
|
assembler starts with the code segment if none is specified.
|
259 |
|
|
|
260 |
|
|
Example:
|
261 |
|
|
code
|
262 |
|
|
org $f000 ; Assuming 4 kbyte code ROM
|
263 |
|
|
data ; with 2 kbyte program and
|
264 |
|
|
org $f800 ; 2 kbyte initialized data
|
265 |
|
|
bss
|
266 |
|
|
org 0 ; bss segment is in RAM
|
267 |
|
|
|
268 |
|
|
Buffer ds 100
|
269 |
|
|
|
270 |
|
|
code
|
271 |
|
|
Begin ld hl,Table
|
272 |
|
|
ld de,Buffer
|
273 |
|
|
ld bc,3
|
274 |
|
|
ldir
|
275 |
|
|
.
|
276 |
|
|
.
|
277 |
|
|
.
|
278 |
|
|
|
279 |
|
|
data
|
280 |
|
|
Table db 1,2,3
|
281 |
|
|
|
282 |
|
|
code
|
283 |
|
|
MyFunc ld ix,Table
|
284 |
|
|
.
|
285 |
|
|
.
|
286 |
|
|
|
287 |
|
|
code
|
288 |
|
|
|
289 |
|
|
Put all following assembled instructions and data in the code segment.
|
290 |
|
|
See BSS.
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
data
|
294 |
|
|
|
295 |
|
|
Put all following assembled instructions and data in the data segment.
|
296 |
|
|
See BSS.
|
297 |
|
|
|
298 |
|
|
|
299 |
|
|
db
|
300 |
|
|
|
301 |
|
|
Define bytes. The bytes may be specified as expressions or strings,
|
302 |
|
|
and are placed in the current (code or data) segment. This pseudo
|
303 |
|
|
instruction is similar to the Zilog-defined defb and defm pseudo-
|
304 |
|
|
instructions.
|
305 |
|
|
|
306 |
|
|
Example:
|
307 |
|
|
Message db "\aError\r\n",0
|
308 |
|
|
|
309 |
|
|
|
310 |
|
|
defb
|
311 |
|
|
|
312 |
|
|
Define bytes. The bytes may be specified only as expressions,
|
313 |
|
|
and are placed in the current (code or data) segment. This
|
314 |
|
|
pseudo-instruction is similar to the db pseudo-instruction.
|
315 |
|
|
|
316 |
|
|
Example:
|
317 |
|
|
Message defb 7
|
318 |
|
|
defm "Error"
|
319 |
|
|
defb 13,10,0
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
defm
|
323 |
|
|
|
324 |
|
|
Define message. The bytes may be specified only as a string, and
|
325 |
|
|
are placed in the current (code or data) segment. This pseudo-
|
326 |
|
|
instruction is similar to the db pseudo-instruction.
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
ds
|
330 |
|
|
defs
|
331 |
|
|
|
332 |
|
|
Define zero or more bytes empty space. The specified number of
|
333 |
|
|
bytes are filled with zeros. This pseudo-instruction is identical
|
334 |
|
|
to the Zilog-defined pseudo-instruction defs.
|
335 |
|
|
|
336 |
|
|
Example:
|
337 |
|
|
ds 100 ; reserve 100 bytes here
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
dw
|
341 |
|
|
defw
|
342 |
|
|
|
343 |
|
|
Define words. The words are placed in the current (code or data)
|
344 |
|
|
segment. This pseudo-instruction is identical to the Zilog-
|
345 |
|
|
defined defw pseudo-instruction.
|
346 |
|
|
|
347 |
|
|
Example:
|
348 |
|
|
ld a,2*Function ; number of function
|
349 |
|
|
ld hl,JumpTable
|
350 |
|
|
add a,l ; calculate HL+A
|
351 |
|
|
ld l,a
|
352 |
|
|
adc a,h
|
353 |
|
|
sub l
|
354 |
|
|
ld h,a
|
355 |
|
|
jp (hl) ; jump to function
|
356 |
|
|
|
357 |
|
|
JumpTable dw Function0
|
358 |
|
|
dw Function1
|
359 |
|
|
dw Function2
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
else
|
363 |
|
|
|
364 |
|
|
The else pseudo-instruction can be used for if-then-else
|
365 |
|
|
constructions. It must be placed between an if and an endif
|
366 |
|
|
instruction. For an example, see the if pseudo-instruction.
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
end
|
370 |
|
|
|
371 |
|
|
The end pseudo-instruction is optional, and need not be used. If
|
372 |
|
|
it is used, its optional operand specifies the staring address of
|
373 |
|
|
the program. This address is displayed when the program is
|
374 |
|
|
assembled, and is also placed in the s-record output file.
|
375 |
|
|
|
376 |
|
|
Example:
|
377 |
|
|
end Start
|
378 |
|
|
|
379 |
|
|
endif
|
380 |
|
|
|
381 |
|
|
The endif pseudo-instruction must be used to close an if-endif
|
382 |
|
|
or if-else-endif construction. For an example, see the if
|
383 |
|
|
pseudo-instruction.
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
|
387 |
|
|
|
388 |
|
|
The equ (equate) pseudo-instruction sets the specified label to
|
389 |
|
|
the value of the expression. The label may not already exist.
|
390 |
|
|
Some programmers choose to use only upper-case identifiers for
|
391 |
|
|
labels defined in this way to differentiate them from addresses.
|
392 |
|
|
|
393 |
|
|
Example:
|
394 |
|
|
ESCAPE equ 27
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
if
|
398 |
|
|
|
399 |
|
|
The if pseudo-instruction can be used in conjunction with the
|
400 |
|
|
endif and possibly the else pseudo-instructions to selectively
|
401 |
|
|
enable and disable pieces of code in the source. If the expression
|
402 |
|
|
given evaluates to zero, then the following code up to the matching
|
403 |
|
|
else or endif is not included in the assembly. If the expression
|
404 |
|
|
is nonzero, then the following code is included, but any code
|
405 |
|
|
between the matching else and endif is not.
|
406 |
|
|
The original Zilog assemblers called this pseudo-instruction COND.
|
407 |
|
|
|
408 |
|
|
Example:
|
409 |
|
|
if COUNT=2 | COUNT=4
|
410 |
|
|
add a,a ; shift left for counts
|
411 |
|
|
if COUNT=4 ; of 2 and 4
|
412 |
|
|
add a,a
|
413 |
|
|
endif
|
414 |
|
|
else
|
415 |
|
|
ld b,COUNT ; otherwise use slow multiply
|
416 |
|
|
call Multiply
|
417 |
|
|
endif
|
418 |
|
|
|
419 |
|
|
|
420 |
|
|
include
|
421 |
|
|
|
422 |
|
|
The named file is included in the assembly at this point. After
|
423 |
|
|
it has been read, assembly continues with the next line of the
|
424 |
|
|
current file. Include files may be nested.
|
425 |
|
|
|
426 |
|
|
Example:
|
427 |
|
|
include "z180.i"
|
428 |
|
|
|
429 |
|
|
|
430 |
|
|
list
|
431 |
|
|
|
432 |
|
|
Enable generation of the listing in the list-file. If the listing
|
433 |
|
|
has been disabled twice, it must be enabled twice before it is
|
434 |
|
|
generated. When no -p or -l option has been specified on the
|
435 |
|
|
command line, this pseudo-instruction has no effect.
|
436 |
|
|
|
437 |
|
|
|
438 |
|
|
macro
|
439 |
|
|
|
440 |
|
|
Define a macro. Macros allow a block of source statements to be
|
441 |
|
|
given a name, and then that name can be used to include the
|
442 |
|
|
statements anywhere in the program. Parameters can be used to
|
443 |
|
|
pass arguments to the macro. In the macro definition names
|
444 |
|
|
can be used to respresent the arguments; these names in the text
|
445 |
|
|
are substituted with the value passed on macro expansion.
|
446 |
|
|
Macro arguments can also be represented by using \1 through \9
|
447 |
|
|
in the macro text; these sequences are replaced by the first
|
448 |
|
|
through ninth argument respectively. The special value \0
|
449 |
|
|
contains the number of arguments passed to the macro.
|
450 |
|
|
|
451 |
|
|
Example 1:
|
452 |
|
|
Macro1 macro text,value
|
453 |
|
|
dw value
|
454 |
|
|
db text,0
|
455 |
|
|
db "value=",'value',0
|
456 |
|
|
endm
|
457 |
|
|
|
458 |
|
|
Macro2 macro
|
459 |
|
|
dw \2
|
460 |
|
|
db \1,0
|
461 |
|
|
db "value=\2",0
|
462 |
|
|
endm
|
463 |
|
|
|
464 |
|
|
Macro1 "Hello",123
|
465 |
|
|
Macro2 "Hello",123
|
466 |
|
|
|
467 |
|
|
Macros can also use local labels, for when a unique label is needed
|
468 |
|
|
each time the macro is expanded. This can be used when the macro
|
469 |
|
|
contains a conditional jump, or a loop of some kind, or simply needs
|
470 |
|
|
to reference some data. Local labels can be declared by using the
|
471 |
|
|
local pseudo-instruction, or by using the \? special value. The
|
472 |
|
|
\? value is replaced by a unique four-digit decimal number each
|
473 |
|
|
time a macro is used.
|
474 |
|
|
|
475 |
|
|
Example 2:
|
476 |
|
|
Macro3 macro text
|
477 |
|
|
local String
|
478 |
|
|
code
|
479 |
|
|
dw String
|
480 |
|
|
data
|
481 |
|
|
String db text,0
|
482 |
|
|
endm
|
483 |
|
|
|
484 |
|
|
Macro4 macro text
|
485 |
|
|
code
|
486 |
|
|
dw String\?
|
487 |
|
|
data
|
488 |
|
|
String\? db text,0
|
489 |
|
|
endm
|
490 |
|
|
|
491 |
|
|
Macro3 "Hello"
|
492 |
|
|
Macro4 "Hello"
|
493 |
|
|
|
494 |
|
|
Macros can also contain if...endif statements, and the exitm
|
495 |
|
|
pseudo-instruction can be used to terminate macro expansion.
|
496 |
|
|
Macros can also call other macros (or themselves) up to a nesting
|
497 |
|
|
depth of 15 levels.
|
498 |
|
|
|
499 |
|
|
Macro5 macro count
|
500 |
|
|
if count>25
|
501 |
|
|
exitm
|
502 |
|
|
endif
|
503 |
|
|
db 10*count
|
504 |
|
|
endm
|
505 |
|
|
|
506 |
|
|
Macro5 10
|
507 |
|
|
Macro5 100
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
nolist
|
511 |
|
|
|
512 |
|
|
Disable generation of the listing in the list-file.
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
noopt
|
516 |
|
|
|
517 |
|
|
Disable optimizations. If the -n option has been specified on the
|
518 |
|
|
command line, this pseudo-instruction has no effect.
|
519 |
|
|
|
520 |
|
|
|
521 |
|
|
nop
|
522 |
|
|
|
523 |
|
|
No operation. When the optional expression is not present, this
|
524 |
|
|
is simply the nop instruction of the processor. When the
|
525 |
|
|
expression is present, the specified number of nop instructions
|
526 |
|
|
are inserted.
|
527 |
|
|
|
528 |
|
|
Example:
|
529 |
|
|
nop 10
|
530 |
|
|
|
531 |
|
|
|
532 |
|
|
opt
|
533 |
|
|
|
534 |
|
|
Enable optimizations. If the -n option has been specified on the
|
535 |
|
|
command line, this pseudo-instruction has no effect.
|
536 |
|
|
When optimization is enabled, the assembler tries to use the
|
537 |
|
|
shortest and fastest instructions possible which have the effect
|
538 |
|
|
the user wants. It may replace any extended-address instruction
|
539 |
|
|
by direct-address instructions (provided the direct pseudo-
|
540 |
|
|
instruction has been used). It replaces long branches with jumps
|
541 |
|
|
or short branches, calls with branches to subroutines, and
|
542 |
|
|
replaces zero-offset indexed instructions by no-offset indexed
|
543 |
|
|
instructions. The effects of optimizations is clearly visible if
|
544 |
|
|
both a pass one and a pass two listing is generated.
|
545 |
|
|
|
546 |
|
|
|
547 |
|
|
org
|
548 |
|
|
|
549 |
|
|
The org (origin) pseudo-instruction specifies the next address to
|
550 |
|
|
be used for assembly. When no origin has been specified, the
|
551 |
|
|
assembler uses the value 0. The assembler maintains three separate
|
552 |
|
|
location counters: one for the code segment, one for the data
|
553 |
|
|
segment, and one for the bss segment. See the code and pseudo-
|
554 |
|
|
instruction for more information.
|
555 |
|
|
|
556 |
|
|
|
557 |
|
|
page
|
558 |
|
|
|
559 |
|
|
When the optional expression is not present, the assembly listing
|
560 |
|
|
is continued on the next page. When the expression is present,
|
561 |
|
|
the listing is continued on the next page only if the specified
|
562 |
|
|
number of lines do not fit on the current page.
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
|
566 |
|
|
|
567 |
|
|
|
568 |
|
|
The set pseudo-instruction sets the specified label to the value
|
569 |
|
|
of the expression. The label may or may not already exist.
|
570 |
|
|
Some programmers choose to use only upper-case identifiers for
|
571 |
|
|
labels defined in this way to differentiate them from addresses.
|
572 |
|
|
|
573 |
|
|
Example:
|
574 |
|
|
CURRENT set 0
|
575 |
|
|
|
576 |
|
|
.
|
577 |
|
|
.
|
578 |
|
|
.
|
579 |
|
|
|
580 |
|
|
CURRENT set CURRENT+1
|
581 |
|
|
|
582 |
|
|
|
583 |
|
|
struct
|
584 |
|
|
struct ,
|
585 |
|
|
|
586 |
|
|
The struct (structure) pseudo-instruction can be used to define
|
587 |
|
|
data structures in memory more easily.
|
588 |
|
|
|
589 |
|
|
The name of the structure is set to the total size of the structure;
|
590 |
|
|
if the expression is present, the starting offset is the value of
|
591 |
|
|
the expression in stead of zero.
|
592 |
|
|
|
593 |
|
|
Between the struct and end struct pseudo-instructions the following
|
594 |
|
|
pseudo-instructions can be used: db, dw, ds, label, align.
|
595 |
|
|
Within structures these pseudo-instructions take a slightly different
|
596 |
|
|
format than normally:
|
597 |
|
|
|
598 |
|
|
db element is one byte
|
599 |
|
|
|
600 |
|
|
dw element is two bytes
|
601 |
|
|
|
602 |
|
|
ds , element is the specified number of bytes
|
603 |
|
|
|
604 |
|
|
ds skip the specified number of bytes
|
605 |
|
|
|
606 |
|
|
label element is zero bytes, i.e. set the name
|
607 |
|
|
to the current structure offset
|
608 |
|
|
|
609 |
|
|
align skip until (offset%expression)=0
|
610 |
|
|
|
611 |
|
|
align skip until offset is even
|
612 |
|
|
|
613 |
|
|
|
614 |
|
|
Example:
|
615 |
|
|
struct ListNode,4
|
616 |
|
|
dw LN_Next
|
617 |
|
|
dw LN_Previous
|
618 |
|
|
db LN_Type
|
619 |
|
|
align
|
620 |
|
|
label LN_Simple ; size of structure so far
|
621 |
|
|
align 8
|
622 |
|
|
ds LN_Data,10
|
623 |
|
|
end struct
|
624 |
|
|
|
625 |
|
|
This is identical to:
|
626 |
|
|
|
627 |
|
|
LN_Next equ 4 ;\
|
628 |
|
|
LN_Previous equ 6 ; offset of structure elements
|
629 |
|
|
LN_Type equ 8 ;/
|
630 |
|
|
LN_Simple equ 10 ; size of structure so far
|
631 |
|
|
LN_Data equ 16 ; offset of structure element
|
632 |
|
|
ListNode equ 26 ; size of structure
|
633 |
|
|
|
634 |
|
|
|
635 |
|
|
title
|
636 |
|
|
|
637 |
|
|
The title pseudo-instruction sets the title to be used in the
|
638 |
|
|
header of each listing page. The string should be no longer than
|
639 |
|
|
80 characters.
|
640 |
|
|
|
641 |
|
|
Example:
|
642 |
|
|
title "DIS80 : A disassembler for a 8080 CPU"
|
643 |
|
|
|
644 |
|
|
|
645 |
|
|
ADDRESSING MODES
|
646 |
|
|
The assembler allows all 8080 (and when enabled also Z80) addressing
|
647 |
|
|
modes. The use of an expression between braces as an address disallows
|
648 |
|
|
braces at the outermost level for immediate values. The assembler
|
649 |
|
|
is capable to determine that
|
650 |
|
|
|
651 |
|
|
ld a,(10)+1
|
652 |
|
|
and
|
653 |
|
|
ld a,1+(10)
|
654 |
|
|
|
655 |
|
|
are immediate operands. You can also use rectangular brackets
|
656 |
|
|
[ and ] to include an address.
|
657 |
|
|
|
658 |
|
|
List of available modes:
|
659 |
|
|
immediate
|
660 |
|
|
(address)
|
661 |
|
|
(bc) (de) (hl) (sp)
|
662 |
|
|
|
663 |
|
|
Additional addressing modes for the Z80 and Z180:
|
664 |
|
|
(ix+offset) (ix-offset)
|
665 |
|
|
(iy+offset) (iy-offset)
|
666 |
|
|
(c)
|
667 |
|
|
|
668 |
|
|
|
669 |
|
|
LIST OF ACCEPTED INSTRUCTIONS
|
670 |
|
|
adc add align and bit bss call ccf code cp cpd cpdr cpi cpir cpl daa
|
671 |
|
|
data db dd dec defb defm defs defw di disable djnz ds dw ei else enable
|
672 |
|
|
end endif equ ex exx fcb fcc fcw fdb halt if im in inc include ind indr
|
673 |
|
|
ini inir jp jr ld ldd lddr ldi ldir list neg nolist noopt nop opt or
|
674 |
|
|
org otdr otir out outd outi page pop push res ret reti retn rim rl rla
|
675 |
|
|
rlc rlca rld rmb rr rra rrc rrca rrd rst sbc scf set shl shr sim sl sla
|
676 |
|
|
sr sra srl stc struct sub title tsti xor
|
677 |
|
|
|
678 |
|
|
Of these instructions, the following are (more or less) synonymous,
|
679 |
|
|
and can be used interchangably.
|
680 |
|
|
YOU CAN USE WHERE YOU WOULD PREVIOUSLY USE
|
681 |
|
|
nop 6 - nop nop nop ....
|
682 |
|
|
push bc,de - push bc ; push de
|
683 |
|
|
pop bc,de - pop de ; pop bc (note reversed order)
|
684 |
|
|
disable - di
|
685 |
|
|
enable - ei
|
686 |
|
|
sr - srl
|
687 |
|
|
shr - srl
|
688 |
|
|
sl - sla
|
689 |
|
|
shl - sla
|
690 |
|
|
stc - scf
|
691 |
|
|
ld bc,de - ld b,d ; ld c,e
|
692 |
|
|
ld ix,bc - ld xh,b ; ld xl,c
|
693 |
|
|
add R - add a,R
|
694 |
|
|
or a,R - or R
|
695 |
|
|
in (c) - tsti (c)
|
696 |
|
|
ex hl,de - ex de,hl
|
697 |
|
|
djnz LBL - dec b ; jp nz,LBL
|
698 |
|
|
jp nv,LBL - jp pe,LBL (no overflow/parity even)
|
699 |
|
|
jp v,LBL - jp po,LBL (overflow/parity odd)
|
700 |
|
|
jp ns,LBL - jp p,LBL (no sign/positive)
|
701 |
|
|
jp s,LBL - jp m,LBL (sign/negative)
|
702 |
|
|
|
703 |
|
|
Operands:
|
704 |
|
|
xh - ixh
|
705 |
|
|
xl - ixl
|
706 |
|
|
yh - iyh
|
707 |
|
|
yl - iyl
|
708 |
|
|
[Address] - (Address)
|
709 |
|
|
[hl] - (hl)
|
710 |
|
|
(ix-6) - (ix+-6)
|
711 |
|
|
|
712 |
|
|
And pseudo-instructions:
|
713 |
|
|
db - defb, defm
|
714 |
|
|
dw - defw
|
715 |
|
|
ds - defs
|
716 |
|
|
= - set
|
717 |
|
|
struct - lots of EQUs
|
718 |
|
|
|
719 |
|
|
|
720 |
|
|
LIST OF OTHER KEYWORDS
|
721 |
|
|
! != $ % & && ( ) * + , - / < << <= = > >= >> [ ] ^ | || ~
|
722 |
|
|
a af af' align b bc c d db de ds dw e end h hl i ix ixh ixl iy iyh
|
723 |
|
|
iyl l label m nc ns nv nz p pe po r s sp struct v xh xl yh yl z
|
724 |
|
|
|
725 |
|
|
|
726 |
|
|
FILES
|
727 |
|
|
.a80 - source file.
|
728 |
|
|
.z80 - source file -- first alternative.
|
729 |
|
|
.asm - source file -- second alternative.
|
730 |
|
|
.lst - List file.
|
731 |
|
|
.s19 - Motorola S-records output file.
|
732 |
|
|
.hex - Intel hex output file.
|
733 |
|
|
.bin - Binary output file.
|
734 |
|
|
|
735 |
|
|
|
736 |
|
|
BUGS
|
737 |
|
|
No provision for linking other pre-assembled modules is made.
|
738 |
|
|
Escape sequences in strings can't use the \x and
|
739 |
|
|
\ formats.
|
740 |
|
|
|
741 |
|
|
|
742 |
|
|
RETURNS
|
743 |
|
|
As80 returns one of the following values:
|
744 |
|
|
|
745 |
|
|
|
746 |
|
|
1 - Incorrect parameter specified on the commandline.
|
747 |
|
|
2 - Unable to open input or output file.
|
748 |
|
|
3 - Assembly gave errors.
|
749 |
|
|
4 - No memory could be allocated.
|
750 |
|
|
|
751 |
|
|
|
752 |
|
|
DIAGNOSTICS
|
753 |
|
|
Help message if only parameter is a question mark, or if an
|
754 |
|
|
illegal option has been specified.
|
755 |
|
|
|
756 |
|
|
|
757 |
|
|
AUTHOR
|
758 |
|
|
This is copyrighted software, but may be distributed freely as long
|
759 |
|
|
as this document accompanies the assembler, and no copyright messages
|
760 |
|
|
are removed. You are explicitly NOT allowed to sell this software
|
761 |
|
|
for anything more than a reasonable copying fee, say US$5.
|
762 |
|
|
To contact the author:
|
763 |
|
|
Frank A. Vorstenbosch
|
764 |
|
|
Kingswood Software
|
765 |
|
|
P.O. Box 85800 Phone: +31-(70)-355 5241
|
766 |
|
|
2508CM The Hague BBS: +31-(70)-355 8674
|
767 |
|
|
Netherlands Email: falstaff@xs4all.nl
|
768 |
|
|
|
769 |
|
|
-------------------------------------------------------------------------
|