Compiler Syntax

This page includes syntax information specific to the compiler that Minicube64 uses.

Comments

Comments begin with a semicolon (;). A colon (:) following a label is optional

    lda #$00             ;hi there
label1: jmp label2
label2  beq label1

Numbers and expressions

Hexadecimal numbers begin with '$' or end with 'h'. Binary numbers begin with '%' or end with 'b'. Characters and strings are surrounded by single or double quotes. The characters (' " \) within quotes must be preceded by a backslash (\).

12345
'12345'
$ABCD
0ABCDh
%01010101
01010101b

Supported operators (listed by precedence):

          ( )
 (unary)  + - ~ ! < >
          * / %
          + -
          << >>
          < > <= >=
          = == != <> 
          &
          ^
          |
          &&
          ||

'=' and '<>' are equivalent to C's '==' and '!=' operators. The unary '<' and '>' operators give the lower and upper byte of a 16-bit word (respectively).

All other operators function like their C equivalents.

Labels

Labels are case sensitive.

The special '$' label holds the current program address. Labels beginning with '@' are local labels. They have limited scope, visible only between non-local labels. Names of local labels may be reused.

Labels beginning with one or more '+' or '-' characters are nameless labels, especially useful for forward and reverse branches.

Assembler directives

(in no specific order)

All directives are case insensitive and can also be preceded by a period (.)

EQU

For literal string replacement, similar to #define in C.

= Unlike EQU, statements with '=' are evaluated to a number first. Also unlike EQU, symbols created with '=' can be reused.

INCLUDE (also INCSRC)

Assemble another source file as if it were part of the current source.

INCBIN (also BIN)

Add the contents of a file to the assembly output.

An optional file offset and size can be specified.

DB, DW (also BYTE/WORD, DCB/DCW, DC.B/DC.W)

Emit byte(s) or word(s). Multiple arguments are separated by commas. Strings can be "shifted" by adding a value to them.

DL, DH

Similar to DB, outputting only the LSB or MSB of a value.

HEX

Compact way of laying out a table of hex values. Only raw hex values are allowed, no expressions. Spaces can be used to separate numbers.

DSB, DSW (also DS.B/DS.W)

Define storage (bytes or words). The size argument may be followed by a fill value (default filler is 0).

PAD

Fill memory from the current address to a specified address. A fill value may also be specified.

ORG

Set the starting address if it hasn't been assigned yet, otherwise ORG functions like PAD.

ALIGN

Fill memory from the current address to an N byte boundary. A fill value may also be specified.

FILLVALUE

Change the default filler for PAD, ALIGN, etc.

BASE

Set the program address. This is useful for relocatable code, multiple code banks, etc. The same can also be accomplished by assigning the '$' symbol directly (i.e. '$=9999').

IF / ELSEIF / ELSE / ENDIF

Process a block of code if an expression is true (nonzero).

IFDEF / IFNDEF

Process a block of code if a symbol has been defined / not defined.

MACRO / ENDM

MACRO name args...

Define a macro. Macro arguments are comma separated. Labels defined inside macros are local (visible only to that macro)

REPT / ENDR Repeat a block of code a specified number of times. Labels defined inside REPT are local.

ENUM / ENDE

Reassign PC and suppress assembly output. Useful for defining variables in RAM.

ERROR

Stop assembly and display a message.

The information on this page is provided from the asm6f documentation by loopy.

https://github.com/freem/asm6f/blob/master/readme-original.txt

Last updated

Was this helpful?