Kingswood Software Development Tools AS80
|
Kingswood Software Development Tools AS80
|
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
|
|
NAME
|
NAME
|
as80 - assembler for 8080, 8085 and Z80 microprocessors.
|
as80 - assembler for 8080, 8085 and Z80 microprocessors.
|
|
|
|
|
SYNOPSIS
|
SYNOPSIS
|
as80 [-cdghilnopqstvwxz] file
|
as80 [-cdghilnopqstvwxz] file
|
|
|
|
|
DESCRIPTION
|
DESCRIPTION
|
This documentation is for as80 [1.10].
|
This documentation is for as80 [1.10].
|
Copyright 1990-1994, Frank A. Vorstenbosch, Kingswood Software.
|
Copyright 1990-1994, Frank A. Vorstenbosch, Kingswood Software.
|
|
|
AS80 is an assembler for the Intel 8080/8085 and Zilog Z80
|
AS80 is an assembler for the Intel 8080/8085 and Zilog Z80
|
microprocessors. It reads input from an ASCII text file, assembles
|
microprocessors. It reads input from an ASCII text file, assembles
|
this into memory, and then writes a listing and a binary or hex file.
|
this into memory, and then writes a listing and a binary or hex file.
|
|
|
AS80 is case sensitive, not only does it differentiate between the
|
AS80 is case sensitive, not only does it differentiate between the
|
labels XYZ and xyz, but it also requires all (pseudo) instruction and
|
labels XYZ and xyz, but it also requires all (pseudo) instruction and
|
register names to be lower case. This way, the listing is the most
|
register names to be lower case. This way, the listing is the most
|
readable. Option -i can be used to make the assembler case insensitive.
|
readable. Option -i can be used to make the assembler case insensitive.
|
Alternatively, the included TOLOWER program can be used to convert
|
Alternatively, the included TOLOWER program can be used to convert
|
sources to lower case.
|
sources to lower case.
|
|
|
|
|
OPTIONS
|
OPTIONS
|
As80 recognizes the following options:
|
As80 recognizes the following options:
|
|
|
-c Show number of cycles per instruction in listing. This
|
-c Show number of cycles per instruction in listing. This
|
decreases the number of columns available for listing by 5.
|
decreases the number of columns available for listing by 5.
|
The number of cycles is printed between brackets [ and ].
|
The number of cycles is printed between brackets [ and ].
|
|
|
-d
|
-d
|
Define a label before the first source line is read. If
|
Define a label before the first source line is read. If
|
no name is specified, DEBUG is defined. The label is
|
no name is specified, DEBUG is defined. The label is
|
EQUated to be 1.
|
EQUated to be 1.
|
|
|
-g Generate source-level debug information file. This file
|
-g Generate source-level debug information file. This file
|
can then be used in in-system debugging or a software
|
can then be used in in-system debugging or a software
|
simulator.
|
simulator.
|
|
|
-h
|
-h
|
Specify height of page for listing. This option determines
|
Specify height of page for listing. This option determines
|
the number of lines per printed page. Each page has a header
|
the number of lines per printed page. Each page has a header
|
and is terminated by a form-feed character. The special
|
and is terminated by a form-feed character. The special
|
case -h0 indicates an infinite page length. In this case,
|
case -h0 indicates an infinite page length. In this case,
|
page breaks are only inserted between the two passes and
|
page breaks are only inserted between the two passes and
|
the symbol table (if present).
|
the symbol table (if present).
|
|
|
-i Ignore case in opcodes. In this way, the assembler does not
|
-i Ignore case in opcodes. In this way, the assembler does not
|
differentiate between 'add' and 'ADD', for example. Labels
|
differentiate between 'add' and 'ADD', for example. Labels
|
are still case sensitive.
|
are still case sensitive.
|
|
|
-l Generate pass 2 listing.
|
-l Generate pass 2 listing.
|
|
|
-l
|
-l
|
Listing file name. The listing file is used for pass 1 and
|
Listing file name. The listing file is used for pass 1 and
|
pass 2 listing, for the symbol table (printed between the
|
pass 2 listing, for the symbol table (printed between the
|
two passes), and some statistics. When neither -p nor -t
|
two passes), and some statistics. When neither -p nor -t
|
is specified, and -l is given, then the assembler
|
is specified, and -l is given, then the assembler
|
automatically generates a pass 2 listing. When -p or -t is
|
automatically generates a pass 2 listing. When -p or -t is
|
specified, an additional -l should be given is a pass 2
|
specified, an additional -l should be given is a pass 2
|
listing is required. The filename - can be used to direct
|
listing is required. The filename - can be used to direct
|
the listing to standard output.
|
the listing to standard output.
|
|
|
-l Generate pass 2 listing.
|
-l Generate pass 2 listing.
|
|
|
-m Show macro expansions in listing. Macro lines are prefixed
|
-m Show macro expansions in listing. Macro lines are prefixed
|
by a > sign.
|
by a > sign.
|
|
|
-n Disable optimizations. When this option is specified no
|
-n Disable optimizations. When this option is specified no
|
optimizations will be done, even when the OPT pseudo-
|
optimizations will be done, even when the OPT pseudo-
|
instruction is used in the source code.
|
instruction is used in the source code.
|
|
|
-o
|
-o
|
Specify binary or s-records output file name. The assembler
|
Specify binary or s-records output file name. The assembler
|
automatically adds ".bin" for binary output or ".s19" for
|
automatically adds ".bin" for binary output or ".s19" for
|
s-records output when no extension is given.
|
s-records output when no extension is given.
|
|
|
-p Generate pass 1 listing. This may be used to examine any
|
-p Generate pass 1 listing. This may be used to examine any
|
optimizations/bugs generated in pass 2.
|
optimizations/bugs generated in pass 2.
|
|
|
-q Quiet mode. No running line counter is displayed on standard
|
-q Quiet mode. No running line counter is displayed on standard
|
error output.
|
error output.
|
|
|
-s Write s-records instead of binary file. The s-records file
|
-s Write s-records instead of binary file. The s-records file
|
contains data for (only) the used memory; the binary file
|
contains data for (only) the used memory; the binary file
|
begins at the lowest used address, and continues up to the
|
begins at the lowest used address, and continues up to the
|
highest used address; filling unused memory between these
|
highest used address; filling unused memory between these
|
two addresses with either $ff or $00.
|
two addresses with either $ff or $00.
|
|
|
-s2 Write intel-hex file instead of binary file. The intel-hex
|
-s2 Write intel-hex file instead of binary file. The intel-hex
|
file contains data for (only) the used memory.
|
file contains data for (only) the used memory.
|
|
|
-t Generate symbol table. The symbol table is listed between
|
-t Generate symbol table. The symbol table is listed between
|
passes one and two, displaying the name, hexadecimal and
|
passes one and two, displaying the name, hexadecimal and
|
decimal value of each label, using 4-digit hexadecimal
|
decimal value of each label, using 4-digit hexadecimal
|
numbers where possible, otherwise 8-digit numbers. The
|
numbers where possible, otherwise 8-digit numbers. The
|
decimal value is followed by an asterisk if the label is
|
decimal value is followed by an asterisk if the label is
|
redefinable (defined using SET instead of EQU).
|
redefinable (defined using SET instead of EQU).
|
|
|
-v Verbose mode. More information is displayed on standard
|
-v Verbose mode. More information is displayed on standard
|
output.
|
output.
|
|
|
-w
|
-w
|
Specify column width. Normally, the listing is printed using
|
Specify column width. Normally, the listing is printed using
|
79 columns for output to a 80-column screen or printer. If
|
79 columns for output to a 80-column screen or printer. If
|
the -w option is given without a number following it, then
|
the -w option is given without a number following it, then
|
the listing will be 131 columns wide, otherwise it will be
|
the listing will be 131 columns wide, otherwise it will be
|
the number of colulmns specified (between 60 and 200).
|
the number of colulmns specified (between 60 and 200).
|
|
|
-x1 Use 8085 extensions. The 8085 CPU has two additional
|
-x1 Use 8085 extensions. The 8085 CPU has two additional
|
instructions and different cycle counts, but is otherwise
|
instructions and different cycle counts, but is otherwise
|
software compatible to the 8080. When this option is not
|
software compatible to the 8080. When this option is not
|
specified the assembler rejects the RIM and SIM instructions.
|
specified the assembler rejects the RIM and SIM instructions.
|
|
|
-x or
|
-x or
|
-x2
|
-x2
|
Use Z80 extensions. The Z80 has many additional instructions
|
Use Z80 extensions. The Z80 has many additional instructions
|
and addressing modes, but is otherwise software compatible to
|
and addressing modes, but is otherwise software compatible to
|
the 8080. When this option is not specified the assembler
|
the 8080. When this option is not specified the assembler
|
rejects all Z80 new instructions and addressing modes.
|
rejects all Z80 new instructions and addressing modes.
|
|
|
-x3 Use Z80 extensions and index register byte instructions.
|
-x3 Use Z80 extensions and index register byte instructions.
|
The IX and IY registers were originally intended to be
|
The IX and IY registers were originally intended to be
|
split in IXH/IXL and IYH/IYL register pairs. For some
|
split in IXH/IXL and IYH/IYL register pairs. For some
|
reason (bug in original mask set?) these instructions were
|
reason (bug in original mask set?) these instructions were
|
not included by Zilog in the programming manuals, but
|
not included by Zilog in the programming manuals, but
|
they do work on all CPUs I've seen. Your mileage may vary.
|
they do work on all CPUs I've seen. Your mileage may vary.
|
Note that these extensions do NOT work on the Z180/181 and
|
Note that these extensions do NOT work on the Z180/181 and
|
H64180, but they DO (and are documented) on the Z280.
|
H64180, but they DO (and are documented) on the Z280.
|
|
|
-z Fill unused memory with zeros. Normally when a binary file
|
-z Fill unused memory with zeros. Normally when a binary file
|
is generated, unused bytes between the lowest and highest
|
is generated, unused bytes between the lowest and highest
|
used addresses are filled with $ff, the unprogrammed state
|
used addresses are filled with $ff, the unprogrammed state
|
of EPROMs. If this is not wanted, the -z option can be used
|
of EPROMs. If this is not wanted, the -z option can be used
|
to initialize this memory to $00. With s-records, unused
|
to initialize this memory to $00. With s-records, unused
|
memory is not output to the file, and this option forces the
|
memory is not output to the file, and this option forces the
|
creation of an S9 (start address) record instead, even if no
|
creation of an S9 (start address) record instead, even if no
|
start address is specified in the file with the END pseudo-
|
start address is specified in the file with the END pseudo-
|
instruction.
|
instruction.
|
|
|
Commandline options can be catenated, but no other option can follow
|
Commandline options can be catenated, but no other option can follow
|
one that may have a parameter. Thus:
|
one that may have a parameter. Thus:
|
-tlfile
|
-tlfile
|
is correct (specifying symbol table and pass 2 listing), but
|
is correct (specifying symbol table and pass 2 listing), but
|
-h5t
|
-h5t
|
is not.
|
is not.
|
|
|
It is possible to discard any of the the output files by specifying
|
It is possible to discard any of the the output files by specifying
|
the name 'nul'.
|
the name 'nul'.
|
|
|
|
|
EXPRESSIONS
|
EXPRESSIONS
|
|
|
The assembler recognizes most C-language expressions. The operators
|
The assembler recognizes most C-language expressions. The operators
|
are listed here in order of precedence, highest first:
|
are listed here in order of precedence, highest first:
|
|
|
() braces to group subexpressions
|
() braces to group subexpressions
|
* $ current location counter
|
* $ current location counter
|
unary + - ! ~ unary + (no-operation), negation, logical NOT,
|
unary + - ! ~ unary + (no-operation), negation, logical NOT,
|
binary NOT
|
binary NOT
|
* / % multiplication, division, modulo
|
* / % multiplication, division, modulo
|
+ - addition, subtraction
|
+ - addition, subtraction
|
<< >> shift left, shift right
|
<< >> shift left, shift right
|
< > <= >= comparison for greater/less than
|
< > <= >= comparison for greater/less than
|
= != comparison for equality (== can be used for =)
|
= != comparison for equality (== can be used for =)
|
& binary AND
|
& binary AND
|
^ binary XOR
|
^ binary XOR
|
| binary OR
|
| binary OR
|
&& logical AND
|
&& logical AND
|
|| logical OR
|
|| logical OR
|
hi lo high byte, low byte
|
hi lo high byte, low byte
|
|
|
The logical NOT (!) evaluates to zero if the parameter is nonzero,
|
The logical NOT (!) evaluates to zero if the parameter is nonzero,
|
and vice versa. The binary NOT (~) complements all the bits in its
|
and vice versa. The binary NOT (~) complements all the bits in its
|
parameter. Logical AND (&&) and OR (||) operators evaluate to one
|
parameter. Logical AND (&&) and OR (||) operators evaluate to one
|
if both resp. at least one argument is nonzero. These two operators
|
if both resp. at least one argument is nonzero. These two operators
|
evaluate both arguments, unlike the C-language versions.
|
evaluate both arguments, unlike the C-language versions.
|
|
|
Note: the asterisk is both used as the multiplication operator, and
|
Note: the asterisk is both used as the multiplication operator, and
|
as symbol for the current location. The assembler determines from
|
as symbol for the current location. The assembler determines from
|
the context which is which. Thus:
|
the context which is which. Thus:
|
|
|
5**
|
5**
|
|
|
is a valid expression, evaluating to five times the current location
|
is a valid expression, evaluating to five times the current location
|
counter, and:
|
counter, and:
|
|
|
2+*/2
|
2+*/2
|
|
|
is too, evaluating to the current location counter divided by two, to
|
is too, evaluating to the current location counter divided by two, to
|
which two is added. In the same way, the % sign is both used as the
|
which two is added. In the same way, the % sign is both used as the
|
modulo operator and the prefix for binary numbers.
|
modulo operator and the prefix for binary numbers.
|
|
|
Numbers can be specified in any number base between 2 and 36.
|
Numbers can be specified in any number base between 2 and 36.
|
Decimal numbers can be used without a prefix, hexadecimal numbers
|
Decimal numbers can be used without a prefix, hexadecimal numbers
|
can be prefixed by $, octal numbers by @, and binary numbers by %.
|
can be prefixed by $, octal numbers by @, and binary numbers by %.
|
Other number bases can be used by using the following format:
|
Other number bases can be used by using the following format:
|
#,
|
#,
|
where the base is the number base to use (must be specified in
|
where the base is the number base to use (must be specified in
|
decimal), and number is the value. Thus:
|
decimal), and number is the value. Thus:
|
1000 - decimal number, value 10*10*10=1000
|
1000 - decimal number, value 10*10*10=1000
|
%1000 - binary number, value 2*2*2=8
|
%1000 - binary number, value 2*2*2=8
|
@1000 - octal number, value 8*8*8=512
|
@1000 - octal number, value 8*8*8=512
|
$1000 - hexadecimal number, value 16*16*16=4096
|
$1000 - hexadecimal number, value 16*16*16=4096
|
#1000 - hexadecimal number, value 16*16*16=4096
|
#1000 - hexadecimal number, value 16*16*16=4096
|
0b1000 - binary number, value 2*2*2=8
|
0b1000 - binary number, value 2*2*2=8
|
0x1000 - hexadecimal number, value 16*16*16=4096
|
0x1000 - hexadecimal number, value 16*16*16=4096
|
2#1000 - binary number, value 2*2*2=8
|
2#1000 - binary number, value 2*2*2=8
|
4#1000 - base-4 number, value 4*4*4=64
|
4#1000 - base-4 number, value 4*4*4=64
|
7#1000 - base-7 number, value 7*7*7=343
|
7#1000 - base-7 number, value 7*7*7=343
|
36#1000 - base-36 number, value 36*36*36=444528
|
36#1000 - base-36 number, value 36*36*36=444528
|
For number bases greater than 10, additional digits are represented
|
For number bases greater than 10, additional digits are represented
|
by letters, starting from A. Both lower and upper case letters can
|
by letters, starting from A. Both lower and upper case letters can
|
be used.
|
be used.
|
11#aa = 120
|
11#aa = 120
|
16#ff = 255
|
16#ff = 255
|
25#oo = 624
|
25#oo = 624
|
36#zz = 1295
|
36#zz = 1295
|
|
|
|
|
PSEUDO-INSTRUCTIONS
|
PSEUDO-INSTRUCTIONS
|
|
|
align
|
align
|
|
|
Align fills zero or more bytes with zeros until the new address
|
Align fills zero or more bytes with zeros until the new address
|
modulo equals zero. If the expression is not present,
|
modulo equals zero. If the expression is not present,
|
align fills zero or one bytes with zeros until the new address
|
align fills zero or one bytes with zeros until the new address
|
is even.
|
is even.
|
|
|
Example 1:
|
Example 1:
|
align 256 ; continue assembly on the
|
align 256 ; continue assembly on the
|
; next 256-byte page
|
; next 256-byte page
|
|
|
Example 2:
|
Example 2:
|
align ; make sure table begins
|
align ; make sure table begins
|
Table dw 1,2,3 ; on an even address
|
Table dw 1,2,3 ; on an even address
|
|
|
|
|
|
|
bss
|
bss
|
|
|
Put all following data in the bss segment. Only data pseudo-instructions
|
Put all following data in the bss segment. Only data pseudo-instructions
|
can be used in the bss segment, and these only increment the location
|
can be used in the bss segment, and these only increment the location
|
counter. It is up to the programmer to initialize the bss segment. The
|
counter. It is up to the programmer to initialize the bss segment. The
|
bss segment is especially meaningful in a ROM based system where
|
bss segment is especially meaningful in a ROM based system where
|
variables must be placed in RAM, and RAM is not automatically initialized.
|
variables must be placed in RAM, and RAM is not automatically initialized.
|
|
|
The assembler internally maintains three separate location counters,
|
The assembler internally maintains three separate location counters,
|
one for the code segment, one for the data segment and one for the
|
one for the code segment, one for the data segment and one for the
|
uninitialized data segment. The user is responsible for not overlapping
|
uninitialized data segment. The user is responsible for not overlapping
|
the segments by setting appropriate origins. The code, data and bss
|
the segments by setting appropriate origins. The code, data and bss
|
pseudo-instructions can be used to interleave code and data in the source
|
pseudo-instructions can be used to interleave code and data in the source
|
listing, while separating the three in the generated program. The
|
listing, while separating the three in the generated program. The
|
assembler starts with the code segment if none is specified.
|
assembler starts with the code segment if none is specified.
|
|
|
Example:
|
Example:
|
code
|
code
|
org $f000 ; Assuming 4 kbyte code ROM
|
org $f000 ; Assuming 4 kbyte code ROM
|
data ; with 2 kbyte program and
|
data ; with 2 kbyte program and
|
org $f800 ; 2 kbyte initialized data
|
org $f800 ; 2 kbyte initialized data
|
bss
|
bss
|
org 0 ; bss segment is in RAM
|
org 0 ; bss segment is in RAM
|
|
|
Buffer ds 100
|
Buffer ds 100
|
|
|
code
|
code
|
Begin ld hl,Table
|
Begin ld hl,Table
|
ld de,Buffer
|
ld de,Buffer
|
ld bc,3
|
ld bc,3
|
ldir
|
ldir
|
.
|
.
|
.
|
.
|
.
|
.
|
|
|
data
|
data
|
Table db 1,2,3
|
Table db 1,2,3
|
|
|
code
|
code
|
MyFunc ld ix,Table
|
MyFunc ld ix,Table
|
.
|
.
|
.
|
.
|
|
|
code
|
code
|
|
|
Put all following assembled instructions and data in the code segment.
|
Put all following assembled instructions and data in the code segment.
|
See BSS.
|
See BSS.
|
|
|
|
|
data
|
data
|
|
|
Put all following assembled instructions and data in the data segment.
|
Put all following assembled instructions and data in the data segment.
|
See BSS.
|
See BSS.
|
|
|
|
|
db
|
db
|
|
|
Define bytes. The bytes may be specified as expressions or strings,
|
Define bytes. The bytes may be specified as expressions or strings,
|
and are placed in the current (code or data) segment. This pseudo
|
and are placed in the current (code or data) segment. This pseudo
|
instruction is similar to the Zilog-defined defb and defm pseudo-
|
instruction is similar to the Zilog-defined defb and defm pseudo-
|
instructions.
|
instructions.
|
|
|
Example:
|
Example:
|
Message db "\aError\r\n",0
|
Message db "\aError\r\n",0
|
|
|
|
|
defb
|
defb
|
|
|
Define bytes. The bytes may be specified only as expressions,
|
Define bytes. The bytes may be specified only as expressions,
|
and are placed in the current (code or data) segment. This
|
and are placed in the current (code or data) segment. This
|
pseudo-instruction is similar to the db pseudo-instruction.
|
pseudo-instruction is similar to the db pseudo-instruction.
|
|
|
Example:
|
Example:
|
Message defb 7
|
Message defb 7
|
defm "Error"
|
defm "Error"
|
defb 13,10,0
|
defb 13,10,0
|
|
|
|
|
defm
|
defm
|
|
|
Define message. The bytes may be specified only as a string, and
|
Define message. The bytes may be specified only as a string, and
|
are placed in the current (code or data) segment. This pseudo-
|
are placed in the current (code or data) segment. This pseudo-
|
instruction is similar to the db pseudo-instruction.
|
instruction is similar to the db pseudo-instruction.
|
|
|
|
|
ds
|
ds
|
defs
|
defs
|
|
|
Define zero or more bytes empty space. The specified number of
|
Define zero or more bytes empty space. The specified number of
|
bytes are filled with zeros. This pseudo-instruction is identical
|
bytes are filled with zeros. This pseudo-instruction is identical
|
to the Zilog-defined pseudo-instruction defs.
|
to the Zilog-defined pseudo-instruction defs.
|
|
|
Example:
|
Example:
|
ds 100 ; reserve 100 bytes here
|
ds 100 ; reserve 100 bytes here
|
|
|
|
|
dw
|
dw
|
defw
|
defw
|
|
|
Define words. The words are placed in the current (code or data)
|
Define words. The words are placed in the current (code or data)
|
segment. This pseudo-instruction is identical to the Zilog-
|
segment. This pseudo-instruction is identical to the Zilog-
|
defined defw pseudo-instruction.
|
defined defw pseudo-instruction.
|
|
|
Example:
|
Example:
|
ld a,2*Function ; number of function
|
ld a,2*Function ; number of function
|
ld hl,JumpTable
|
ld hl,JumpTable
|
add a,l ; calculate HL+A
|
add a,l ; calculate HL+A
|
ld l,a
|
ld l,a
|
adc a,h
|
adc a,h
|
sub l
|
sub l
|
ld h,a
|
ld h,a
|
jp (hl) ; jump to function
|
jp (hl) ; jump to function
|
|
|
JumpTable dw Function0
|
JumpTable dw Function0
|
dw Function1
|
dw Function1
|
dw Function2
|
dw Function2
|
|
|
|
|
else
|
else
|
|
|
The else pseudo-instruction can be used for if-then-else
|
The else pseudo-instruction can be used for if-then-else
|
constructions. It must be placed between an if and an endif
|
constructions. It must be placed between an if and an endif
|
instruction. For an example, see the if pseudo-instruction.
|
instruction. For an example, see the if pseudo-instruction.
|
|
|
|
|
end
|
end
|
|
|
The end pseudo-instruction is optional, and need not be used. If
|
The end pseudo-instruction is optional, and need not be used. If
|
it is used, its optional operand specifies the staring address of
|
it is used, its optional operand specifies the staring address of
|
the program. This address is displayed when the program is
|
the program. This address is displayed when the program is
|
assembled, and is also placed in the s-record output file.
|
assembled, and is also placed in the s-record output file.
|
|
|
Example:
|
Example:
|
end Start
|
end Start
|
|
|
endif
|
endif
|
|
|
The endif pseudo-instruction must be used to close an if-endif
|
The endif pseudo-instruction must be used to close an if-endif
|
or if-else-endif construction. For an example, see the if
|
or if-else-endif construction. For an example, see the if
|
pseudo-instruction.
|
pseudo-instruction.
|
|
|
|
|
|
|
|
|
The equ (equate) pseudo-instruction sets the specified label to
|
The equ (equate) pseudo-instruction sets the specified label to
|
the value of the expression. The label may not already exist.
|
the value of the expression. The label may not already exist.
|
Some programmers choose to use only upper-case identifiers for
|
Some programmers choose to use only upper-case identifiers for
|
labels defined in this way to differentiate them from addresses.
|
labels defined in this way to differentiate them from addresses.
|
|
|
Example:
|
Example:
|
ESCAPE equ 27
|
ESCAPE equ 27
|
|
|
|
|
if
|
if
|
|
|
The if pseudo-instruction can be used in conjunction with the
|
The if pseudo-instruction can be used in conjunction with the
|
endif and possibly the else pseudo-instructions to selectively
|
endif and possibly the else pseudo-instructions to selectively
|
enable and disable pieces of code in the source. If the expression
|
enable and disable pieces of code in the source. If the expression
|
given evaluates to zero, then the following code up to the matching
|
given evaluates to zero, then the following code up to the matching
|
else or endif is not included in the assembly. If the expression
|
else or endif is not included in the assembly. If the expression
|
is nonzero, then the following code is included, but any code
|
is nonzero, then the following code is included, but any code
|
between the matching else and endif is not.
|
between the matching else and endif is not.
|
The original Zilog assemblers called this pseudo-instruction COND.
|
The original Zilog assemblers called this pseudo-instruction COND.
|
|
|
Example:
|
Example:
|
if COUNT=2 | COUNT=4
|
if COUNT=2 | COUNT=4
|
add a,a ; shift left for counts
|
add a,a ; shift left for counts
|
if COUNT=4 ; of 2 and 4
|
if COUNT=4 ; of 2 and 4
|
add a,a
|
add a,a
|
endif
|
endif
|
else
|
else
|
ld b,COUNT ; otherwise use slow multiply
|
ld b,COUNT ; otherwise use slow multiply
|
call Multiply
|
call Multiply
|
endif
|
endif
|
|
|
|
|
include
|
include
|
|
|
The named file is included in the assembly at this point. After
|
The named file is included in the assembly at this point. After
|
it has been read, assembly continues with the next line of the
|
it has been read, assembly continues with the next line of the
|
current file. Include files may be nested.
|
current file. Include files may be nested.
|
|
|
Example:
|
Example:
|
include "z180.i"
|
include "z180.i"
|
|
|
|
|
list
|
list
|
|
|
Enable generation of the listing in the list-file. If the listing
|
Enable generation of the listing in the list-file. If the listing
|
has been disabled twice, it must be enabled twice before it is
|
has been disabled twice, it must be enabled twice before it is
|
generated. When no -p or -l option has been specified on the
|
generated. When no -p or -l option has been specified on the
|
command line, this pseudo-instruction has no effect.
|
command line, this pseudo-instruction has no effect.
|
|
|
|
|
macro
|
macro
|
|
|
Define a macro. Macros allow a block of source statements to be
|
Define a macro. Macros allow a block of source statements to be
|
given a name, and then that name can be used to include the
|
given a name, and then that name can be used to include the
|
statements anywhere in the program. Parameters can be used to
|
statements anywhere in the program. Parameters can be used to
|
pass arguments to the macro. In the macro definition names
|
pass arguments to the macro. In the macro definition names
|
can be used to respresent the arguments; these names in the text
|
can be used to respresent the arguments; these names in the text
|
are substituted with the value passed on macro expansion.
|
are substituted with the value passed on macro expansion.
|
Macro arguments can also be represented by using \1 through \9
|
Macro arguments can also be represented by using \1 through \9
|
in the macro text; these sequences are replaced by the first
|
in the macro text; these sequences are replaced by the first
|
through ninth argument respectively. The special value \0
|
through ninth argument respectively. The special value \0
|
contains the number of arguments passed to the macro.
|
contains the number of arguments passed to the macro.
|
|
|
Example 1:
|
Example 1:
|
Macro1 macro text,value
|
Macro1 macro text,value
|
dw value
|
dw value
|
db text,0
|
db text,0
|
db "value=",'value',0
|
db "value=",'value',0
|
endm
|
endm
|
|
|
Macro2 macro
|
Macro2 macro
|
dw \2
|
dw \2
|
db \1,0
|
db \1,0
|
db "value=\2",0
|
db "value=\2",0
|
endm
|
endm
|
|
|
Macro1 "Hello",123
|
Macro1 "Hello",123
|
Macro2 "Hello",123
|
Macro2 "Hello",123
|
|
|
Macros can also use local labels, for when a unique label is needed
|
Macros can also use local labels, for when a unique label is needed
|
each time the macro is expanded. This can be used when the macro
|
each time the macro is expanded. This can be used when the macro
|
contains a conditional jump, or a loop of some kind, or simply needs
|
contains a conditional jump, or a loop of some kind, or simply needs
|
to reference some data. Local labels can be declared by using the
|
to reference some data. Local labels can be declared by using the
|
local pseudo-instruction, or by using the \? special value. The
|
local pseudo-instruction, or by using the \? special value. The
|
\? value is replaced by a unique four-digit decimal number each
|
\? value is replaced by a unique four-digit decimal number each
|
time a macro is used.
|
time a macro is used.
|
|
|
Example 2:
|
Example 2:
|
Macro3 macro text
|
Macro3 macro text
|
local String
|
local String
|
code
|
code
|
dw String
|
dw String
|
data
|
data
|
String db text,0
|
String db text,0
|
endm
|
endm
|
|
|
Macro4 macro text
|
Macro4 macro text
|
code
|
code
|
dw String\?
|
dw String\?
|
data
|
data
|
String\? db text,0
|
String\? db text,0
|
endm
|
endm
|
|
|
Macro3 "Hello"
|
Macro3 "Hello"
|
Macro4 "Hello"
|
Macro4 "Hello"
|
|
|
Macros can also contain if...endif statements, and the exitm
|
Macros can also contain if...endif statements, and the exitm
|
pseudo-instruction can be used to terminate macro expansion.
|
pseudo-instruction can be used to terminate macro expansion.
|
Macros can also call other macros (or themselves) up to a nesting
|
Macros can also call other macros (or themselves) up to a nesting
|
depth of 15 levels.
|
depth of 15 levels.
|
|
|
Macro5 macro count
|
Macro5 macro count
|
if count>25
|
if count>25
|
exitm
|
exitm
|
endif
|
endif
|
db 10*count
|
db 10*count
|
endm
|
endm
|
|
|
Macro5 10
|
Macro5 10
|
Macro5 100
|
Macro5 100
|
|
|
|
|
nolist
|
nolist
|
|
|
Disable generation of the listing in the list-file.
|
Disable generation of the listing in the list-file.
|
|
|
|
|
noopt
|
noopt
|
|
|
Disable optimizations. If the -n option has been specified on the
|
Disable optimizations. If the -n option has been specified on the
|
command line, this pseudo-instruction has no effect.
|
command line, this pseudo-instruction has no effect.
|
|
|
|
|
nop
|
nop
|
|
|
No operation. When the optional expression is not present, this
|
No operation. When the optional expression is not present, this
|
is simply the nop instruction of the processor. When the
|
is simply the nop instruction of the processor. When the
|
expression is present, the specified number of nop instructions
|
expression is present, the specified number of nop instructions
|
are inserted.
|
are inserted.
|
|
|
Example:
|
Example:
|
nop 10
|
nop 10
|
|
|
|
|
opt
|
opt
|
|
|
Enable optimizations. If the -n option has been specified on the
|
Enable optimizations. If the -n option has been specified on the
|
command line, this pseudo-instruction has no effect.
|
command line, this pseudo-instruction has no effect.
|
When optimization is enabled, the assembler tries to use the
|
When optimization is enabled, the assembler tries to use the
|
shortest and fastest instructions possible which have the effect
|
shortest and fastest instructions possible which have the effect
|
the user wants. It may replace any extended-address instruction
|
the user wants. It may replace any extended-address instruction
|
by direct-address instructions (provided the direct pseudo-
|
by direct-address instructions (provided the direct pseudo-
|
instruction has been used). It replaces long branches with jumps
|
instruction has been used). It replaces long branches with jumps
|
or short branches, calls with branches to subroutines, and
|
or short branches, calls with branches to subroutines, and
|
replaces zero-offset indexed instructions by no-offset indexed
|
replaces zero-offset indexed instructions by no-offset indexed
|
instructions. The effects of optimizations is clearly visible if
|
instructions. The effects of optimizations is clearly visible if
|
both a pass one and a pass two listing is generated.
|
both a pass one and a pass two listing is generated.
|
|
|
|
|
org
|
org
|
|
|
The org (origin) pseudo-instruction specifies the next address to
|
The org (origin) pseudo-instruction specifies the next address to
|
be used for assembly. When no origin has been specified, the
|
be used for assembly. When no origin has been specified, the
|
assembler uses the value 0. The assembler maintains three separate
|
assembler uses the value 0. The assembler maintains three separate
|
location counters: one for the code segment, one for the data
|
location counters: one for the code segment, one for the data
|
segment, and one for the bss segment. See the code and pseudo-
|
segment, and one for the bss segment. See the code and pseudo-
|
instruction for more information.
|
instruction for more information.
|
|
|
|
|
page
|
page
|
|
|
When the optional expression is not present, the assembly listing
|
When the optional expression is not present, the assembly listing
|
is continued on the next page. When the expression is present,
|
is continued on the next page. When the expression is present,
|
the listing is continued on the next page only if the specified
|
the listing is continued on the next page only if the specified
|
number of lines do not fit on the current page.
|
number of lines do not fit on the current page.
|
|
|
|
|
|
|
|
|
|
|
The set pseudo-instruction sets the specified label to the value
|
The set pseudo-instruction sets the specified label to the value
|
of the expression. The label may or may not already exist.
|
of the expression. The label may or may not already exist.
|
Some programmers choose to use only upper-case identifiers for
|
Some programmers choose to use only upper-case identifiers for
|
labels defined in this way to differentiate them from addresses.
|
labels defined in this way to differentiate them from addresses.
|
|
|
Example:
|
Example:
|
CURRENT set 0
|
CURRENT set 0
|
|
|
.
|
.
|
.
|
.
|
.
|
.
|
|
|
CURRENT set CURRENT+1
|
CURRENT set CURRENT+1
|
|
|
|
|
struct
|
struct
|
struct ,
|
struct ,
|
|
|
The struct (structure) pseudo-instruction can be used to define
|
The struct (structure) pseudo-instruction can be used to define
|
data structures in memory more easily.
|
data structures in memory more easily.
|
|
|
The name of the structure is set to the total size of the structure;
|
The name of the structure is set to the total size of the structure;
|
if the expression is present, the starting offset is the value of
|
if the expression is present, the starting offset is the value of
|
the expression in stead of zero.
|
the expression in stead of zero.
|
|
|
Between the struct and end struct pseudo-instructions the following
|
Between the struct and end struct pseudo-instructions the following
|
pseudo-instructions can be used: db, dw, ds, label, align.
|
pseudo-instructions can be used: db, dw, ds, label, align.
|
Within structures these pseudo-instructions take a slightly different
|
Within structures these pseudo-instructions take a slightly different
|
format than normally:
|
format than normally:
|
|
|
db element is one byte
|
db element is one byte
|
|
|
dw element is two bytes
|
dw element is two bytes
|
|
|
ds , element is the specified number of bytes
|
ds , element is the specified number of bytes
|
|
|
ds skip the specified number of bytes
|
ds skip the specified number of bytes
|
|
|
label element is zero bytes, i.e. set the name
|
label element is zero bytes, i.e. set the name
|
to the current structure offset
|
to the current structure offset
|
|
|
align skip until (offset%expression)=0
|
align skip until (offset%expression)=0
|
|
|
align skip until offset is even
|
align skip until offset is even
|
|
|
|
|
Example:
|
Example:
|
struct ListNode,4
|
struct ListNode,4
|
dw LN_Next
|
dw LN_Next
|
dw LN_Previous
|
dw LN_Previous
|
db LN_Type
|
db LN_Type
|
align
|
align
|
label LN_Simple ; size of structure so far
|
label LN_Simple ; size of structure so far
|
align 8
|
align 8
|
ds LN_Data,10
|
ds LN_Data,10
|
end struct
|
end struct
|
|
|
This is identical to:
|
This is identical to:
|
|
|
LN_Next equ 4 ;\
|
LN_Next equ 4 ;\
|
LN_Previous equ 6 ; offset of structure elements
|
LN_Previous equ 6 ; offset of structure elements
|
LN_Type equ 8 ;/
|
LN_Type equ 8 ;/
|
LN_Simple equ 10 ; size of structure so far
|
LN_Simple equ 10 ; size of structure so far
|
LN_Data equ 16 ; offset of structure element
|
LN_Data equ 16 ; offset of structure element
|
ListNode equ 26 ; size of structure
|
ListNode equ 26 ; size of structure
|
|
|
|
|
title
|
title
|
|
|
The title pseudo-instruction sets the title to be used in the
|
The title pseudo-instruction sets the title to be used in the
|
header of each listing page. The string should be no longer than
|
header of each listing page. The string should be no longer than
|
80 characters.
|
80 characters.
|
|
|
Example:
|
Example:
|
title "DIS80 : A disassembler for a 8080 CPU"
|
title "DIS80 : A disassembler for a 8080 CPU"
|
|
|
|
|
ADDRESSING MODES
|
ADDRESSING MODES
|
The assembler allows all 8080 (and when enabled also Z80) addressing
|
The assembler allows all 8080 (and when enabled also Z80) addressing
|
modes. The use of an expression between braces as an address disallows
|
modes. The use of an expression between braces as an address disallows
|
braces at the outermost level for immediate values. The assembler
|
braces at the outermost level for immediate values. The assembler
|
is capable to determine that
|
is capable to determine that
|
|
|
ld a,(10)+1
|
ld a,(10)+1
|
and
|
and
|
ld a,1+(10)
|
ld a,1+(10)
|
|
|
are immediate operands. You can also use rectangular brackets
|
are immediate operands. You can also use rectangular brackets
|
[ and ] to include an address.
|
[ and ] to include an address.
|
|
|
List of available modes:
|
List of available modes:
|
immediate
|
immediate
|
(address)
|
(address)
|
(bc) (de) (hl) (sp)
|
(bc) (de) (hl) (sp)
|
|
|
Additional addressing modes for the Z80 and Z180:
|
Additional addressing modes for the Z80 and Z180:
|
(ix+offset) (ix-offset)
|
(ix+offset) (ix-offset)
|
(iy+offset) (iy-offset)
|
(iy+offset) (iy-offset)
|
(c)
|
(c)
|
|
|
|
|
LIST OF ACCEPTED INSTRUCTIONS
|
LIST OF ACCEPTED INSTRUCTIONS
|
adc add align and bit bss call ccf code cp cpd cpdr cpi cpir cpl daa
|
adc add align and bit bss call ccf code cp cpd cpdr cpi cpir cpl daa
|
data db dd dec defb defm defs defw di disable djnz ds dw ei else enable
|
data db dd dec defb defm defs defw di disable djnz ds dw ei else enable
|
end endif equ ex exx fcb fcc fcw fdb halt if im in inc include ind indr
|
end endif equ ex exx fcb fcc fcw fdb halt if im in inc include ind indr
|
ini inir jp jr ld ldd lddr ldi ldir list neg nolist noopt nop opt or
|
ini inir jp jr ld ldd lddr ldi ldir list neg nolist noopt nop opt or
|
org otdr otir out outd outi page pop push res ret reti retn rim rl rla
|
org otdr otir out outd outi page pop push res ret reti retn rim rl rla
|
rlc rlca rld rmb rr rra rrc rrca rrd rst sbc scf set shl shr sim sl sla
|
rlc rlca rld rmb rr rra rrc rrca rrd rst sbc scf set shl shr sim sl sla
|
sr sra srl stc struct sub title tsti xor
|
sr sra srl stc struct sub title tsti xor
|
|
|
Of these instructions, the following are (more or less) synonymous,
|
Of these instructions, the following are (more or less) synonymous,
|
and can be used interchangably.
|
and can be used interchangably.
|
YOU CAN USE WHERE YOU WOULD PREVIOUSLY USE
|
YOU CAN USE WHERE YOU WOULD PREVIOUSLY USE
|
nop 6 - nop nop nop ....
|
nop 6 - nop nop nop ....
|
push bc,de - push bc ; push de
|
push bc,de - push bc ; push de
|
pop bc,de - pop de ; pop bc (note reversed order)
|
pop bc,de - pop de ; pop bc (note reversed order)
|
disable - di
|
disable - di
|
enable - ei
|
enable - ei
|
sr - srl
|
sr - srl
|
shr - srl
|
shr - srl
|
sl - sla
|
sl - sla
|
shl - sla
|
shl - sla
|
stc - scf
|
stc - scf
|
ld bc,de - ld b,d ; ld c,e
|
ld bc,de - ld b,d ; ld c,e
|
ld ix,bc - ld xh,b ; ld xl,c
|
ld ix,bc - ld xh,b ; ld xl,c
|
add R - add a,R
|
add R - add a,R
|
or a,R - or R
|
or a,R - or R
|
in (c) - tsti (c)
|
in (c) - tsti (c)
|
ex hl,de - ex de,hl
|
ex hl,de - ex de,hl
|
djnz LBL - dec b ; jp nz,LBL
|
djnz LBL - dec b ; jp nz,LBL
|
jp nv,LBL - jp pe,LBL (no overflow/parity even)
|
jp nv,LBL - jp pe,LBL (no overflow/parity even)
|
jp v,LBL - jp po,LBL (overflow/parity odd)
|
jp v,LBL - jp po,LBL (overflow/parity odd)
|
jp ns,LBL - jp p,LBL (no sign/positive)
|
jp ns,LBL - jp p,LBL (no sign/positive)
|
jp s,LBL - jp m,LBL (sign/negative)
|
jp s,LBL - jp m,LBL (sign/negative)
|
|
|
Operands:
|
Operands:
|
xh - ixh
|
xh - ixh
|
xl - ixl
|
xl - ixl
|
yh - iyh
|
yh - iyh
|
yl - iyl
|
yl - iyl
|
[Address] - (Address)
|
[Address] - (Address)
|
[hl] - (hl)
|
[hl] - (hl)
|
(ix-6) - (ix+-6)
|
(ix-6) - (ix+-6)
|
|
|
And pseudo-instructions:
|
And pseudo-instructions:
|
db - defb, defm
|
db - defb, defm
|
dw - defw
|
dw - defw
|
ds - defs
|
ds - defs
|
= - set
|
= - set
|
struct - lots of EQUs
|
struct - lots of EQUs
|
|
|
|
|
LIST OF OTHER KEYWORDS
|
LIST OF OTHER KEYWORDS
|
! != $ % & && ( ) * + , - / < << <= = > >= >> [ ] ^ | || ~
|
! != $ % & && ( ) * + , - / < << <= = > >= >> [ ] ^ | || ~
|
a af af' align b bc c d db de ds dw e end h hl i ix ixh ixl iy iyh
|
a af af' align b bc c d db de ds dw e end h hl i ix ixh ixl iy iyh
|
iyl l label m nc ns nv nz p pe po r s sp struct v xh xl yh yl z
|
iyl l label m nc ns nv nz p pe po r s sp struct v xh xl yh yl z
|
|
|
|
|
FILES
|
FILES
|
.a80 - source file.
|
.a80 - source file.
|
.z80 - source file -- first alternative.
|
.z80 - source file -- first alternative.
|
.asm - source file -- second alternative.
|
.asm - source file -- second alternative.
|
.lst - List file.
|
.lst - List file.
|
.s19 - Motorola S-records output file.
|
.s19 - Motorola S-records output file.
|
.hex - Intel hex output file.
|
.hex - Intel hex output file.
|
.bin - Binary output file.
|
.bin - Binary output file.
|
|
|
|
|
BUGS
|
BUGS
|
No provision for linking other pre-assembled modules is made.
|
No provision for linking other pre-assembled modules is made.
|
Escape sequences in strings can't use the \x and
|
Escape sequences in strings can't use the \x and
|
\ formats.
|
\ formats.
|
|
|
|
|
RETURNS
|
RETURNS
|
As80 returns one of the following values:
|
As80 returns one of the following values:
|
|
|
0 - Source file assembled without errors.
|
0 - Source file assembled without errors.
|
1 - Incorrect parameter specified on the commandline.
|
1 - Incorrect parameter specified on the commandline.
|
2 - Unable to open input or output file.
|
2 - Unable to open input or output file.
|
3 - Assembly gave errors.
|
3 - Assembly gave errors.
|
4 - No memory could be allocated.
|
4 - No memory could be allocated.
|
|
|
|
|
DIAGNOSTICS
|
DIAGNOSTICS
|
Help message if only parameter is a question mark, or if an
|
Help message if only parameter is a question mark, or if an
|
illegal option has been specified.
|
illegal option has been specified.
|
|
|
|
|
AUTHOR
|
AUTHOR
|
This is copyrighted software, but may be distributed freely as long
|
This is copyrighted software, but may be distributed freely as long
|
as this document accompanies the assembler, and no copyright messages
|
as this document accompanies the assembler, and no copyright messages
|
are removed. You are explicitly NOT allowed to sell this software
|
are removed. You are explicitly NOT allowed to sell this software
|
for anything more than a reasonable copying fee, say US$5.
|
for anything more than a reasonable copying fee, say US$5.
|
To contact the author:
|
To contact the author:
|
Frank A. Vorstenbosch
|
Frank A. Vorstenbosch
|
Kingswood Software
|
Kingswood Software
|
P.O. Box 85800 Phone: +31-(70)-355 5241
|
P.O. Box 85800 Phone: +31-(70)-355 5241
|
2508CM The Hague BBS: +31-(70)-355 8674
|
2508CM The Hague BBS: +31-(70)-355 8674
|
Netherlands Email: falstaff@xs4all.nl
|
Netherlands Email: falstaff@xs4all.nl
|
|
|
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
|
|