Each line of the assembly program should follow one of the following templates, where the brackets
delimit optional parts.
[;comment]label=expression[;comment][label]mnemonicoperand[;comment]
Comments are introduced by a semicolon (;) and extend to the end of the line. Labels are identifiers
containing up to 36 alphanumeric characters (including period and underscore). Labels cannot start with a
digit. The format of the mnemonics and operands field depends on the selected micro-processor. A few
mnemonics are valid for all processors and are used to give directives to the assembled. These are known
as "pseudo-mnemonics".
Labels
Labels are identifiers representing
— an absolute address,
— a relative address (position independent code),
— a register,
— a list of registers,
— a specific bit at a specific address,
— or a mnemonic.
Most labels are composed of at most 36 alphanumeric characters, periods (.) or underscores (_). Labels
cannot start with a digit. They are case insensitive.
Labels starting with a period (.) are local labels whose scope is either limited to the macro in which
they are defined, or to the code segment delimited by the pseudo-mnemonics CODE or DUMMY.
The predefined "star" label (*) represents the current program counter, that is to say, the address where
the next assembly code instruction will be encoded. Other predefined labels include all pseudo-
mnemonics, micro-processor specific mnemonics and register names.
Constants
The assembled recognizes numerical constants expressed in decimal, hexadecimal, octal, binary, or ascii.
┌───────────────────────────────────────────────────────────┐
│ TypeFormatExamples │
├───────────────────────────────────────────────────────────┤
│ decimal dddd1234, 675, 12, 1, but not 0.12. │
├───────────────────────────────────────────────────────────┤
│ hexadecimal $dddd$fd12, $2AC, $0. │
│ ddddH03H, 2da7H, 0FC84H, but not FC84H. │
│ 0Xdddd0x03, 0x2AC, 0Xfc84. │
├───────────────────────────────────────────────────────────┤
│ octal ddddQ377Q, 012412Q. │
├───────────────────────────────────────────────────────────┤
│ binary %dddd%01110110, %1100. │
│ ddddB01110110B, 1100B. │
│ 0Bdddd0b1100 │
├───────────────────────────────────────────────────────────┤
│ ascii 'cccc''a', 'AB', '"', '\n', '\''. │
│ "cccc""\t", "\"", "a'b". │
└───────────────────────────────────────────────────────────┘
Expressions
Like labels, expressions can represent an absolute address (abs), a relative address for position
independent code (rel), a register (reg), or a list of registers (reglist), or a reference to a specific
bit at a specific address (bspec).
The following operators are recognized on expressions.
┌────────────────────────────────────────────────────────────┐
│ SyntaxResultDescription │
├────────────────────────────────────────────────────────────┤
│ abs{abs}bspec bit reference, e.g. pia{3} │
│ ADDR(abs)abs address from a bit reference │
│ BIT(abs)abs bit number from a bit reference │
├────────────────────────────────────────────────────────────┤
│ -absabs two's complement │
│ ~absabs one's complement │
├────────────────────────────────────────────────────────────┤
│ abs<<absabs left shift │
│ abs>>absabs right shift │
├────────────────────────────────────────────────────────────┤
│ abs|absabs bitwise or │
│ abs&absabs bitwise and │
│ abs^absabs bitwise xor │
├────────────────────────────────────────────────────────────┤
│ abs*absabs multiplication │
│ abs*absabs division │
├────────────────────────────────────────────────────────────┤
│ abs+absabs addition │
│ rel+absrel addition │
│ abs-absabs subtraction │
│ rel-absrel subtraction │
│ rel-relabs subtraction │
├────────────────────────────────────────────────────────────┤
│ reg-regreglist register range │
│ reglist\regreglist register list │
└────────────────────────────────────────────────────────────┘
The table lists operators in order of decreasing precedence. Parenthesis can be used to avoid
ambiguities. A warning is generated when an entire expression is surrounded with parenthesis and can be
confused with a micro-processor addressing mode.
Examples:
(base+$12)>>8&0xff00'A'-80H(base+0x12)
The last example causes a warning because the parenthesis were not necessary and might suggest a micro-
processor addressing mode.
All arithmetic expressions are evaluated on 32 bits. Arithmetic operations overflow silently. The
arithmetic values are then truncated to the size implied by the micro-processor mnemonic. This
truncation might cause a warning message.
Examples: all the following instructions
(6502) lda#$1234
(6800) ldaa$1234,x
(Z80) ld(ix+0C2H),b
cause a warning
>>>WARNING:Operandoverflow
However expression
$1123454*1298992
overflows silently.
Pseudo-mnemonics
The following pseudo-mnemonics are always recognized.
CPUcpuname
Indicates the selected micro-processor type. This must appear before anu micro-processor specific
instruction. The possible values of cpuname are listed when you invoke crasm without arguments.
The current list includes 6800,6801,6803,6502,65C02, and Z80OUTPUTbinformat
Indicates the format of the output file. Argument binformat can take values SCODE for producing
an output file using Motorola's S code, or HEX for Intel's Hex format. The default depends on the
selected micro-processor.
CODE
Delimit the scope of local labels and introduce a program section.
DUMMY Delimit the scope of local labels and introduce a fake program section whose sole effect is to
define labels without generating code.
labelEQUexpressionlabel=expression
Define the value of label label. Labels defined using these directives can be redefined later in
the program.
[label]DBexpression[,...,expression]
Insert the specified data bytes (8 bits).
[label]DWexpression[,...,expression]
Insert the specified data words (16 bits). The byte ordering depends on the selected micro-
processor.
[label]DLexpression[,...,expression]
Insert the specified data longs (32 bits). The byte ordering depends on the selected micro-
processor.
[label]DDBexpression[,...,expression]
Insert the specified double bytes (16 bits). The byte ordering is the opposite of the usual byte
ordering for the selected micro-processor.
[label]ASCstringconstant
Insert the ascii representation of the string stringconstant. The string must be delimited by
double quotes. The C escape sequences \r, \n, \t, \0, \', \", and \\ are recognized.
[label]DScountexpr,[valexpr]
Insere countexpr bytes with value valexpr. The default value is zero.
[label]ALIGNEVEN[label]ALIGNODD
Insert a null byte in order to make the program counter even or odd.
IFcondexpr
...
ELSE
...
ENDC
Conditional assembly: If expression condexpr is non zero, process the lines located between the IF
and the ELSE pseudo-mnemonics. Otherwise process the lines located between the ELSE and the ENDC
pseudo-mnemonics. Conditional assembly instructions can be nested. The ELSE part can be omitted.
labelMACRO
...
ENDM
Define a new mnemonic label equivalent to all the instructions located between the MACRO and ENDM
pseudo-mnemonics. Invocations of the macro can specify a list of comma separated operands. The
character sequences \1, \2, ... \N in the macro definition are replaced by the supplied operands.
The character sequence \0 is replaced by the number of supplied operands.
EXITM
This pseudo mnemonic can be used inside a macro definition to exit the macro. This is useful in
conjunction with the conditional assembly pseudo-mnemonics.
INCLUDEfilename
Force the assembler to process file named filename at the current point.
LISTONLISTOFF
Enable or disable the production of a listing (default is on.)
CLISTONCLISTOFF
Enable or disable the production of a listing for the non active branches of a conditional
assembly construct (default is on.)
ILISTONILISTOFF
Enable or disable the production of a listing for included files (default is off.)
MLISTONMLISTOFF
Enable or disable the production of a listing for the macro expansions (default is off.)
NAM title
Provide name title for the header of the listing pages.
PAGE
Start a new listing page.
PAGE columns,rows
Specify the size of a listing page.
SKIP number
Skip number lines.
FAIL message
Generate an error message message.