Skip to main content

Basic structure

Each line of assembly code can contain:
  • An optional label (ending with ,)
  • An instruction, directive, macro, or expression
  • Comments (starting with /)
LABEL, ADD 0R  / This is a comment
       SUB 1R  / Instructions can be on lines without labels

Labels

Labels mark specific addresses in your program and must end with a comma:
START,    / Label marking the start
    JUN START  / Jump to the START label

LOOP,     / Another label
    INC 0R
    JCN NZ? LOOP
Labels are automatically assigned the .address type and can be used as jump targets or in expressions.

Comments

Comments begin with / and continue to the end of the line:
/ This is a full-line comment
INC 0R  / This is an end-of-line comment

Directives

Origin directive

Set the program counter to a specific address using the = directive:
= 256    / Set origin to address 256
= 0x100  / Same as above
The origin expression cannot contain labels. Only numeric values are allowed.

Equate directive

Define named constants using the name = value syntax:
EPB = 1              / End pointer bank
EPA = 0              / End pointer address
AS1 = 1              / First nibble of allocation start
KEYBOARD_PORT = 2    / Keyboard ready port
Equates can reference previously defined labels and other equates:
BUFFER_SIZE = 128
BUFFER_END = BUFFER_START + BUFFER_SIZE

Standalone data

You can embed raw data bytes using standalone numeric expressions:
DATA_SECTION,
    'e'  / Character literal
    'c'
    'h'
    'o'
    255  / Decimal number
    0xAB / Hex number (if supported)

Whitespace

Whitespace (spaces and tabs) separates tokens but is otherwise ignored. Instructions and arguments can be formatted for readability:
FIM 0P 5     / Spaced for alignment
JMS PUSH_4   / Different spacing is fine

Number formats

The assembler supports several number formats:
Default format for numbers:
LDM 10
FIM 0P 255

Conditions

Conditions are used with jump instructions and end with ?:
JCN Z? LABEL    / Jump if zero
JCN NZ? LABEL   / Jump if not zero
JCN C? LABEL    / Jump if carry
JCN NC? LABEL   / Jump if not carry
Available conditions:
  • Z? - Zero (accumulator is 0)
  • NZ? - Not zero
  • C? - Carry set
  • NC? - Carry not set

Character literals

Character literals are enclosed in single quotes:
FIM 0P 'A'    / ASCII character A
FIM 0P ' '    / Space character
Supported escape sequences:
  • \n - Newline
  • \t - Tab
  • \a - Alert/bell
  • \d - Delete
  • \\ - Backslash
  • \' - Single quote
FIM 0P '\n'   / Newline character
FIM 0P '\\\\' / Backslash character

Special symbols

Current address (*)

The * symbol represents the current program counter:
*+14 -> 8R _ _     / Current address plus 14
JCN NC? *+4        / Skip ahead 4 bytes

Placeholder (_)

The underscore is used as a placeholder in source/dest expressions:
*+14 -> 8R _ _     / Write to 8R, skip two positions
128 -> 0R 1R 2R    / Write to all three registers

Case sensitivity

Instructions, registers, and conditions are case-sensitive:
ADD 0R    / Correct
add 0r    / Incorrect
JCN NZ?   / Correct
jcn nz?   / Incorrect

Build docs developers (and LLMs) love