beautypg.com

4 extended, 5 relative, Extended – Motorola HC12 User Manual

Page 132: Relative, Assembler syntax

background image

User’s Manual

MCUez HC12 Assembler

132

Assembler Syntax

MOTOROLA

Assembler Syntax

7.4.3.4 Extended

The extended addressing mode is used to access memory located above the
direct page in a 64-Kbyte memory map.

Example:

XDEF Entry

ORG $100

data: DS.B 1

MyCode: SECTION

Entry:

LDS #$AFE

; init Stack Pointer

LDAA #$01

main: STAA data

BRA main

In this example, the value in register A is stored in the variable

data

. This

variable is located at address $0100 in the memory map.

7.4.3.5 Relative

This addressing mode is used to determine the destination address of branch
instructions. Each conditional branch instruction tests some bits in the condition
code register. If the bits are in the expected state, the specified offset is added
to the address of the instruction following the branch instruction, and execution
continues at that address.

Short branch instructions (BRA, BEQ, etc.) expect a signed offset encoded on
one byte. The valid range for a short branch offset is [–128...127].

Example:

main:

NOP

NOP

BRA main

In this example, after the two

NOP

s have been executed, the application

branches on the first

NOP

and continues execution.