Professional Documents
Culture Documents
04 Addressing Modes 2
04 Addressing Modes 2
Lecture 4:
Addressing Modes
Todays Goals
Two major goals
Understand addressing modes so figure out how to use them.
If you dont get addressing modes, you will have a serious
problem to complete this course.
1/15/2010
Addressing Modes
How to get effective addresses
Extended (EXT)
Direct (DIR)
Inherent (INH)
Immediate (IMM)
Index (IDX)
Relative (REL) : Used only with branch instructions.
instructions
Effective Address
The effective address is the location that holds the data to be used
by the operation.
The operand is often used to construct the effective address.
An addressing mode tells the microprocessor the way of calculation
to get the effective address.
B6
2001
30
2002
00
.
.
3000
98
.
.
No operation needed.
Extended
d d addressing
dd
tells
ll the
h ffull
ll memory address.
dd
Format:
Example:
p
1/15/2010
.
.
0080
98
.
.
2000
B6
2001
30
.
.
Format:
Example:
p
Format:
No operand.
.
.
2000
42
.
.
Example:
INH
42
1/15/2010
86
2001
80
CC
03
2002
E8
.
.
Example:
.
.
2000
Format:
.
.
2001
Effective address:
LDD
#1000
Effective Address
Format
Example:
LDAA
0,X
LDD
-100,Y
LDX
1000, Y
Notes:
1/15/2010
rr
00
01
SP
10
PC
11
Postbyte for5bitOffset:
rr0nnnnn
Postbytes for9bitOffset: 111rr00nnnnnnnnn
Postbytes for16bitOffset: 111rr010nnnnnnnn nnnnnnnn
Index Addressing
Examples
Instruction
Machine Code
LDAA4,Y
A6
LDD100,X
EC
LDX1000,Y
EE
44
01 000100
00100
E1
1
11100
00 001
EA
11101
01 010
9C
10011100
FC
11111100
Postbyte for5bitOffset:
rr0nnnnn
Postbytes for9bitOffset: 111rr00nnnnnnnnn
Postbytes for16bitOffset: 111rr010nnnnnnnn nnnnnnnn
18
00011000
Register
rr
00
01
SP
10
PC
11
1/15/2010
Instruction Set
SourceForm
Operation
LDAA#opr8i
LDAAopr8a
LDAAopr16a
LDAAoprx0_xysp
LDAAoprx9,xysp
LDAAoprx16,xysp
(M) A
LoadAcc.A
Addr.
Mode
IMM
DIR
EXT
IDX
IDX1
IDX2
MachineCoding
86ii
96dd
B6hhii
A6xb
A6xbff
A6xbeeff
AccessDetail
P
rPf
rPO
rPf
rPO
frPP
SXHI
NZVC
10
Op Code
IMM
Op Code
Data
DIR
Op Code
Addr-low
Effective Address
00
Addr-low
EXT
Op Code
Addr-high
Addr-low
Effective Address
Addr-high
Addr-low
IDX
Op Code
Offset
REL
Op Code
Op Code
Data-high
Data-low
Effective Address
Index Register
Effective Address
Relative offset
Program Counter
1/15/2010
Program Trace
2000
B6
2001
30
2002
00
2003
C6
2004
02
2005
18
2006
06
2007
7A
2008
30
2009
01
200A
3F
3000
19
3001
FF
LDAA3000h
LDAB#2
ABA
STAA3001h
Stop
Program Trace
Example
Trace
Line
1
Address
PC
LDAA 3000h
LDAA3000h
2003
19
2
3
2003
LDAB#2
2005
19
02
2005
ABA
2007
1B
02
2007
STAA3001h
200A
1B
02
200A
stop
2000
Instruction
1/15/2010
Program Trace
Another Example
2000
CE
2001
30
2002
01
2003
EC
2004
01
LDX#3001H
Trace Address
Instruction
Line
1
2000 LDX
LDX#3001h
#3001h
LDD1,X
2005
87
CLRA
2006
6C
STD1,X
2007
1F
2008
3F
3000
EC
3001
27
3002
45
3003
99
Stop
PC
2003 3001
LDD1,X
2005 3001
45
99
2003
2005
INCB
2006 3001
45
9A
2007
STD1,X
2009 3001
00
9A
2009
STOP
Questions?
1/15/2010
Wrap-up
What weve learned
Five addressing modes
Program trace
What to Come
Unconditional branches
Relative
Relati e addressing mode