addressing

This section shows the syntax of the various instruction addressing modes. The following labels are used in the examples in this section:

	.SECT example, RAM
	WRD1: .DSW 1
	BYT1: .DSB 3
	NUM = 6
	

Note: WRD1 has the word attribute and BYT1 has the byte attribute; NUM is of type null. These attributes only have meaning in a debugger; the assembler treats word, byte, and null attributes the same.

direct addressing

A direct operand is specified.

	LD A,WRD1+2 ; load contents of byte at address WRD1+2
	LD A,BYT1+1 ; load contents of byte at address BYT1+1
	

immediate addressing

An immediate operand is specified with a #. Values must be in range -256 to 255; -256 is treated as 0, -1 as 255.

	LD A,#BYT1+2 ; load A immediate
	ADD A,#1 ; add immediate to A
	

register indirect addressing

A register indirect operand is specified by [reg], where reg is X or B.

	LD A,[B] ; B indirect
	LD A,[X] ; X indirect
	

register indirect addressing, auto increment/decrement

A register indirect operand with auto increment is specified by [B+]; [X+]. Auto decrement uses - instead of +.

	LD A,[X+] ; reg indirect, auto increment
	LD A,[B-] ; reg indirect, auto decrement
	

branch addressing

The operand of one of the branch type instructions (JP, JMP, JMPL, JSR or JSRL) must be a null type expression, and the operand is normally defined in a section that has the ROM attribute. Assume you have the following program fragment:

	     .SECT ONE,RAM
	DAT: .DSB  1
	     .SECT TWO,ROM
	BYT: .DB   2

	LBL: LD    A,DAT
	

Then:

	JMP LBL ; is a valid instruction
	JMP BYT ; is an error, operand type must be null
	JMP DAT ; is a error, operand is RAM type
	JMP &BYT ; valid now, byte type removed by &
	

operand size

The assembler normally generates the minimal instruction size possible for each instruction. There may be cases in which you want the instruction to be the maximum size for ease of debugging. In these cases, the > operator is provided to force the maximum size for each operand. This operator can appear only at the start of the operand.

	JP >label ; 3 bytes
	LD >B,#0  ; 3 bytes