XASM source [options]source is the name of source file. If no extension is given, the .ASX is implied.
Default action on invoking without options is to compile writing to a file with the .OBX extension.
There are following types of fields:
In the latter form, you must use a minimum of an instruction field.
It depends on the instruction, how many operands it takes.
Every instruction takes constant number of operands, therefore
there's no need to use a special character at the start of a comment, because after
succesfully taking operands, X-Asm discards the remaining part of line.
Single instruction always consists of 3 letters. It can be:
Assembling options
Following options are supported:
If source is incorrect, X-Asm stops on first encountered error.
By default lines skipped due to false condition are not listed.Exit codes
Meaning of exit codes returned by X-Asm:
3 = bad parameters, assembling not started
2 = error occured
1 = warning(s) only
0 = no errors, no warnings
Listing structure
Line of listing includes:
Listed are also generated headers. A xxxx-yyyy> in place of origin
represents generated header: $xxxx is the first and $yyyy
is the last byte of the block.
A FFFF> represents two $ff bytes written as a header prefix.
A plus sign placed after hex numbers stands for more bytes written to object
in this line, not listed through lack of space.
Label table structure
Line of label table includes:
n - label defined but not used elsewhere
2 - label value known in pass 2 only (label definition uses forward
reference and thus you can't make forward references to that label)
SYNTAX
Fields
Source code is line-oriented. Every line of source consists of fields.
Same sequence of characters used in different fields has completely different meaning.
Fields are separated with one or more blank characters.
There can't be any space within a field excluding strings and comments.
In the first form, both fields are optional. Blank lines are ignored of course.
Comment must here start with one of these characters: ; | or *
(semicolon, pipe or asterisk). Any information in the line following
such character is ignored.Label field
This field is optional. It must start at first character in line, without
any blank characters before. The purpose of using label field is to define a label.
Label is a symbol representing an integer of range -$ffff..$ffff.
Name of a label can contain letters, digits and underscores (_).
Digit can not be label's first character.
Name of a label can be as long as you want and all the characters
are meaningful. In Quick Assembler only 6 leading characters were recognized
and some sources may not compile under X-Asm for this reason.
Defining a label without using EQU makes it equal to current value
of the origin counter.
Label can't be redefined.Repeat count
Repeating means assembling single line several times as if
there were several identical lines. Note it is not just duplicating
bytes written to object.
Repeat count, which can be any valid expression, has to be preceded
with a colon.
Examples:
:4 asl @
:2 dta a(*)
In the latter example each DTA has different operand value.
If repeat count equals zero, remaining part of line is not assembled.
This allows conditional assembly on single line to be more compact.
Instruction field
If this is the first field in a line, the line must start with at least
one blank character. Instruction field consists of one or two instructions.
The latter case is called instructions pairing, because a pair
of instructions have shared operand. You separate instructions
with a colon.
Example:
adc:sta $80
is equivalent to
adc $80
sta $80
Note that
lda:tax $80
is correct, because $80 is a comment for TAX.
Operand field
Some instructions don't need any operand,
other need two operands.
6502 commands require operand with proper
addressing mode.Comment
Comment in a statement does not start from any special character
like ; for example. Comment field is implied when appropriate
number of operands was taken.Expressions
Expressions are numbers combined with operators and brackets.
You should use square brackets, because parentheses are reserved
for 6502 indirect addressing.
Numbers
Numbers are 32-bit signed integers, in the range of -$7fffffff..$7fffffff.
A number can be:
| -12345 |
| $abcd |
| %10100101 |
| 'a' or "a" |
| * |
| ^31 |
| {lda #0} |
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Remainder |
& | Bitwise and |
| | Bitwise or |
^ | Bitwise xor |
<< | Arithmetic shift left |
>> | Arithmetic shift right |
= | Equal |
<> | Not equal |
!= | Not equal (same as <>) |
< | Less than |
> | Greater than |
<= | Less or equal |
>= | Greater or equal |
&& | Logical and |
|| | Logical or |
+ | Plus (does nothing) |
- | Minus (changes sign) |
~ | Bitwise not (complements all bits) |
! | Logical not (changes true to false and vice versa) |
< | Low (extracts low byte) |
> | High (extracts high byte) |
Operator precedence:
first | [] | (brackets) |
+ - ~ < > | (unary) | |
* / % & << >> | (binary) | |
+ - | ^ | (binary) | |
= <> != < > <= >= | (binary) | |
! | (unary) | |
&& | (binary) | |
last | || | (binary) |
Operators are similar to used in C language, but their priorities are different than in C.
Compare and logical operators assume that zero is false and non-zero is true. They return 1 for true.
While calculating expression, signed 32-bit arithmetic is used. When range of 32 bits is exceeded, 'Arithmetic overflow' error is generated.
There are two extra immediate addressing modes:
< and >,
which use low/high byte of word rather than byte value.
They are for Quick Assembler compatibility.
You can use traditional #< and #>.
Note
In absolute addressing modes, X-Asm examines expression and uses zero-page
addressing mode if it supposes it is possible. You may override it with
a: and z: prefixes.
Examples:
A: < and > are not only 'low' and 'high'
operators, but also 'low of immediate' and 'high of immediate'
addressing modes indicators.
In order to get lda $ab, write lda +>$abcd
A: You should use @ for accumulator addressing mode.
A: You should have explicit run address specified.
Use run start directive. end takes no operand.
Example:
A: X-Asm displays only first error.
Directives
Examples:
five equ 5
here equ *
Default (if no OPT specified) is opt l+h+.
Examples:
opt l- listing off
opt h- headers off
opt l+h- listing on, headers off
Examples:
org $600
org f:$700
table org *+100
In the latter example table points to 100 bytes
of uninitialized data (label is assigned to *
before ORG directive is executed).
Pseudo-commands
Pseudo-commands are built-in macros.
They are not illegal instructions and work on typical 6502.
X-Asm can do it for you. ADD replaces two instructions:
CLC and ADC.
Addressing modes
All addressing modes are entered in standard convention except
the accumulator addressing mode, which should be marked with a
@ character (as in Quick Assembler).
nop
asl @
lda >$1234 assembles to lda #$12
lda $100,x
lda a:0 generates 16-bit address
jmp ($0a)
lda ($80),y
There are also pseudo addressing modes, which are similar to
pseudo-commands. You may use them just like standard addressing modes
in all 6502 commands and pseudo-commands excluding
MWA, MWX and MWY only:
cmd a,x+ = cmd a,x : inx
cmd a,x- = cmd a,x : dex
cmd a,y+ = cmd a,y : iny
cmd a,y- = cmd a,y : dey
cmd (z),y+ = cmd (z),y : iny
cmd (z),y- = cmd (z),y : dey
cmd (z,0) = ldx #0 : cmd (z,x)
cmd (z),0 = ldy #0 : cmd (z),y
cmd (z),0+ = ldy #0 : cmd (z),y : iny
cmd (z),0- = ldy #0 : cmd (z),y : dey
FAQ
label equ 1 +2
A: X-Asm treats space as operand terminator. Remaining part of line
is a comment. You should write 1+2 without any spaces.label: lda #0
A: Label definition can not include a colon.three equ one+two
two equ one+one
one equ 1
while this does:
two equ one+one
one equ 1
A: X-Asm reads source twice (in pass 1 and pass 2)
from the beginning until the end.
This allows forward references, but not too complex.
Keep in mind that assembler should know all the values in second pass.two equ one+one This value is known in 2nd pass only
one equ 1 This value is known as early as in 1st pass
These values can be fixed in two passes.
If you insert following statement as first line:
three equ one+two
X-Asm will generate an error because it can't fix
the value of three in second pass.
When you were assembling for the first time, both errors might exist,
but X-Asm stopped on the first one.