Top Banner
Lesson 05: Basic Addressing Modes for operands Chapter 04: Instruction Sets and the Processor organizations
23

Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Jul 19, 2018

Download

Documents

doancong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Lesson 05: Basic Addressing Modes for operands

Chapter 04: Instruction Sets and the Processor organizations

Page 2: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

2

Objective

• Basic Addressing Modes

Page 3: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

3

Addressing Modes

Page 4: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

4

Addressing mode

• Defined by an instruction opcode of an instruction lets the processor compute the address of the operands

Page 5: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

5

Common Ways

• 4-ways─ the instructions of an instruction set compute the address of the operands

1. At a register 2. At a memory address specified in instruction 3. At a memory address pointed by a register4. The immediate operand (part of instruction

after the opcode bits)

Page 6: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

6

Indirect Addressing Mode

Page 7: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

7

Indirect Memory to Register Operation Format

ADD r0, r1, r2 {M [addr1]},

r03-bits

Opcode7-bits

r13-bits

r23-bits

Indirect Address

Page 8: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

8

4) Immediate operand

• Operand is at a part of the instruction immediate operand after the opcode of the instruction — ADD r1, #07, second source operand is immediate and is 07

• First source operand and destination is same and is a register operand in r1

Page 9: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

9

Immediate operand

Page 10: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

10

Constant (Immediate Operand) to Register Operation Format

• If register r0 is specified by 3-bits and a constant is of 12 bits then instruction MOV r0, #b11-b0 can be three-bytes (m = 3) long when the opcode field can have 24 − 3 − 12 = 9 bits. b11-b0 are 12 bits for a constant value to be moved in the register r0. r0 ← #b11-b0

Immediate Address

Page 11: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

11

MOV r0, #constant

r0 3-bits

Opcode 9-bits

constant12-bits

Immediate Address

Page 12: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

12

Memory address as operand

Page 13: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

13

Register to memory or Memory to Register Operation Formats

• I = operation (M0,.., Mi, r0,.., rj) or I = operation (r0,.., rj, M0,.., Mi,)

• i = 0, 1 or 2 and j = 0, 1 or 2• M─ means a memory address and r means a

register• Mi ─ means memory content at address i,

ADDRi

Page 14: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

14

Memory address among 2n locations

1) Memory address short or at a page or segment of memory – A memory address represented by few bits than n

Page 15: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

15

MUL r0, M [addr1].

• Direct memory by short address ─ If register r2 is specified by 4-bits and memory addresses by 20 bits (a short address for 32-bits), then MUL r2, M [addr1] can be four-bytes (m = 4) long when the opcode field can have 32 − 4 − 20 = 8 bits. [r3 is implicit.] (r2-r3) pair← r2 × M [addr1].

Page 16: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

16

Memory address among 2n locations

2) Memory address long - A memory address represented by all address bits represented by nbits

Page 17: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

17

MUL r2, r3, M [addr1]

• Absolute long memory address─ If register pair r2-r3 is specified by 4-bits each and memory addresses by 32 bits, then MUL r2, r3, M [addr1] can be six-bytes (m = 6) long when the opcode field can have 48 − 8 − 32 = 8 bits. r2-r3← r2 × M [addr1]

Page 18: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

18

Memory address among 2n locations

3) Relative address─ A memory address represented by relative displacement (plus or minus) from the next instruction address

Page 19: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

19

Memory address among 2n locations

4) Offset address─ A memory address represented by an offset with respect to a base address, the offset plus base address bits displacement (plus or minus) from next instruction address

Page 20: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

20

Memory address among 2n locations

5) Base plus relative or offset, Index plus relative or offset, Base plus index plus relative or offset

Page 21: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

21

Summary

Page 22: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

22

• Addressing of operands from memory• Register addressing• Memory direct addressing• Memory indirect addressing • Absolute long address• Relative address• Offset (Displacement)• Immediate addressing

We Learnt

Page 23: Basic Addressing Modes for operands Chapter 04 ...€¦ · Basic Addressing Modes for operands ... the instructions of an instruction set ... Operation Format • If register r 0

Schaum’s Outline of Theory and Problems of Computer ArchitectureCopyright © The McGraw-Hill Companies Inc. Indian Special Edition 2009

23

End of Lesson 05 on Basic Addressing Modes for operands