User’s Manual MCUez HC12 Assembler
130 Assembler Syntax MOTOROLA
Assembler Syntax
7.4.3.1 Inherent
Instructions using this addressing mode either have no operands or all operands
are stored in internal CPU registers. The CPU does not need to perform memory
access to complete the instruction.
Example:
NOP ; Instruction with no operand
CLRA ; Operand is in CPU register A
7.4.3.2 Immediate
The opcode contains the value to use with the instruction rather than the address
of this value. The # (pound sign) character is used to indicate an immediate
addressing mode operand.
Example:
main: LDAA #$64
LDX #$AFE
BRA main
In this example, the hexadecimal value $64 is loaded in register A.
The size of the immediate operand is implied by the instruction context.
Register A is an 8-bit register, so the instruction LDAA expects an 8-bit
immediate operand. Register X is a 16-bit register, so the instruction LDX
expects a 16-bit immediate operand.
The immediate addressing mode can also be used to refer to the address of a
symbol.
Example:
ORG $80
var1: DC.B $45, $67
ORG $800
main:
LDX #var1
BRA main
In this example, the address of variable var1 ($80) is loaded in register X.