Chapter 11 Instruction Sets

45
Addressing Modes and Formats Chapter 11 Instruction Sets

description

Chapter 11 Instruction Sets. Addressing Modes and Formats. Team Members. Jose Alvarez Daniel Monsalve Marlon Calero Alfredo Guerrero Oskar Pio Andres Manyoma. Addressing Modes. An addressing mode is the method by which an instruction references memory Types of addressing modes: - PowerPoint PPT Presentation

Transcript of Chapter 11 Instruction Sets

Page 1: Chapter 11 Instruction Sets

Addressing Modes and Formats

Chapter 11Instruction Sets

Page 2: Chapter 11 Instruction Sets

Team MembersJose AlvarezDaniel MonsalveMarlon Calero Alfredo GuerreroOskar PioAndres Manyoma

2

Page 3: Chapter 11 Instruction Sets

Addressing ModesAn addressing mode is the method by which an

instruction references memoryTypes of addressing modes:

ImmediateDirect IndirectRegisterRegister IndirectDisplacement (Indexed)Stack

3

Page 4: Chapter 11 Instruction Sets

Immediate AddressingSimplest form of addressingActual data is stored in instructionValue of the operand is stored within instructionData sizes vary by processor and by instructionNo memory reference (other than instruction

fetch) required to obtain operandSize of number limited to size of address field

4

Page 5: Chapter 11 Instruction Sets

Immediate Addressing Diagram

Instruction Opcode Operand

5

Page 6: Chapter 11 Instruction Sets

Direct AddressingInstruction points to location of stored value, but

value itself is out of memorySingle memory reference to access dataNo additional calculations needed to work out

effective addressFrequently used for global variables in high level

languageLimited address space

6

Page 7: Chapter 11 Instruction Sets

Direct Addressing Diagram7

Address AOpcode

Instruction

Memory

Operand

Page 8: Chapter 11 Instruction Sets

Indirect AddressingMemory pointed to by address field contains the

address of the operandLarge address space 2n where n = word lengthMultiple memory accesses to find operandHence slower

8

Page 9: Chapter 11 Instruction Sets

Indirect Addressing Diagram9

Address AOpcode

Instruction

Memory

Operand

Pointer to operand

Page 10: Chapter 11 Instruction Sets

Register AddressingSpecified instruction contains required operandLimited number of registersSmall address field needed

Leads to shorter instructions, but faster fetch cycle

No memory accessFast executionLimited address space

10

Page 11: Chapter 11 Instruction Sets

Register Addressing Diagram11

Register Address ROpcode

Instruction

Registers

Operand

Page 12: Chapter 11 Instruction Sets

Register Indirect AddressingVery similar to indirect addressingOnly one main difference between the twoAlgorithms:

Register Indirect: EA = (R) Indirect: EA = (A)

Advantages/disadvantages also similar to those of indirect addressing:Advantage: Large address space (2n)Disadvantage: Extra memory reference

12

Page 13: Chapter 11 Instruction Sets

Register Indirect Addressing Diagram

13

Register Address ROpcode

Instruction

Memory

OperandPointer to Operand

Registers

Page 14: Chapter 11 Instruction Sets

Displacement AddressingVery powerful addressing modeCombines capabilities of direct and register

indirect addressing ( EA = A + (R) )Three common uses for displacement addressing

Relative addressingBase-register addressing Indexing

14

Page 15: Chapter 11 Instruction Sets

Displacement Addressing (continued)Relative addressing

Implicitly referred to in PC. If most memory references near to instruction being executed, use of relative addressing saves address bits in instruction

Base-register addressingConvenient means of implementing segmentation

Indexed addressingAddress field references a main memory address;

referenced register contains positive displacement from that address

15

Page 16: Chapter 11 Instruction Sets

Displacement Addressing Diagram

16

Register ROpcode

Instruction

Memory

OperandPointer to Operand

Registers

Address A

+

Page 17: Chapter 11 Instruction Sets

Stack AddressingLinear array of locationsOther names: Pushdown list, last-in-first-out queueStack is a reverse block of locationsHas a pointer associated with itStack locations in memory are register indirect

addressed

17

Page 18: Chapter 11 Instruction Sets

Stack Addressing Diagram18

Page 19: Chapter 11 Instruction Sets

x86 Addressing Modes (continued)8 addressing modes available

ImmediateRegister operandDisplacementBaseBase with displacementScaled index with displacementBase with index and displacementBase scaled index with displacementRelative

19

Page 20: Chapter 11 Instruction Sets

x86 Addressing Mode Calculation

20

Page 21: Chapter 11 Instruction Sets

ARM Addressing Modes

Arm has a rich set of addressing modes.Typically they are classified with respect to the type of

instruction.Load/Store AddressingData Processing Instruction AddressingBranch InstructionsLoad/Store Multiple Addressing

21

Page 22: Chapter 11 Instruction Sets

ARM Addressing ModesLoad/StoreLoads and stores Instructions are the only instructions

that reference memory, always done indirectly through a base register plus offset.

3 alternatives are : Offset Preindex Postindex

22

Page 23: Chapter 11 Instruction Sets

ARM Data Processing Instruction Addressing & Branch InstructionsData Processing

Or mixture of register and immediate addressingBranch

Immediate Instruction contains 24 bit valueShifted 2 bits left

On word boundary Effective range +/-32MB from PC

23

Page 24: Chapter 11 Instruction Sets

ARM Load/Store Multiple AddressingLoad/store subset of general-purpose registers 16-bit instruction field specifies list of registersSequential range of memory addressesIncrement after, increment before, decrement

after, and decrement beforeBase register specifies main memory address Incrementing or decrementing starts before or

after first memory access

24

Page 25: Chapter 11 Instruction Sets

Instruction FormatsLayouts of bits in an instructionIncludes opcodeIncludes (implicit or explicit) operand(s)Usually more than one instruction in an instruction

set

25

Page 26: Chapter 11 Instruction Sets

Instruction LengthAffected by and affects:

Memory size Memory organization Bus structure CPU complexity CPU speed

Tradeoff between powerful instruction repertoire and saving space

26

Page 27: Chapter 11 Instruction Sets

Instruction Length (continued)Should be equal to or multiple of memory transfer

lengthShould be multiple of character length (usually 8

bits)Word length of memory is “natural” unit of

organization

27

Page 28: Chapter 11 Instruction Sets

Allocation of BitsTradeoff between number of opcodes and power

of the addressing capabilityMore opcodes mean more bits in the opcode fieldIn an instruction format, this reduces number of

bits available for addressingInterrelated factors that determine the use of

addressing bits:

28

Page 29: Chapter 11 Instruction Sets

Allocation of Bits (continued)Number of addressing modes: can be implicit,

but sometimes one or more mode bits are neededNumber of operands: today’s machines provide

for two operands, each requiring its own mode indicator

Register versus memory: one operand address is implicit and consumes no instruction bits, but causes awkward programming and many instructions (a total of 8 to 32 user-visible registers is desirable)

29

Page 30: Chapter 11 Instruction Sets

Allocation of BitsNumber of register sets: most machines have

one set of 32 general-purpose registers to store data and addressesArchitectures like Pentium have more specialized

sets, that by a functional split the instruction uses fewer bits

Address range: related to number of address bits, has severe limitations (which is why direct addressing is rarely used) With displacement addressing, the range is opened

up to the length of the address register

30

Page 31: Chapter 11 Instruction Sets

Allocation of BitsAddress granularity: a factor for addresses that

reference memory rather than registers In a system with 16- or 32-bit words, an address can

reference a word or a byte at the designer’s choice Byte addressing is convenient for character

manipulation but requires more address bits

31

Page 32: Chapter 11 Instruction Sets

PDP-8 Instruction Format32

Page 33: Chapter 11 Instruction Sets

PDP-10 Instruction Format33

Page 34: Chapter 11 Instruction Sets

Variable-Length InstructionMake it difficult to decouple memory fetchesFetch part, then decide whether to fetch more,

and maybe miss in cache before instruction is complete

Fixed length allows full instruction to be fetched in one access

34

Page 35: Chapter 11 Instruction Sets

PDP-11Designed to provide powerful and flexible

instruction set within constraints of 16-bit minicomputer

Employs set of eight 16-bit general-purpose registers

Two of these registers have additional significanceOne is used as a stack pointer for special-purpose

stack operationsThe other is used as the program counter, which

contains the address of the next instruction

35

Page 36: Chapter 11 Instruction Sets

PDP-11 (continued) PDP-11 instructions set and addressing capability

are complexThis increases both hardware cost and

programming complexityThe advantage is that more efficient or compact

programs can be developed

36

Page 37: Chapter 11 Instruction Sets

PDP-11 Instruction Format37

Page 38: Chapter 11 Instruction Sets

VAXMost architectures provide a relatively small

number of fixed instruction formatsTo avoid problems two criteria were used in

designing the VAXAll instructions should have the “natural” number of

operandsAll operands should have the same generality in

specification

VAX instruction begins with a 1-byte opcode, which suffices to handle most VAX instructions

38

Page 39: Chapter 11 Instruction Sets

VAX Instruction Examples39

Page 40: Chapter 11 Instruction Sets

VAX Instruction FormatsThe remainder of the instructions consists of up

to six operand specifiersIs, at minimum, a 1-byte format in which the

leftmost 4 bits are the address mode specifier The only exception to this rule is the literal mode,

which is signaled by the pattern 00 in the leftmost 2 bits, leaving space for a 6-bit literal

Because of this exception, a total of 12 different addressing modes can be specified

40

Page 41: Chapter 11 Instruction Sets

VAX Instruction FormatsAn example uses an 8-, 16-, or 32-bit

displacement. An indexed mode of addressing may be used. In this case, the first byte of the operand specifier consists of the 4-bit addressing mode code of 0100 and a 4-bit index register identifier.

The remainder of operand specifier consists of base address specifier, which may be one or more bytes.

The VAX instruction set provides for a wide variety of operations and addressing modes. This gives the programmer a very powerful and flexible tool for developing programs.

41

Page 42: Chapter 11 Instruction Sets

Questions1) How many x86 addressing modes were

presented?

42

Ans: 9- Imme, Reg operand, Displacement, Base, Base with Displacement, Scaled Index with Displacement, Base with index and Displacement, Base with scaled Index and Displacement, Relative.

2) What are the most common addressing modes?Ans: Immediate, direct, indirect, register, register indirect, displacement, stack

3) How many ARM Addressing modes are there?Load/Store addressing, Data Process Inst Addr, Branch Inst, Load/Store multiple Addr.

Page 43: Chapter 11 Instruction Sets

Questions4) How many factors can go into determining the

use of determining addressing bits?

43

Ans: # of Addr. Modes, # of Operands, Register vs Mem, # of reg sets, Address Range, Address Granularity

5) What is the fastest Addressing mode?Ans: Immediate Opt code + Operand

6) What is an advantage of using Direct addressing mode? Ans: Simplicity Opt code + lower address

space.7) What addressing mode combines the capabilities of direct & reg indirect addr?

Ans: Displacement

Page 44: Chapter 11 Instruction Sets

Questions

8) Which addressing mode it’s also known as pushdown list addressing mode.

44

Ans: Stack Addressing mode.9) Which of the addressing modes is the simplest?

Ans: immediate addressing mode

10) More opcodes mean more ___ in the opcode field?Ans: Bits

Page 45: Chapter 11 Instruction Sets

Thank You

[APPLAUSE]

45