This page includes syntax information specific to the compiler that Minicube64 uses.
Comments begin with a semicolon (;). A colon (:) following a label is optional
lda #$00 ;hi there
label1: jmp label2
label2 beq label1
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 (\).
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 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.
-- ldx #0
- lda $2002 ;loop (wait for vblank)
- lda $2002 ;nameless labels are easy to reuse..
beq + ;forward branch..
beq +here ;use more characters to make more unique
jmp -- ;multiple --'s handy for nested loops
+ ldx #0
(in no specific order)
All directives are case insensitive and can also be preceded by a period (.)
For literal string replacement, similar to #define in C.
one EQU 1
plus EQU +
DB one plus one ;DB 1 + 1
=Unlike EQU, statements with '=' are evaluated to a number first. Also unlike EQU, symbols created with '=' can be reused.
j EQU i+1
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.
moredata: INCBIN whatever.bin
An optional file offset and size can be specified.
INCBIN foo.bin, $400 ;read foo.bin from $400 to EOF
INCBIN foo.bin, $200, $2000 ;read $2000 bytes, starting from $200
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.
DB "ABCDE"+1 ;equivalent to DB "BCDEF"
DB "ABCDE"-"A"+32 ;equivalent to DB 32,33,34,35,36
Similar to DB, outputting only the LSB or MSB of a value.
DL a,b,c,d ;equivalent to DB <a, <b, <c, <d
DH a,b,c,d ;equivalent to DB >a, >b, >c, >d
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.
HEX 456789ABCDEF ;equivalent to DB $45,$67,$89,$AB,$CD,$EF
HEX 0 1 23 4567 ;equivalent to DB $00,$01,$23,$45,$67
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).
DSB 4 ;equivalent to DB 0,0,0,0
DSB 8,1 ;equivalent to DB 1,1,1,1,1,1,1,1
DSW 4,$ABCD ;equivalent to DW $ABCD,$ABCD,$ABCD,$ABCD
Fill memory from the current address to a specified address. A fill value may also be specified.
PAD $FFFA ;equivalent to DSB $FFFA-$
PAD $FFFA,$EA ;equivalent to DSB $FFFA-$,$EA
Set the starting address if it hasn't been assigned yet, otherwise ORG functions like PAD.
ORG $E000 ;start assembling at $E000
ORG $FFFA,$80 ;equivalent to PAD $FFFA,$80
Fill memory from the current address to an N byte boundary. A fill value may also be specified.
Change the default filler for PAD, ALIGN, etc.
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)
MACRO setAXY x,y,z
;expands to LDA #$12
; LDX #$34
; LDY #$56
REPT / ENDRRepeat 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.
foo: db 0
foo2: db 0
Stop assembly and display a message.
ERROR "X is out of range :("
The information on this page is provided from the asm6f documentation by loopy.