Docsity

Addressing Modes 1-Programming and Computer Architechture-Lecture Slides, Slides of Computer Architecture and Organization

Partial preview of the text

Download Addressing Modes 1-Programming and Computer Architechture-Lecture Slides and more Slides Computer Architecture and Organization in PDF only on Docsity!

Addressing Modes

Day 4

What is an Instruction Set?

 The complete collection of instructions thatare understood by a CPU  Machine Code  Binary  Usually represented by assembly codes

Instruction Representation

 In machine code each instruction has aunique bit pattern  For human consumption (well, programmersanyway) a symbolic representation is used โ–  e.g. ADD, SUB, LOAD  Operands can also be represented in thisway โ–  ADD A,B

Simple Instruction Format

Number of Addresses (a)

 3 addresses โ–  Operand 1, Operand 2, Result โ–  a = b + c; โ–  May be a forth - next instruction (usually implicit) โ–  Not common โ–  Needs very long words to hold everything

Three Address Instruction

 Format operation op1,op2,op (op1,op2, op3 may be register or memory)  Example โ–  ADD R1, R2, R (R1 = R2 +R3) โ–  ADD A, B, C (variable A= mem. B +C) (The contents of R1 and A are lost whereas contents of R2, R3, B and C are still there)

Two Address Instruction

 Format operation op1,op2 (op1,op2 may be register or memory)  Example โ–  ADD R1, R (R1 = R1 +R2) โ–  ADD A, B (variable A= A+ mem. B) (The contents of R1 and A are lost whereas contents of R2 and B are still there)

Number of Addresses (c)

 1 address โ–  Implicit second address โ–  Usually a register (accumulator) โ–  Common on early machines

One & Half Address Instruction

 Format operation op1, op2 (op1 is memory and op2 must be register)  Example โ–  ADD G,R (R1 = mem. G + R1) This is because register addressing needs a smaller number of bitsthan those needed by memory bits

Zero Address Instruction

 It uses stack for operation  Operand is (implicitly) on top of stack  Format operation  Example โ–  PUSH โ–  POP โ–  ADD Question:Explain Stack operationusing different examples?

How Many Addresses

 More addresses โ–  More complex (powerful?) instructions โ–  More registers

  • Inter-register operations are quicker โ–  Fewer instructions per program  Fewer addresses โ–  Less complex (powerful?) instructions โ–  More instructions per program โ–  Faster fetch/execution of instructions

Design Decisions (1)

 Operation repertoire โ–  How many ops? โ–  What can they do? โ–  How complex are they?  Data types  Instruction formats โ–  Length of op code field โ–  Number of addresses

Types of Operand

 Addresses  Numbers โ–  Integer/floating point  Characters โ–  ASCII etc.  Logical Data โ–  Bits or flags  (Aside: Is there any difference between numbers andcharacters? Ask a C programmer!)

x86 Data Types

 8 bit Byte  16 bit word  32 bit double word  64 bit quad word  128 bit double quad word  Addressing is by 8 bit unit  Words do not need to align at even-numbered address  Data accessed across 32 bit bus in units ofdouble word read at addresses divisible by 4  Little endian