Directives are commands that control the assembler and include controls for conditional assembly, exporting multible binary files, creating linkable object files etc.
The directives are case insensitive and can be preceeded by a dot
Export this section or disable export Note that with the -xdefimp command line option this means XDEF instead and the EXPORT directive is not available.
Enable code that will be assigned a start address during a link step, or alternatively its own load address. BSS and ZP sections will not be included in the binary output, and sections can be separately exported using the EXPORT directive.
Add to address to make it evenly divisible by this. This only works at the start of a SECTION or in the middle of a section that is assembled to a fixed address.
Create a macro. When used with the command line option -endm the macro ends with a ENDMACRO or ENDM directive, and if not using -endm the macro is defined within braces ( { and } ).
A user function is a pre-defined one-line expression that can be used in a similar way as a macro, but instead of generating binary data it returns a single integer value.
; user defined function
FUNCTION alignto(address, alignment) (address + alignment-1) & (~alignment)
Note that functions must evaluate at the time of reference, if any symbol is not evaluated it will fail. This differs from in-place expressions that can have references that will be evaluated at a later time in assembly or at link time.
Declare constant / Declare Value. The directive can be specific by appending .b for byte size, .w for word size, .t for triple size or .l for long size. The default size is 1 byte.
Declare a string symbol. Strings are a little bit limited but can be used for ordering characters in a TEXT declaration, or it can be used as assembler source.
; Some custom ordered text
TEXT [FontOrder] "MAKE IT SO!"
; Macro for (x=start; x<end;x++)
macro for.x Start, End {
ldx #Start
if Start <End
string _ForEnd = "inx\ncpx #End\nbne _ForLoop"
elif Start > End
{
if (-1 == End) & (Start<129)
string _ForEnd = "dex\nbpl _ForLoop"
else
string _ForEnd = "dex\ncpx #End\nbne _ForLoop"
endif
}
else
string _ForEnd = ""
endif
_ForLoop
}
macro forend {
_ForEnd ; _ForEnd defined by a variation of the for macro
Create a pool of addresses to assign as labels dynamically. This acts as a linear stack allocator for temporary storage and is deallocated when the scope ends if declared as a local symbol.
Pools can be defined as part of a larger pool.
pool zpGlobal $40-$f8 ; all zero page usage
zpGlobal pool zpLocal 16 ; temporary storage for regular functions
zpGlobal pool zpUtility 16 ; temporary storage for utility functions
zpGlobal pool zpInterrupt 8 ; temporary storage for interrupts
zpGlobal pool zpBuffer 64 ; per module storage
Allocate from a pool by using the pool name
zpBuffer zpIntroTimer.w ; frame counter, 2 bytes
zpBuffer zpScrollChar.8 ; 8 bytes of rol char for scroll
{
zpLocal .zpSrc.w ; 2 bytes source address
zpLocal .zpDst.w ; 2 bytes dest address
..
} ; at this point .zpSrc and .zpDst are deallocated and can be reused by other code.
{
zpLocal .zpCount ; 1 byte, same address as .zpSrc used above
Begin conditional code. Whatever lines follow will be assembled only if the expression following the IF evaluates to a non-zero value, the conditional block ends with ELSE, ELSEIF or ENDIF.
conditional_code = 1
IF conditional_code
... ; this will be assembled because conditional_code is not zero
Similar to IF but only takes one symbol and the following lines will be assembled only if the symbol was defined previously (IFDEF) or not defined previously (IFNDEF)
defined_symbol = 0
IFDEF defined_symbol
... ; this will be assembled because defined_symbol exists
Similar to IF but like IFDEF only takes one symbol and the following lines will be assembled if the symbol is CONST. The symbol should be defined prior to testing it.
CONST() is also an Eval Function that can be used to form more complex expressions using IF. IFCONST is equivalent to IF CONST(<symbol>)
Repeats the code within { and } following the REPT directive and counter. Within the REPT code the symbol REPT has the current iteration count, starting at 0.
const words = 10
.rept words * 2 { dc.b rept / 2 }
If the command line option -endm is used then REPT uses ENDR instead of the braced scope so the equivalent to the above would be
Specific to 65816 assembly, controls the current accumulator and index register width (8 or 16 bits). Different assemblers use different names so various alternatives are allowed.
Define "section", Reserve. Reserves a number of bytes at the current address. The first argument is the number of bytes and the second argument is optional and is the byte to fill with. The main purpose is to reserve space in a BSS or ZP section.
A specialized version of a scope, does the same this as a brace scope (code between { and }) but additionally marks all labels defined within as local. An unimplemented feature is that the scope can be named and then labels defined can be accessed outside the scope as