Directives
directivesThe xyw assembler supports a few directives, special instructions that can be used to change the behavior of the assembler and also facilitate some programming tasks by introducing constructs like macros and labels.
Directives are identifiers that must start with a dot and can only contain letters, numbers, dashes or underscores, and are typically followed by one or more space-separated arguments.
Note that a directive and all its arguments must fit on a single line. Multiline directives are not supported.
The following sections provide a description of all the directives supported by the xyw assembler.
=== .byte
The byte directive can be used to store arbitrary bytes in memory at the current address. It can take any number of arguments, each corresponding to a byte or a word to be stored:
.byte $55 $28 $F4 $2A $FF
=== .label
The label directive defines a label, which is an alias to a memory address corresponding to the exact location where the label is defined:
.label print.loop
In this case, the .label directive defines a label called print.loop, which can be used throughout the program to access the corresponding memory address.
Labels are essential for organizing code in subroutines and for implementing jumps without having to use raw memory addresses.
Note that all labels are globals, so typically you can use your own conventions to define "sub labels", such as using dots, but as a matter of fact all labels can be accessed from anywhere in the program.
Also, labels are processed in the same symbol table as macros (see the dedicated section further on), so they cannot have the same name as an existing macro, or reuse an instruction mnemonic.
Labels must start with a letter or underscore, and they can contain letters, numbers, underscores, dashes, or dots.
=== .macro
The .macro directive can be used to define a macro, which is basically a textual substitution:
.macro square DUP MUL
.macro fourth square DUP MUL
.macro system.page $FF
The first argument of a macro is its name, which can start with a letter or underscore, and can contain letters, numbers, underscores, dashes, or dots, followed by one or more arbitrary space-separated arguments.
Macros are processed in the same symbol table as labels (see the dedicated section further on), so they cannot have the same name as an existing label, or reuse an instruction mnemonic.
When the xyw assembler encounters a symbol corresponding to a macro, it will simply substitute it with its contents. If the contents contain another macro, it will continue to replace it with its contents indefinitely. Note that infinite recursions will be detected and result in an error.
=== .include
The .include directive can be used to include the contents of another file in the current file. It takes a quoted string as single argument corresponding to the path to the file to include:
.include "file.xyw"
=== .string
The .string directive can be used to allocate null-terminated strings in memory. When the xyw assembler encounters it, it will look for a quoted string as first argument, and it will convert it to a sequence of 8bit ISO 8859-1 characters and add the null terminator byte automatically.
.string "Hello, World!"