Instruction Sets: Characteristics and Functions Addressing Modes

Similar documents
Computer Organization CS 206 T Lec# 2: Instruction Sets

Computer Architecture and Organization. Instruction Sets: Addressing Modes and Formats

COMPUTER ORGANIZATION & ARCHITECTURE

Addressing Modes. Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

Instruction Sets: Characteristics and Functions

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

Chapter 11. Instruction Sets: Addressing Modes and Formats. Yonsei University

Chapter 2 Instruction Set Architecture

Instruction Set Architecture

Instruction Set II. COMP 212 Computer Organization & Architecture. COMP 212 Fall Lecture 7. Instruction Set. Quiz. What is an Instruction Set?

Overview. EE 4504 Computer Organization. Much of the computer s architecture / organization is hidden from a HLL programmer

Module 3 Instruction Set Architecture (ISA)

SEN361 Computer Organization. Prof. Dr. Hasan Hüseyin BALIK (8 th Week)

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 10 Instruction Sets: Characteristics and Functions

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Interfacing Compiler and Hardware. Computer Systems Architecture. Processor Types And Instruction Sets. What Instructions Should A Processor Offer?

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

17. Instruction Sets: Characteristics and Functions

CSIS1120A. 10. Instruction Set & Addressing Mode. CSIS1120A 10. Instruction Set & Addressing Mode 1

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CPU Structure and Function. Chapter 12, William Stallings Computer Organization and Architecture 7 th Edition

Computer Organization and Technology Processor and System Structures

The Instruction Set. Chapter 5

We briefly explain an instruction cycle now, before proceeding with the details of addressing modes.

COS 140: Foundations of Computer Science

William Stallings Computer Organization and Architecture. Chapter 11 CPU Structure and Function

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

TYPES OF INTERRUPTS: -

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...

CHAPTER 5 A Closer Look at Instruction Set Architectures

Processing Unit CS206T

CHAPTER 5 A Closer Look at Instruction Set Architectures

Page 1. Structure of von Nuemann machine. Instruction Set - the type of Instructions

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Instruction-set Design Issues: what is the ML instruction format(s) ML instruction Opcode Dest. Operand Source Operand 1...

Instruction Set. Instruction Sets Ch Instruction Representation. Machine Instruction. Instruction Set Design (5) Operation types

The von Neumann Architecture. IT 3123 Hardware and Software Concepts. The Instruction Cycle. Registers. LMC Executes a Store.

CHAPTER 5 A Closer Look at Instruction Set Architectures

Lecture 4: Instruction Set Architecture

Assembly Language Design

UNIT 2 PROCESSORS ORGANIZATION CONT.

55:132/22C:160, HPCA Spring 2011

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

Instruction Set Design

2. ADDRESSING METHODS

COSC 6385 Computer Architecture. Instruction Set Architectures

Computer System Architecture

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 12 Processor Structure and Function

William Stallings Computer Organization and Architecture

Instructions: Language of the Computer

CS401 - Computer Architecture and Assembly Language Programming Glossary By

UNIT- 5. Chapter 12 Processor Structure and Function

3.1 DATA MOVEMENT INSTRUCTIONS 45

William Stallings Computer Organization and Architecture

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

CN310 Microprocessor Systems Design

COMPUTER HARDWARE. Instruction Set Architecture

Computer Architecture. The Language of the Machine

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

Chapter 2A Instructions: Language of the Computer

Computer Architecture 1 ح 303

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

INSTRUCTION SET ARCHITECTURE

3.0 Instruction Set. 3.1 Overview

Main Points of the Computer Organization and System Software Module

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

CN310 Microprocessor Systems Design

Understand the factors involved in instruction set

Instruction Set Architecture (ISA)

EEM336 Microprocessors I. Arithmetic and Logic Instructions

2. Define Instruction Set Architecture. What are its two main characteristics? Be precise!

CPU Structure and Function

Computer Organisation CS303

Chapter 3 Machine Instructions & Programs. Jin-Fu Li Department of Electrical Engineering National Central University Jungli, Taiwan

Real instruction set architectures. Part 2: a representative sample

EC 413 Computer Organization

CS4617 Computer Architecture

Programming of 8085 microprocessor and 8051 micro controller Study material

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1

CHAPTER 8: Central Processing Unit (CPU)

COMPUTER ORGANIZATION & ARCHITECTURE

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

A First Look at Microprocessors

Instruction content (2/2) Instruction content (1/2) The Instruction Set. Chapter 9. Each instruction must contain 4 basic pieces of information

TABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention

Instruction Set Architecture. "Speaking with the computer"

VARDHAMAN COLLEGE OF ENGINEERING (AUTONOMOUS) Shamshabad, Hyderabad

When an instruction is initially read from memory it goes to the Instruction register.

2.2 THE MARIE Instruction Set Architecture

Digital System Design Using Verilog. - Processing Unit Design

Fig: Computer memory with Program, data, and Stack. Blog - NEC (Autonomous) 1

Practical Malware Analysis

Chapter 2. Instruction Set. RISC vs. CISC Instruction set. The University of Adelaide, School of Computer Science 18 September 2017

Assembly Language Programming of 8085

Run time environment of a MIPS program

Intel 8086: Instruction Set

Transcription:

Instruction Sets: Characteristics and Functions Addressing Modes Chapters 10 and 11, William Stallings Computer Organization and Architecture 7 th Edition

What is an Instruction Set? The complete collection of instructions that are understood by a CPU Machine language: binary representation of operations and (addresses of) arguments Assembly language: mnemonic representation for humans, e.g., OP A,B,C (meaning A <- OP(B,C))

Elements of an Instruction Operation code (opcode) Do this: ADD, SUB, MPY, DIV, LOAD, STOR Source operand reference To this: (address of) argument of op, e.g. register, memory location Result operand reference Put the result here (as above) Next instruction reference (often implicit) When you have done that, do this: BR

Simple Instruction Format (using two addresses)

Instruction Cycle State Diagram

Operation repertoire How many ops? Design Decisions (1) What can they do? How complex are they? Data types (length of words, integer representation) Instruction formats Length of op code field Length and number of addresses (e.g., implicit addressing)

Design Decisions (2) Registers Number of CPU registers available Which operations can be performed on which registers? General purpose and specific registers Addressing modes (see later) RISC v CISC

Instruction Types Data transfer: registers, main memory, stack or I/O Data processing: arithmetic, logical Control: systems control, transfer of control

Data Transfer Store, load, exchange, move, clear, set, push, pop Specifies: source and destination (memory, register, stack), amount of data May be different instructions for different (size, location) movements, e.g., IBM S/390: L (32 bit word, R<-M), LH (halfword, R<-M), LR (word, R<-R), plus floating-point registers LER, LE, LDR, LD Or one instruction and different addresses, e.g. VAX: MOV

Input/Output May be specific instructions, e.g. INPUT, OUTPUT May be done using data movement instructions (memory mapped I/O) May be done by a separate controller (DMA): Start I/O, Test I/O

Arithmetic Add, Subtract, Multiply, Divide for signed integer (+ floating point and packed decimal) may involve data movement May include Absolute ( a ) Increment (a++) Decrement (a--) Negate (-a)

Logical Bitwise operations: AND, OR, NOT, XOR, TEST, CMP, SET Shifting and rotating functions, e.g. logical right shift for unpacking: send 8-bit character from 16-bit word arithmetic right shift: division and truncation for odd numbers arithmetic left shift: multiplication without overflow

Systems Control Privileged instructions: accessing control registers or process table CPU needs to be in specific state Ring 0 on 80386+ Kernel mode For operating systems use

Transfer of Control Skip, e.g., increment and skip if zero: ISZ Reg1, cf. jumping out from loop Branch instructions: BRZ X (branch to X if result is zero), BRP X (positive), BRN X (negative), BRE X,R1,R2 (equal) Procedure (economy and modularity): call and return

Branch Instruction

Nested Procedure Calls

Use of Stack: Saving the return address for reentrant procedures

Types of Operand Addresses: immediate, direct, indirect, stack Numbers: integer or fixed point (binary, twos complement), floating point (sign, significand, exponent), (packed) decimal (246 = 0000 0010 0100 0110) Characters: ASCII (128 printable and control characters + bit for error detection) Logical Data: bits or flags, e.g., Boolean 0 and 1

Pentium Data Types Addressing is by 8 bit unit General data types: 8 bit Byte, 16 bit word, 32 bit double word, 64 bit quad word Integer: signed binary using twos complement representation (Un)packed decimal Near pointer: offset in segment Bit field Strings Floating point

Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than one instruction format in an instruction set

Instruction Length Affected by and affects: Memory size Memory organization - addressing Bus structure, e.g., width CPU complexity CPU speed Trade off between powerful instruction repertoire and saving space

Allocation of Bits Number of addressing modes: implicit or additional bits specifying it Number of operands Register (faster, limited size and number, 32) versus memory Number of register sets, e.g., data and address (shorter addresses) Address range Address granularity (e.g., by byte)

Number of Addresses More addresses More complex (powerful?) instructions More registers - inter-register operations are quicker Less instructions per program Fewer addresses Less complex (powerful?) instructions More instructions per program, e.g. data movement Faster fetch/execution of instructions Example: Y=(A-B):[(C+(DxE)]

3 addresses Operation Result, Operand 1, Operand 2 Not common Needs very long words to hold everything SUB Y,A,B MPY T,D,E ADD T,T,C DIV Y,Y,T Y <- A-B T <- DxE T <- T+C Y <- Y:T

2 addresses One address doubles as operand and result Reduces length of instruction Requires some extra work: temporary storage MOVE Y,A SUB Y,B MOVE T,D MPY T,E ADD T,C DIV Y,T Y <- A Y <- Y-B T <- D T <- TxE T <- T+C Y <- Y:T

1 address Implicit second address, usually a register (accumulator, AC) LOAD D MPY E ADD C STOR Y LOAD A SUB B DIV Y STOR Y AC <- D AC <- ACxE AC <- AC+C Y <- AC AC <- A AC <- AC-B AC <- AC:Y Y <- AC

0 (zero) addresses All addresses implicit, e.g. ADD Uses a stack, e.g. pop a, pop b, add c = a + b

Addressing Modes Immediate Direct Indirect Register Register Indirect Displacement (Indexed) Stack

Immediate Addressing Operand is part of instruction Operand = address field e.g., ADD 5 or ADD #5 Add 5 to contents of accumulator 5 is operand No memory reference to fetch data Fast Limited range

Direct Addressing Address field contains address of operand Effective address (EA) = address field (A) e.g., ADD A Add contents of cell A to accumulator Look in memory at address A for operand Single memory reference to access data No additional calculations needed to work out effective address Limited address space (length of address field)

Direct Addressing Diagram Opcode Instruction Address A Memory Operand

Indirect Addressing (1) Memory cell pointed to by address field contains the address of (pointer to) the operand EA = (A) Look in A, find address (A) and look there for operand E.g. ADD (A) Add contents of cell pointed to by contents of A to accumulator

Indirect Addressing (2) Large address space 2 n where n = word length May be nested, multilevel, cascaded e.g. EA = (((A))) Multiple memory accesses to find operand Hence slower

Indirect Addressing Diagram Instruction Opcode Address A Memory Pointer to operand Operand

Register Addressing (1) Operand is held in register named in address field EA = R Limited number of registers Very small address field needed Shorter instructions Faster instruction fetch

Register Addressing (2) No memory access Very fast execution Very limited address space Multiple registers helps performance Requires good assembly programming or compiler writing see register renaming cf. direct addressing

Register Addressing Diagram Opcode Instruction Register Address R Registers Operand

Register Indirect Addressing Cf. indirect addressing EA = (R) Operand is in memory cell pointed to by contents of register R Large address space (2 n ) One fewer memory access than indirect addressing

Register Indirect Addressing Diagram Opcode Instruction Register Address R Memory Registers Pointer to Operand Operand

Displacement Addressing EA = A + (R) Address field hold two values A = base value R = register that holds displacement or vice versa See segmentation

Displacement Addressing Diagram Opcode Register R Instruction Address A Memory Registers Displacement + Operand

Relative Addressing A version of displacement addressing R = Program counter, PC EA = A + (PC) i.e., get operand from A cells away from current location pointed to by PC cf. locality of reference & cache usage

Base-Register Addressing A holds displacement R holds pointer to base address R may be explicit or implicit e.g., segment registers in 80x86

Indexed Addressing A = base R = displacement EA = A + R Good for iteration, e.g., accessing arrays EA = A + R R++ Sometimes automated: autoindexing (signalled by one bit in instruction)

Stack Addressing Operand is (implicitly) on top of stack e.g. ADD Pop top two items from stack and add and push result on top

PowerPC Addressing Modes Load/store architecture (see next slide): Displacement and indirect indexed EA = base + displacement/index with updating base by computed address Branch address Absolute Relative (see loops): (PC) + I Indirect: from register Arithmetic Operands in registers or part of instruction For floating point: register only

PowerPC Memory Operand Addressing Modes