Skip to content

Aquarius DevStudio Assembler

Frank van den Hoef edited this page Dec 15, 2023 · 3 revisions

Aquarius DevStudio - Assembler

The assembler is using 2-passes to assemble source code into machine code. All Z80 instructions are supported included almost all of the undocumented ones.

The assembler will create a directory out in the same directory as the file that is being assembled. In this directory the output and listing are placed. The name of these files are determined by replacing the .asm extension with .aqx and .lst for the output and listing respectively.

The listing is a text file that shows the addresses and bytes that were generated along with the original source code.

Line format

; Comment
    org     $1000       ; Comment
label:
    ld      a,$42
.a:

Labels should be specified at the start of the line. Characters valid to be used in labels are: . _ a-z A-Z 0-9.
Labels starting with a . are only visible up to the next non-. label and thus can be reused at multiple places in your code.

Keywords should never appear at the start of the line. Comments can be placed by starting with a ; and can appear anywhere.

Supported directives

Name Description
org expr Set the address to assemble to expr. This will also pad to the specified address with zeroes (except when the current address is 0).
phase expr Continue to produce code and data for loading at the current address but assemble instructions and define labels as if they originated at the given address. Useful when producing code that will be copied to a different location before being executed (e.g., an overlay).
dephase End phase mode assembly.
end Ends the input. Any lines following after an end are ignored.
assert expr Stop assembly if expr is non-zero.
include "file" Include a file.
incbin "file" Inserts the raw contents of the file into the assembly.
label equ expr Define a symbol label with the value expr.
defb / db value [, value ...] Output specified byte (8-bit) values. Also strings can be specified using either '' or "".
defw / dw value [, value ...] Output specified word (16-bit) values.
defs / ds size Output size zeroes.

Expressions

Full expression parsing is supported. Expressions follow the same rules as the C-language. All expressions are performed with 16-bit arithmetic.

Primary expressions

Example Description
$ Current address
1234 Decimal constant 1234
$ABCD Hexadecimal constant $ABCD
'A' Character constant 'A' (value 65)
(subexpr) Parentheses to specify sub-expression.
label Address of specified label

Operators

The table below shows the operators in descending precedence

Operator Description
- + ~ low (or <) high (or >) Unary negate, Unary plus, Unary bitwise-not, low 8 bits (& $FF), high 8 bits (>> 8)
* / % Multiplication, division, and remainder
+ - Addition and subtraction
<< >> Bitwise left shift and right shift
<= >= < > Relational operators: less-or-equal, greater-or-equal, less-than, greater-than
== = != Equal (==/=), Not equal
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
&& Logical AND
|| Logical OR
Clone this wiki locally