COS 140: Foundations of Computer Science

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

COMPUTER ORGANIZATION & ARCHITECTURE

Computer Organization CS 206 T Lec# 2: Instruction Sets

Instruction Sets: Characteristics and Functions Addressing Modes

Introduction to Computers & Programming

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

Lecture 4: Instruction Set Architecture

Introduction to Computer Science. Homework 1

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

Instruction Set Architecture

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

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

Processing Unit CS206T

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Instruction Set Design

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Instruction Set Architecture (ISA)

EC-801 Advanced Computer Architecture

Instruction Sets: Characteristics and Functions

CHAPTER 5 A Closer Look at Instruction Set Architectures

Assembly Language Design

CISC / RISC. Complex / Reduced Instruction Set Computers

COSC 6385 Computer Architecture. Instruction Set Architectures

Computer Architecture and Data Manipulation. Von Neumann Architecture

CHAPTER 5 A Closer Look at Instruction Set Architectures

17. Instruction Sets: Characteristics and Functions

Chapter 2 Logic Gates and Introduction to Computer Architecture

CS4617 Computer Architecture

Review of instruction set architectures

Chapter 2 Data Manipulation

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

EC 413 Computer Organization

ECE 486/586. Computer Architecture. Lecture # 7

Introduction to Computers - Chapter 4

CHAPTER 5 A Closer Look at Instruction Set Architectures

Chapter 1: Background

Computer Organization and Technology Processor and System Structures

Micro-programmed Control Ch 15

Class Notes. Dr.C.N.Zhang. Department of Computer Science. University of Regina. Regina, SK, Canada, S4S 0A2

Latches. IT 3123 Hardware and Software Concepts. Registers. The Little Man has Registers. Data Registers. Program Counter

Machine Instructions vs. Micro-instructions. Micro-programmed Control Ch 15. Machine Instructions vs. Micro-instructions (2) Hardwired Control (4)

Lecture 5: Instruction Set Architectures II. Take QUIZ 2 before 11:59pm today over Chapter 1 Quiz 1: 100% - 29; 80% - 25; 60% - 17; 40% - 3

Chapter 2: Instructions How we talk to the computer

Instruction Set Architecture

Micro-programmed Control Ch 15

THE MICROPROCESSOR Von Neumann s Architecture Model

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Micro-Operations. execution of a sequence of steps, i.e., cycles

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

CPE300: Digital System Architecture and Design

Data Manipulation. Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan

Chapter 13 Reduced Instruction Set Computers

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

COMPUTER ORGANIZATION AND ARCHITECTURE

Chapter 2: Data Manipulation

Lecture 4: RISC Computers

ASSEMBLY LANGUAGE MACHINE ORGANIZATION

Chapter 2: Data Manipulation

CS401 - Computer Architecture and Assembly Language Programming Glossary By

Chapter 17. Microprogrammed Control. Yonsei University

Typical Processor Execution Cycle

Author : Dalbir Singh, Computer Science Deptt. CPU Structure and Functions. 1. Processor Organization

Micro-programmed Control Ch 17

Behind the Curtain. Introduce TA Friday 1 st lab! (1:30-3:30) (Do Prelab before) 1 st Problem set on Thurs. Comp 411 Fall /16/13

Chapter 3 : Control Unit

Hardwired Control (4) Micro-programmed Control Ch 17. Micro-programmed Control (3) Machine Instructions vs. Micro-instructions

Instruction Set Architectures. Part 1

Instruction Set Architecture. "Speaking with the computer"

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

EITF20: Computer Architecture Part2.1.1: Instruction Set Architecture

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

2.2 THE MARIE Instruction Set Architecture

Computer Organisation CS303

COSC 122 Computer Fluency. Computer Organization. Dr. Ramon Lawrence University of British Columbia Okanagan

1. Fundamental Concepts

Topics in computer architecture

von Neumann Architecture Basic Computer System Early Computers Microprocessor Reading Assignment An Introduction to Computer Architecture

Basic Computer System. von Neumann Architecture. Reading Assignment. An Introduction to Computer Architecture. EEL 4744C: Microprocessor Applications

Chapter 2: Data Manipulation

Name: CMSC 313 Fall 2001 Computer Organization & Assembly Language Programming Exam 1. Question Points I. /34 II. /30 III.

Instruction Sets Ch 9-10

Instruction Sets Ch 9-10

Unsigned Binary Integers

Unsigned Binary Integers

Lecture1: introduction. Outline: History overview Central processing unite Register set Special purpose address registers Datapath Control unit

REDUCED INSTRUCTION SET COMPUTERS (RISC)

Instruction Set Architecture

MICROPROGRAMMED CONTROL

Alternate definition: Instruction Set Architecture (ISA) What is Computer Architecture? Computer Organization. Computer structure: Von Neumann model

Mark II Aiken Relay Calculator

Lecture 3 Machine Language. Instructions: Instruction Execution cycle. Speaking computer before voice recognition interfaces

Computer and Hardware Architecture I. Benny Thörnberg Associate Professor in Electronics

5 Computer Organization

Instruction Set Architectures. CS301 Prof. Szajda

Computer Organization

Problem with Scanning an Infix Expression

A Bit of History. Program Mem Data Memory. CPU (Central Processing Unit) I/O (Input/Output) Von Neumann Architecture. CPU (Central Processing Unit)

EE 3170 Microcontroller Applications

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

Multiple Choice Type Questions

Transcription:

COS 140: Foundations of Computer Science CPU Organization and Assembly Language Fall 2018 CPU 3 Components of the CPU..................................................... 4 Registers................................................................ 5 Register design issues........................................................ 6 Assembly Language 8 Machine Language......................................................... 8 Assembly Language......................................................... 9 Instruction Execution........................................................ 10 Instruction Format.......................................................... 11 Instruction Types 12 Types of Instructions........................................................ 12 Data Transfer Instructions.................................................... 13 Arithmetic Operations....................................................... 14 Logical operations.......................................................... 15 Transfer of control.......................................................... 16 System control............................................................ 17 Number of Instructions...................................................... 18 Data Types.............................................................. 20 Addressing Modes 21 Addressing Modes.......................................................... 21 Immediate Addressing....................................................... 22 Direct Addressing.......................................................... 23 Direct Addressing.......................................................... 24 Indirect Addressing......................................................... 25 Indirect Addressing......................................................... 26 Register Addressing......................................................... 27 Register Indirect Addressing................................................... 28 Other Addressing Modes..................................................... 29 Instruction Set Design 30 Abstraction 31 1

Abstraction hierarchy........................................................ 31 2

Homework, etc. Reading Chapter 14 Appendix A is there as well Homework: Exercises at end of Chapter 14, due 10/17 (later than usual) Prelim I: Friday, 10/12 Detailed questions (e.g., problems) on material up through RAID Conceptual questions on all material up to & including today s material Copyright c 2002 2018 UMaine Computer Science Department 2 / 31 CPU 3 / 31 Central Processing Unit Part of the computer that carries out the instructions of programs Controls the other two parts (memory, I/O). This class: CPU organization Machine (and assembly) language introduction Copyright c 2002 2018 UMaine Computer Science Department 3 / 31 3

Components of the CPU Arithmetic and logic unit (ALU): where actual computation takes place Control unit (CU): controls moving information around in CPU, placing data in registers, getting new instructions from memory, ALU function, etc. Registers: memory for CPU operation Copyright c 2002 2018 UMaine Computer Science Department 4 / 31 Registers Registers virtually all CPUs have: program (or instruction) counter program status word (PSW) instruction register Copyright c 2002 2018 UMaine Computer Science Department 5 / 31 4

Design Issues for Registers User accessible or protected? Want to protect the machine, other users from the user PSW probably protected Instruction counter: generally protected, but some special instructions for changing (e.g., branch, subroutine instructions) Data registers: user accessible (via instructions) Copyright c 2002 2018 UMaine Computer Science Department 6 / 31 Design Issues for Registers General-purpose or special-purpose? General-purpose flexibility Special-purpose reduce number of operands or operand size Mixed: some special-purpose registers that are used as general-purpose registers by some instructions Different size registers for different purposes Size? Need to hold largest operand required Sometimes use multiple registers for single operand Who saves them when needed (on interrupt) software or hardware? Copyright c 2002 2018 UMaine Computer Science Department 7 / 31 5

Assembly Language 8 / 31 Machine Language Instruction set: instructions CPU can carry out Each: Op code & 0 operands Operands include addresses and data. Op codes, operands: binary numbers of course. Instuctions are the machine language Difficult for humans to use! Copyright c 2002 2018 UMaine Computer Science Department 8 / 31 Assembly Language Symbolic version of machine language. Op codes represented by mnemonics e.g., Machine language: addition op code might be 001001 Assembly language: might represent as ADD Operands can be symbolic: names for constants, memory locations Assembler translates assembly language program machine language Copyright c 2002 2018 UMaine Computer Science Department 9 / 31 6

Instruction Execution Fetch instruction from memory Decode instruction Fetch operands (if any) Carry out instruction Store results (if any) Copyright c 2002 2018 UMaine Computer Science Department 10 / 31 Instruction Format Specification of action to be done: op code Addresses of any operands Address of any result to be stored E.g., add register 0 to register 1 Assembly lang: ADD R0,R1 Instruction: 01000 000 0000 00 01 5 bit op code, 3 bits unused, 4 bits for mode (direct, direct), R0, R1 Copyright c 2002 2018 UMaine Computer Science Department 11 / 31 7

Instruction Types 12 / 31 Types of Instructions Data transfer Arithmetic operations Logical operations Transfer of control System control Copyright c 2002 2018 UMaine Computer Science Department 12 / 31 Data Transfer Instructions Move data from place to place Source, destination could be registers, memory Different addressing modes possible (see later) Size of transfer: on some machines, amount can be large Copyright c 2002 2018 UMaine Computer Science Department 13 / 31 8

Arithmetic Operations Almost all CPUs (i.e., their ALUs) provide ADD, SUB, MULT, and DIV Why include SUB could use ADD and complement second op? Usually provide for signed integers, other types (e.g., floating point) Usually have to move the operand s data to location where ALU expects it (e.g., a register) Copyright c 2002 2018 UMaine Computer Science Department 14 / 31 Logical operations Usually provide AND, OR, NOT, XOR, EQUAL, SHIFT, ROTATE, maybe arithmetic shift (sign bit propagated) Why include all these, when you can do it all with NAND? What about complement? Can you do it with XOR? with NOT? How would you mask (clear) particular bits? How would you set particular bits? Copyright c 2002 2018 UMaine Computer Science Department 15 / 31 9

Transfer of control Branch (jump) instructions Unconditional and conditional Absolute or relative Subroutine call and return Copyright c 2002 2018 UMaine Computer Science Department 16 / 31 System control Protected operations only executable by some processes (e.g., operating system) Use to access protected registers, protected memory, etc. Input/output instructions are usually protected Copyright c 2002 2018 UMaine Computer Science Department 17 / 31 10

Number of Instructions One philosophy: have relatively few, simple instructions Allows instructions to be optimized Requires less chip space ( cheaper, or more other things can be put on chip) Components can be closer to each other ( faster) Reduced instruction set computers (RISC) Examples: SPARC chips in Sun machines, PowerPC in older Macs Copyright c 2002 2018 UMaine Computer Science Department 18 / 31 Number of Instructions Other philosophy: have a large number of instructions, including special-purpose ones (e.g., multimedia, etc.) Makes it easier for programmers Requires less memory, less disk space for programs Complex instruction set computers (CISC) Examples: Intel family of processors Copyright c 2002 2018 UMaine Computer Science Department 19 / 31 11

Data Types Numbers: Integers (sign-magnitude, 2 s complement, packed decimal) Floating point Size: single, double, etc. Characters: Encoded as ASCII or Unicode characters these days Single byte (ASCII) or two or more bytes (Unicode) in length Strings of characters: length + string or null-terminated Logical data General bit strings: e.g., for multimedia, etc. Copyright c 2002 2018 UMaine Computer Science Department 20 / 31 Addressing Modes 21 / 31 Addressing Modes Different instructions have different addressing modes Determines where the data corresponding to the operands is E.g.: think of operand as name of data s location Modes: immediate, direct, indirect, register, register indirect, displacement, others Issues: Which one should CPU use for instruction? Sometimes indicated by op code Sometimes indicated by mode bits that can be set How many bits are required for instruction? How many memory references are required to find effective address (where the data is actually located)? Copyright c 2002 2018 UMaine Computer Science Department 21 / 31 12

Immediate Addressing Operand s data is the operand itself: i.e., in instruction E.g., NEG #5 might mean negate 5, leave result in register 0 How many bits needed? Generally: fixed-size field in the instruction for operand Generally limited to integers (2 s complement) or characters Operand memory accesses: none Copyright c 2002 2018 UMaine Computer Science Department 22 / 31 Direct Addressing Operand contains memory address of the data E.g.: NEG 8: negate the value of the data located at memory location 8 Number of bits needed? Varies between computers, maybe between instructions With n bits devoted to address, can refer to 2 n addresses in memory Up to size of word Copyright c 2002 2018 UMaine Computer Science Department 23 / 31 13

Direct Addressing Operand memory accesses: one per operand CPU 1 2 3 Mem 4 Data Address Busses Copyright c 2002 2018 UMaine Computer Science Department 24 / 31 Indirect Addressing Operand contains the address of the address of the data E.g.: NEGI 8: ifaddress8contains24, thentheactualdatathatwouldbenegated would be what s stored at memory location 24. 48 44 40 36 32 28 24 20 16 12 8 4 0 1010 24 Number of bits needed same as for direct addressing Copyright c 2002 2018 UMaine Computer Science Department 25 / 31 14

Indirect Addressing Operand memory accesses needed: two per operand CPU 2 1 4 5 3 6 7 Mem 8 Data Address Busses Copyright c 2002 2018 UMaine Computer Science Department 26 / 31 Register Addressing Implicit op code specifies which register is used Explicit operand specifies which register E.g.: NEG R5 negate the data contained in register 5 Number of bits needed? Usually few, since number of registers limited. Operand memory accesses: none Only requires access to register, which is quick Only really efficient if register used over and over otherwise, have to load the register, which could be more inefficient than direct addressing RISC machines make heavy use of register addressing e.g., PowerPC forces this for all arithmetic operations Copyright c 2002 2018 UMaine Computer Science Department 27 / 31 15

Register Indirect Addressing Register contains address of the data E.g.: NEGI R5 if register 5 contains the value 24, then the data would be found at address 24 Number of bits needed? Same as register addressing Operand memory accesses: one per operand access When would this be useful? Copyright c 2002 2018 UMaine Computer Science Department 28 / 31 Other Addressing Modes Relative displacement addressing: used for jumps (branches) relative to program counter Base register displacement addressing: have a base register to which all addresses are added Copyright c 2002 2018 UMaine Computer Science Department 29 / 31 16

Instruction Set Design 30 / 31 Designing Instruction Sets Which operations to support Memory-mapped I/O or special instructions? How many instructions to support? RISC or CISC? Format of instructions: Size of instruction: part of word, word, multiple words? All instructions same size or not? Fields within instruction? All instructions with same format or not? Address modes? Number of registers? Addressing granularity? Copyright c 2002 2018 UMaine Computer Science Department 30 / 31 Abstraction 31 / 31 Abstraction hierarchy Problem-Oriented Language Level High-level language: e.g., C, C++, Java, Lisp, Ada, FORTRAN,... Assembly Language Level Symbolic API Conventional Machine Level CPU s API Microprogramming Level Functional units Digital Logic Level Gates Device Level Transistors, etc. Copyright c 2002 2018 UMaine Computer Science Department 31 / 31 17