Sie sind auf Seite 1von 15

ed

Modes
Addressing Modes- The term addressing modesrefers to the way in which the
operand ofan instruction is specified. The addressing mode specifies a rule for
interpreting or modifying the addressfield of the instruction before the operand is
actually executed.
Addressing modesindicate how instructions access data operands.

Addressing modestell the CPU howto obtain the data neededto execute an
instruction
Q The data may be
Q Explicitly supplied with the instruction
Q Stored in a CPUregister
Q Stored at a memory location
Q) Stored in an I/O deviceregister
Q Implicit Addressing Mode * Operand is implicit to the instruction

University of Gaziantep
[131714 BeeEnd aa
Addressing Modes

There are seven addressing modes.


Addressing Mode Syntax Description
Register mode Rn Register contents are operand
Indexed mode X(Rn) (Rn + X) points to the operand. X
is stored in the next word.
Symbolic mode ADDR (PC + X) points to the operand. X
is stored in the next word. Indexed
mode X(PC)is used.
Absolute mode &ADDR The wordfollowingthe instruction
contains the absolute address. X
is stored in the next word. Indexed
mode X(SR)is used.
Indirect register @Rn Rn is used as a pointerto the
mode operand.
Indirect @Rn+ ~—Rnis used as a pointerto the
autoincrement ‘operand.Rnis incremented
afterwardsby1 for .B instructions
and by2 for .W instructions.
Immediate mode #N The word followingthe instruction
contains the immediate constant
N. Indirect autoincrement mode
@PC+is used.
University of Gaziantep
iF Department of EEE
ed
Mode
Note: Use of Labels EDE, TONI, TOM, and LEO
Throughout MSP430 documentation EDE, TONI, TOM, and LEOare used
as generic labels. They are only labels. They have no special meaning.

Register Mode
Assembler Code Content of ROM
Mov_R10,R11 Mov_R10,R11
Length: Oneor two words
Operation: Movethe content of R10 to R11. R10 is notaffected.

Comment: Valid for source and destination


Example: MOV R10,R11

Before: After:

R10 [OA02an

R11 0A023h

pc pc [PCoa+2]

University of Gaziantep
[131714 Department of EEE
eaMo
u de mn

3REGISTER MODE EXAMPLE


mov.w #1234H,R6 ; thevalueof 01234 is loaded into register R6
mov.wW R6,R7 the contentof R6is copied into R7
mov.b #@xcd,R8 Thevalue of Oxedis loadedinto register RS
mov.b R8,R9
; the content of RS is copied into R9

iversity of Gaziantep
Si) Department of EEE
Addressing Modes

Assembler Code Content of ROM


MOV 2(R5),6(R6) MOV X(R5),¥(R6)
X=2
Y=6

Length: Twoor three words

Operation: Movethe contents of the source address (contents of R5 + 2)


to the destination address (contents of R6 + 6). The source
and destination registers (R5 and R6) are notaffected. In
indexed mode, the program counter is incremented
automatically so that program execution continues with the
next instruction.

Comment: Valid for source and destination

Example: MOV 2(R5),6(R6);

Introduction to Embedded Systems University of Gaziantep


Si) “ear ener ple! Department of EEE
Addressing M Indexed Mode

Example: MOV 2(RS5),6(R6);


Before: After:
Address Register Address Register
Space Space
rooxh
OFF16h 00006h RS} 01080h OFF16h 00006h RS] 01080h
OFF14h | 00002h | —-R6| 0108Ch| OFF14h 00002h R6| 0108Ch
fl line
OFF12h 04596h PC OFF12h 04596h

0108Ch
01094h +0006h_-01094h Oxxxxh
01092h 05555h 01082h —o1092h 01234h
01090h

01080h
+0002h_—-01084h
“oogah Oxcoxh
o1082h orosan [0124

University of Gaziantep
EEE204
Addressing Modes SiRmtmravare

Symbolic Mode Description

Assembler Code Content of ROM


MOV EDE, TONI MOV X(PC),Y(PC)

X=EDE -PC
Y = TONI - PC

Length: Twoor three words

Operation: Movethe contents of the source address EDE (contents of


PC + X) to the destination address TONI (contents of PC + Y).
The words after the instruction contain the differences
between the PC and the source or destination addresses.
The assembler computes and inserts offsets X and Y
automatically. With symbolic mode, the program counter(PC)
is incremented automatically so that program execution
continueswith the nextinstruction.

Comment: Valid for source and destination

” to Embedded Systems
Introduction B University of Gaziantep
iF Aa pea Department of EEE
Addressing Mode
Example: MOV EDE,TONI ;Source address EDE = OF016h
;Dest. address TONI=01114h
Before: After:
Address Register Address Register
Space Space
Oxoxh PC
OFF16h O11FEh| OFF16h O11FEh
OFF14h oFF14h 102h
OFF12h 04090h PC OFF12h 04090h

OFF 14h
OFO18h Oxxxxh +0F102h_ OF018h_ Oxxxh
oFoteh 0A123h OFOT6R Foren 0A123h
oFO14h Ox0xh oFO14h Oxxxxh

OFF 16h
01116h Oxxxxh +011FEh 01116h
01114h 05555h onnidh 01114h
01112h Oxooxh 01112h Oxooh

University of Gaziantep
EEE204
Addressing Mode

Absolute Mode Description

Assembler Code Content of ROM


MOV &EDE, &TONI MOV X(0),¥(0)

X= EDE
Y=TONI

Length: Twoorthree words

Operation: Move the contents of the source address EDE to the


destination address TONI. The words after the instruction
contain the absolute address of the source and destination
addresses. With absolute mode, the PC is incremented
automatically so that program execution continues with the
next instruction.

Comment: Valid for source and destination

EEE204
Me
aa s A
Pe Lrt
LY University of Gaziantep
Prof Dr. Eraun Ercelebi Department of EEE
Addressing Modes

Example: MOV &EDE,&TONI ;Source address EDE=0F016h,


;dest. address TONI=01114h
Before: After:
Address Register Address Register
Space Space
Owoaxh PC
oFFiéh O1114h OFF16h
oFFi4h OFO16h OFF14h
OFF12h 04292h PC OFF12h

OFO18h Oxxxxh oF018h Oxoxh


oFo16h 0A123h oFo16h 0A123h
oFo14h Oxcxh oF014h Oxoxh

01116h Oxoxh 01116h Oxooh


01114h 01234h 01114h
01112h Qxoo%h 01112h Oxo0xh

EEE204 ereeee University of Gaziantep


ee a ae Department of EEE
exasybareas YE

Indirect Mode Description

Assembler Code Content of ROM


MOV__@R10,0(R11) MOV__@R10,0(R11)

Length: Oneor two words

Operation: Movethe contents ofthe source address (contents of R10) to


the destination address (contents of R11). The registers are
not modified.

Comment: Valid only for source operand. The substitute for destination
operandis 0(Rd).

University of Gaziantep
[131714 Department of EEE
dressing Modes ftreeseeneatere

Example: MOV.B @R10,0(R11)


Before: After:
Address Register Address Register
Space Space
Oxxxh YS Oxxxxh PC
OFF16h
|_c00h R10
OFF 14h R11
OFF12h Oxoaxch

OFA34h Oxxxxh OFA34h Oxxxxh


OFA32h @s8y1| OFA32h
oFA30h Oia OFA30h Oxxxxh

oo2ash Oxxh 002A8h Oxxh


002A7h 012h 002A7h O5Bh
oo2a6h Oxxh oo2ash Oxxh

University of Gaziantep
EEE204
LRIMIEISE Autoincrement |_FINTYVWMR
. Indirect Autoincrement Mode Description

Assembler Code Content of ROM


MOV @R10+,0(R11) MOV__@R10+, 0(R11)

Length: Oneor two words

Operation: Movethe contents of the source address(contents of R10) to


the destination address (contents of R11). Register R10 is
incremented by 1 for a byte operation, or 2 for a word
operationafter the fetch; it points to the next address without
any overhead. This is useful for table processing.

Comment: Valid only for source operand. The substitute for destination
operandis 0(Rd) plus secondinstruction INCD Rd.

cti ed
sy: temsr University of Gaziantep
EEE204 Introduct ion to Emb edd Sys
Prof. Dr. Erqun Ercelebi Department of EEE
Addressing Modes fitveesteantecnenatre

Example: MOV @R10+,0(R11)


Before: After:
Address Register Address Register
Space Space

OFF18h |_Oxooeh OFF 18h |_Oxxxxh


OFF 16h 00000h R10[ OFA32h] oFF16h 00000h R10[ OFA34h
OFF14h | 04ABBh PC R11] 010A8h| OFF14h 04ABBh| \R11[ 010A8h
OFF 12h OFF 12h Oxxxh

OFA34h| Oxxaaxh OFA34h Ox00ch


OFA32 (asc OFA32h
OFA30h [Sexscoge] OFA30h Ox00ch

O10AAh| Oxxxxh 010AAh


O10A8h 010A8h| OSBC1h
010A6h o10A6h Ox00xh

MCMC nce ners University of Gaziantep


i Prof. Dr. Erqun Ercelebi Department of EEE
ressing M [S53 Immediate Mode

Immediate Mode Description

Assembler Cod Content of ROM


Mov #45h, TONI MOV @PC+,X(PC)
45
X= TONI - PC

Length: Two orthree words


It is one wordlessif a constant of CG1 or CG2 can be used.

Operation: Movethe immediate constant 45h, which is contained in the


word following the instruction, to destination address TONI.
Whenfetching the source, the program counterpoints to the
word following the instruction and moves the contentsto the
destination.

Comment: Valid only for a source operand.

University of Gaziantep
Si) Department of EEE

Das könnte Ihnen auch gefallen