User guide

Immediate addressing
<instruction> #<value>
The value is directly provided. Note the ‘#’ character before the value; if it was not there then it
would be taken as an address – the ‘#’ is important!
Examples:
LDA #123
Relative addressing
<branch instruction> <offset|label>
Relative addressing is used only with branch instructions. The second byte of the instruction
establishes a branch point which may be -128 to +127 bytes away from the following instruction
(i.e. -128 to +127 bytes away from PC).
This is why you cannot BEQ across large expanses of code.
Examples:
BEQ <label>
BNE <label>
The assembler sorts out the offset, you don’t have to.
Absolute addressing
Zero page addressing
<instruction> <address>
The parameter to the instruction is a byte held at a fixed address.
If the address is less than &100, zero page addressing is used otherwise absolute addressing is
used.
Zero page addressed instructions can operate a lot faster, so careful use of page zero can be a
definite speed bonus.
Examples:
CMP &FE02 ;
compare A with byte at &FE02
LDA &C5 ;
load A from &C5 ==ZERO PAGE==
It is very important to note that all references to a label fall into this category of addressing. If the
label has been resolved before it is encountered in the code, then 6502asm will pick Absolute or
Zero page addressing as is deemed appropriate.
However, if the label has not been seen before it is used (i.e. you are assembling a forward
branch) then 6502asm will always treat this as an full absolute (not zero-page) address.
In 99.9% of cases, this behaviour is correct, however if the label is later defined as being Zero
Page, then 6502asm will then assemble the code as if it was Zero Page and everything else will be
wrong, your software will crash, etc. This is only of concern if you are assembling code to be
located or used within Page Zero itself. Simply pre-define all of the labels first, and then go back
and assemble code. Don’t use forward references.
6502asm user guide – prerelease version
page 12