0% found this document useful (0 votes)
84 views14 pages

Data Movement Instructions: Topics To Discuss

This document discusses different addressing modes in computer programming including: 1) Base + Offset mode which uses a base register and signed offset to generate a memory address. 2) Indirect mode which reads an address from memory and then loads/stores to that address location. 3) Immediate mode using the LEA instruction which computes an address but stores it in a register rather than loading memory contents. Examples of instructions in each mode are provided.

Uploaded by

vipulugale
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT or read online on Scribd
0% found this document useful (0 votes)
84 views14 pages

Data Movement Instructions: Topics To Discuss

This document discusses different addressing modes in computer programming including: 1) Base + Offset mode which uses a base register and signed offset to generate a memory address. 2) Indirect mode which reads an address from memory and then loads/stores to that address location. 3) Immediate mode using the LEA instruction which computes an address but stores it in a register rather than loading memory contents. Examples of instructions in each mode are provided.

Uploaded by

vipulugale
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT or read online on Scribd
You are on page 1/ 14

Computer Programming TA C162

Topics to discuss…

Data Movement Instructions


• PC Relative Mode
 LD, ST (Done)
• Base + Offset Mode
 LDR, STR
• Indirect mode
 LDI, STI
• Immediate Mode
 LEA

1
Computer Programming TA C162

Base + Offset Addressing Mode


With PC-relative mode, can only address data within 256
words of the instruction.
• What about the rest of memory?
Solution #1
• Use a register to generate a full 16-bit address.

4 bits for opcode, 3 for src/dest register, 3 bits for base register
Remaining 6 bits are used as a signed offset.

2
Computer Programming TA C162

LDR (Base+Offset)

3
Computer Programming TA C162

What does the following instruction do ?

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 1 1 0 1 1 0 1 0 1 1 0 1 1 1 1
Opcode Destination Base Signed Offset (6 bits)
LDR R6
Register Register R5 x2F

Let say R5 contains x6AC9.


Signed extended offset becomes xFFEF
Operand address will be x6AC9 + xFFEF
Content of memory location (x6AC9 + xFFEF) will be loaded in R6

4
Computer Programming TA C162

STR (Base+Offset)

5
Computer Programming TA C162

What does the following instruction do ?

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 1
Opcode Source Base Signed Offset (6 bits)
STR R6 Register R5 x2F
Register

Let say R5 contains x6AC9.


Signed extended offset becomes xFFEF
Operand address will be x6AC9 + xFFEF
Contents of R6 will be store in memory location (x6AC9 + xFFEF)

6
Computer Programming TA C162

Indirect Addressing Mode


With PC-relative mode, can only address data within 256
words of the instruction.
• What about the rest of memory?

Solution #2
• Read address from memory location, then load/store to
that address.

First address is generated from PC and IR (just like PC-


relative addressing), then content of that address is used as
target for load/store.

7
Computer Programming TA C162

LDI (Indirect)

8
Computer Programming TA C162

What does the following instruction do ?

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 1
Destination
Opcode LDI R6 PC Offset (9 bits) x1AF
Register

Assume this LDI instruction is in the location x2345.  While this instruction
is in execution, PC will have x2346.
Sign Extended offset is xFFAF
The address of operand’s address is  xFFAF + x 2346
Assume the contents of the memory location (xFFAF + x 2346) xABC6
So the address of the operand becomes xABC6
So finally contents of memory location xABC6 will be loaded in R6

9
Computer Programming TA C162

STI (Indirect)

10
Computer Programming TA C162

What does the following instruction do ?

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

1 0 1 1 1 1 0 1 1 0 1 0 1 1 1 1
Destination
Opcode STI R6 PC Offset (9 bits) x1AF
Register

Assume this STI instruction is in the location x2345.  While this instruction
is in execution, PC will have x2346.
Sign Extended offset is xFFAF
The address of operand’s address is  xFFAF + x 2346
Assume the contents of the memory location (xFFAF + x 2346) xABC6
So the address of the operand becomes xABC6
So finally contents of R6 will be STORED in memory location xABC6

11
Computer Programming TA C162

Load Effective Address (Immediate)


Computes address like PC-relative -> PC + signed offset and
stores the result into a register

The address is stored in the register, not the contents of the


memory location.

Why Immediate?
No memory access required for operand loading.

12
Computer Programming TA C162

LEA

13
Computer Programming TA C162

Excercise
Address Instruction Comments
LEA
x30F6 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 R1 ← PC – 3 = x30F4
ADD
x30F7 0 0 0 1 0 1 0 0 0 1 1 0 1 1 1 0 R2 ← R1 + 14 = x3102
ST M[PC - 5] ← R2
x30F8 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 M[x30F4] ← x3102
AND
x30F9 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2 ← 0
ADD
x30FA 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 R2 ← R2 + 5 = 5
STR
M[R1+14] ← R2
x30FB 0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 0 M[x3102] ← 5

LDI R3 ← M[M[x30F4]]
x30FC 1 0 1 0 0 1 1 1 1 1 1 1 0 1 1 1 R3 ← M[x3102]
R3 ← 5

opcode
14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy