CS1Q Computer Systems Lecture 3 Simon Gay. Lecture 3CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.

Slides:



Advertisements
Similar presentations
RAM (cont.) 220 bytes of RAM (1 Mega-byte) 20 bits of address Address
Advertisements

Stored Program Architecture
Instruction Set Design
Microprocessors Typical microprocessor controlled devices: Camera, mobile phone, stereo, mp3 player, electronic toys… High-level microprocessor controlled.
Chapter 2 Machine Language.
 Suppose for a moment that you were asked to perform a task and were given the following list of instructions to perform:
1. Microprocessor. mp mp vs. CPU Intel family of mp General purpose mp Single chip mp Bit slice mp.
Elements of a Microprocessor system Central processing unit. This performs the arithmetic and logical operations, such as add/subtract, multiply/divide,
Processor System Architecture
INTRODUCTION OF COMPUTER
Computer Architecture and Data Manipulation Chapter 3.
General information Course web page: html Office hours:- Prof. Eyal.
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
Stored Program Concept: The Hardware View
Choice for the rest of the semester New Plan –assembler and machine language –Operating systems Process scheduling Memory management File system Optimization.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
EET 2261 Unit 2 HCS12 Architecture
Computer Organization and Assembly language
Computer Organization and Assembly language
Computer Structure.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Computer Architecture and Organization
BLOCK DIAGRAM OF COMPUTER
Computer Organization
C.S. Choy95 COMPUTER ORGANIZATION Logic Design Skill to design digital components JAVA Language Skill to program a computer Computer Organization Skill.
1.1 1 Introduction Foundations of Computer Science  Cengage Learning.
Intro to CS Chapt 2 Data Manipualtion 1 Data Manipulation How is data manipulated inside a computer? –How is data input? –How is it stored? –How is it.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
CS1Q Computer Systems Lecture 3 Simon Gay. Lecture 3CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
CS1Q Computer Systems Lecture 9 Simon Gay. Lecture 9CS1Q Computer Systems - Simon Gay2 Addition We want to be able to do arithmetic on computers and therefore.
Chapter 1 Basic Structure of Computers. Chapter Outline computer types, structure, and operation instructions and programs numbers, arithmetic operations,
COMP2011 Assembly Language Programming and Introduction to WRAMP.
Introduction to Computer Architecture and System
CISC105 General Computer Science Class 1 – 6/5/2006.
CS1Q Computer Systems Lecture 14 Simon Gay. Lecture 14CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
Introduction to Programming Using C Introduction to Computer Programming.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Computers organization & Assembly Language Chapter 0 INTRODUCTION TO COMPUTING Basic Concepts.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
Von Neumann Machine Objectives: Explain Von Neumann architecture:  Memory –Organization –Decoding memory addresses, MAR & MDR  ALU and Control Unit –Executing.
Computer Organization - 1. INPUT PROCESS OUTPUT List different input devices Compare the use of voice recognition as opposed to the entry of data via.
Computer Architecture And Organization UNIT-II General System Architecture.
Execution of an instruction
CHAPTER 4 The Central Processing Unit. Chapter Overview Microprocessors Replacing and Upgrading a CPU.
Computer Organization & Assembly Language © by DR. M. Amer.
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Electronic Analog Computer Dr. Amin Danial Asham by.
What is a Microprocessor ? A microprocessor consists of an ALU to perform arithmetic and logic manipulations, registers, and a control unit Its has some.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
The Computer System.
Lecture 7: Overview Microprocessors / microcontrollers.
Department of Electronic & Electrical Engineering Introduction to microcontrollers A microcontroller is a small computer on a single integrated circuit.
Simple ALU How to perform this C language integer operation in the computer C=A+B; ? The arithmetic/logic unit (ALU) of a processor performs integer arithmetic.
CBP 2002ITY 270 Computer Architecture1 Module Structure Whirlwind Review – Fetch-Execute Simulation Instruction Set Architectures RISC vs x86 How to build.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Hardware Information Created by Nasih 1. Hardware  The physical components of a computer system, including any peripheral equipment such as printers,
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
1 3 Computing System Fundamentals 3.2 Computer Architecture.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
CHAPTER 2 Instruction Set Architecture 3/21/
Popular Microcontrollers and their Selection by Lachit Dutta
Control Unit Lecture 6.
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Computer Architecture
Introduction to Microprocessor Programming
Introduction to Computer Systems
Chapter 4 The Von Neumann Model
Presentation transcript:

CS1Q Computer Systems Lecture 3 Simon Gay

Lecture 3CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed computing Application on a single computer Operating System Architecture Digital Logic Electronics Physics How do we design a machine that can execute programs?

Lecture 3CS1Q Computer Systems - Simon Gay3 Structure of a Computer CPU MEM- ORY DIS- PLAY DISK more... buses CPU - Central Processing Unit; microprocessor; e.g. Pentium 4 Peripherals - display, disk, keyboard, modem, printer, … Disk - larger, slower and more permanent than memory Buses - pathways for information

Lecture 3CS1Q Computer Systems - Simon Gay4 CPU Architecture The CPU is in control. It executes individual instructions. The CPU does not execute Python statements directly. The CPU has its own machine language which is simpler, but general enough that programs in Python (or other languages) can be translated into it. Why? –The CPU does not force the use of any one high-level language. –It’s more efficient to design and manufacture a general- purpose machine, rather than one for each language.

Lecture 3CS1Q Computer Systems - Simon Gay5 Which CPU? A wide variety of CPUs are in use today: –The Intel family (486, Pentium, Pentium 2, P3, P4,…) popular in desktop computers –The 64-bit Intel family (Itanium) popular in high-performance workstations and servers –The PowerPC range was used in Apple computers: iMac, PowerBook, etc –The ARM range used in handheld computers, embedded systems –DSP (digital signal processors), integrated microcontrollers,... Most of the world’s CPUs are not in PCs!

Lecture 3CS1Q Computer Systems - Simon Gay6 How many CPUs do you think you are carrying today? None One Two Three Four or more

Lecture 3CS1Q Computer Systems - Simon Gay7 Personal CPUs You might be carrying any of the following devices, which all contain CPUs: Laptop computer Mobile telephone Pocket PC / Palm etc MP3 player GPS receiver Calculators and watches probably don’t contain a CPU in this sense. They are usually not built around a programmable general-purpose CPU – instead they have a special-purpose circuit.

Lecture 3CS1Q Computer Systems - Simon Gay8 The IT Machine A simplified CPU, whose design shares many features of modern real CPUs. We can understand its operation in detail, without getting bogged down in complexity. We have a software emulator, so we can run programs in the lab. We’ll compare the IT machine with some real CPU designs later.

Lecture 3CS1Q Computer Systems - Simon Gay9 Registers: The ITM’s Variables The ITM has 16 registers, which are like Python variables. Each register can store a 16 bit value. Their names are R0 - Rf. LDVAL and ADD instructions allow basic calculations. R1 := 1; R2 := 2; R3 := R1 + R2; LDVAL R1,$0001 LDVAL R2,$0002 ADD R3,R1,R2 combination of addition and assignment an immediate value (Register R0 always stores the value 0 and cannot be changed.)

Lecture 3CS1Q Computer Systems - Simon Gay10 Working with Registers Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 13 R2 -2 R3 0 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 13 R2 -2 R3 11 ADD R3,R1,R2 ALU

Lecture 3CS1Q Computer Systems - Simon Gay11 The ALU The Arithmetic and Logic Unit is a subsystem of the CPU. The ALU carries out operations such as addition, subtraction, comparisons, … when required by instructions such as ADD.

Lecture 3CS1Q Computer Systems - Simon Gay12 Memory The registers are not sufficient for storing large amounts of data. So the ITM has memory. The memory is like an array of 16 bit words. Each location (element) has an address (index). The ITM is a 16 bit machine, so a memory address is a 16 bit word. Therefore the maximum memory size is words. As well as storing data, the memory stores the instructions which make up a program. In practice, (most of) the memory is outside the CPU.

Lecture 3CS1Q Computer Systems - Simon Gay13 Assembly Language and Machine Language Instructions such as ADD R3,R1,R2 are in assembly language. Assembly language is a human-readable form of machine language. Machine language is a binary representation of instructions. ADD R3,R1,R It is the machine language form which is stored in memory. assembly language machine language (binary) machine language (hex)

Lecture 3CS1Q Computer Systems - Simon Gay14 The Stored Program Computer Storing the program in memory, in the same way as data, is one of the most important ideas in computing. It allows great flexibility, and means that programs which manipulate programs (e.g. compilers) are conceptually no different from programs which manipulate data.

Lecture 3CS1Q Computer Systems - Simon Gay15 Execution of a Program Instructions are executed in sequence, starting with the instruction in memory location 0. A special register, the program counter (PC), stores the address of the instruction being executed. R1 := 5; R2 := 3; R3 := 2*R1 + R2; LDVAL R1,$0005 LDVAL R2,$0003 LDVAL R4,$0002 MUL R5,R1,R4 ADD R3,R5,R2 Example:

Lecture 3CS1Q Computer Systems - Simon Gay16 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 13 R2 -2 R3 0 Registers Memory AddressContents c b a f e d ALU 0000 PC LDVAL R1,$0005 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay17 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 5 R2 -2 R3 0 Registers Memory AddressContents c b a f e d ALU 0000 PC LDVAL R1,$0005 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay18 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 5 R2 -2 R3 0 Registers Memory AddressContents c b a f e d ALU 0002 PC LDVAL R2,$0003 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay19 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 0 Registers Memory AddressContents c b a f e d ALU 0002 PC LDVAL R2,$0003 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay20 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 134 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 0 Registers Memory AddressContents c b a f e d ALU 0004 PC LDVAL R4,$0002 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay21 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 2 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 0 Registers Memory AddressContents c b a f e d ALU 0004 PC LDVAL R4,$0002 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay22 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 -56 R4 2 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 0 Registers Memory AddressContents c b a f e d ALU 0006 PC MUL R5,R1,R4 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay23 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 10 R4 2 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 0 Registers Memory AddressContents c b a f e d MUL ALU 0006 PC MUL R5,R1,R4 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay24 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 10 R4 2 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 0 Registers Memory AddressContents c b a f e d ALU 0007 PC ADD R3,R5,R2 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay25 Rd 0 Rc 0 Rb -600 Ra 1254 R9 1 R8 0 R7 0 R6 2 R5 10 R4 2 Rf -5 Re 3 R0 0 R1 5 R2 3 R3 13 Registers Memory AddressContents c b a f e d ADD ALU 0007 PC ADD R3,R5,R2 Instruction

Lecture 3CS1Q Computer Systems - Simon Gay26 Assembly Language Programming It is rarely necessary to program in assembly language. Assembly language programs are produced by systematic (and automatic) translation of programs in high level languages (e.g. Python). We will look at how some common high level constructs are translated. Compiler writers must understand assembly language. CPUs are designed with compilers in mind.

Lecture 3CS1Q Computer Systems - Simon Gay27 Using Memory To use the memory, we must refer to an address. In assembly language we can use a label instead of a numerical address. A label is just a name, similar to a variable name in Python. LOAD R3, x[R0] any register label of memory location explain later If we think of the label x as the name of a variable (the value of this variable is stored in the memory location labelled by x) this means: R3 := x;

Lecture 3CS1Q Computer Systems - Simon Gay28 Writing to Memory The instruction STORE, with a similar format to LOAD, changes the contents of a memory location. STORE R3, x[R0] any register label of memory location explain later Again thinking of x as the name of a variable, this means: x := R3;

Lecture 3CS1Q Computer Systems - Simon Gay29 Example We can translate a fragment of Python code into assembly language: x := 5; y := 3; z := 2*x + y; Declare the labels x, y, z, initialising the variables to 0: xDATA$0000 yDATA$0000 zDATA$0000 DATA is not a machine language instruction. It just tells the assembler (which translates assembly language to machine language) to allocate space in memory.

Lecture 3CS1Q Computer Systems - Simon Gay30 Example Now translate the Python statements. We need to use registers, because only the LOAD and STORE instructions can access memory. LDVALR6, $0005 STORER6, x[R0] LDVALR6, $0003 STORER6, y[R0] LOADR1, x[R0] LOADR2, y[R0] LDVALR4, $0002 MULR5, R1, R4 ADDR3, R5, R2 STORER3, z[R0] x := 5; y := 3; R1 := x; R2 := y; R5 := x*2; R3 := x*2+y; z := x*2+y;

Lecture 3CS1Q Computer Systems - Simon Gay31 A Complete Program LDVALR6, $0005 STORER6, x[R0] LDVALR6, $0003 STORER6, y[R0] LOADR1, x[R0] LOADR2, y[R0] LDVALR4, $0002 MULR5, R1, R4 ADDR3, R5, R2 STORER3, z[R0] CALLexit[R0] xDATA$0000 yDATA$0000 zDATA$0000 stops execution

Lecture 3CS1Q Computer Systems - Simon Gay32 Program and Data in Memory c b a f e d e fffd x y z These locations are data, not part of the program. CALL exit[R0] LOAD R2, y[R0] calculated by the assembler some instructions are only one word long

Lecture 3CS1Q Computer Systems - Simon Gay33 Have we seen enough assembly language for general-purpose programming? Yes No Don't know

Lecture 3CS1Q Computer Systems - Simon Gay34 Optimizations There are ways of improving this program by making it shorter. Compilers use a variety of techniques to produce optimized (as good as possible) code. We won’t worry about this issue - we’ll just concentrate on a straightforward and systematic translation of simple Python statements into assembly language.

Lecture 3CS1Q Computer Systems - Simon Gay35 Which format do you prefer for handouts? Two slides per page Four slides per page Six slides per page