Академический Документы
Профессиональный Документы
Культура Документы
Spring 2002
Addition and subtraction of hexadecimal numbers. Setting the C (Carry), V (overow), N (negative) and Z (zero) bits How the C, V, N and Z bits of the CCR are changed
EE 308
Spring 2002
ADDITION: C bit set when result does not fit in word V bit set when P + P = N N + N = P
7A +52 CC C: 0 V: 1 N: 1 Z: 0
2A +52 7C C: 0 V: 0 N: 0 Z: 0
AC +8A 36 C: 1 V: 1 N: 0 Z: 0
AC +72 1E C: 1 V: 0 N: 1 Z: 0
EE 308
Spring 2002
N P = P P N = N
EE 308
Spring 2002
CODE:
EE 308
Spring 2002
B6 09 13 40 7A 09 14
PC = 0x0803
EE 308
Spring 2002
HC12 Programming Model The registers inside the HC12 CPU the programmer needs to know about
7 15
0 B 0 D
15 15 15 15
0 X 0 Y 0 SP 0 PC
CCR
S X H I N Z V C
EE 308
Spring 2002
Addressing Modes for the HC12 Almost all HC12 instructions operate on data in memory
The address of the data an instruction operates on is called the effective address of that instruction. Each instruction has information which tells the HC12 the address of the data in memory it operates on. The addressing mode of the instruction tells the HC12 how to gure out the effective address for the instruction The HC12 has 6 addressing modes
Most of the HC12s instructions access data in memory There are several ways for the HC12 to determine which address to access
Effective Address:
Memory address used by instruction
ADDRESSING MODE:
How the HC12 calculates the effective address
EE 308
Spring 2002
EE 308
Spring 2002
$0900
; ($0901:$0902) > X Effective Address: $0901 ; (B) > $0903 Effective Address:
$0903
17 35
X 02 4A C7
EE 308
Spring 2002
17 35
X 02 4A C7
10
EE 308
Spring 2002
17 35
X 02 4A C7
11
EE 308
Spring 2002
More Complicated Forms INC 2,X ; Postdecrement Indexed ; Increment the number at address (X), ; then subtract 2 from X Effective address: contents of X ; Preincrement Indexed ; Add 4 to X ; then increment the number at address (X) Effective address: contents of X + 4
EFF ADDR EFF ADDR
62 3E INC 4,+X
62 23
X Y
12
EE 308
Spring 2002
Different types of indexed addressing (Note: There are several other types we will not discuss
INDEXED ADDRESSING MODES
(Does not include indirect modes) Effective Address (X)+n (X)n (X) (X)+n (X) (X)n Value in X After Done (X) (X) (X)+n (X)+n (X)n (X)n (X) Registers To Use X, Y, SP, PC X, Y, SP, PC X, Y, SP X, Y, SP X, Y, SP X, Y, SP
Example Constant Offset Constant Offset Postincrement Preincrement Postdecrement Predecrement ACC Offset LDAA n,X
LDAA n,X LDAA n,X+ LDAA n,+X LDAA n,X LDAA n,X
0 to FF 0 to FF 0 to FFFF
X, Y, SP, PC
LBEQ
18 27 02 1A
When writing assembly language program, assembler figurs out offset $0820
0x0820
BRA
$0830
20 0E
PC
13
EE 308
Spring 2002
IDX
LDAA 3,+X
A6 22
14