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

Instruction Set Design
Topics covered: CPU Architecture CSE 243: Introduction to Computer Architecture and Hardware/Software Interface.
Chapter 2 Machine Language.
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,
EEE226 MICROPROCESSORBY DR. ZAINI ABDUL HALIM School of Electrical & Electronic Engineering USM.
Processor System Architecture
INTRODUCTION OF COMPUTER
Computer Architecture and Data Manipulation Chapter 3.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Stored Program Concept: The Hardware View
Chapter 4 Processor Technology and Architecture. Chapter goals Describe CPU instruction and execution cycles Explain how primitive CPU instructions are.
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.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Computer Organization and Assembly language
COM181 Computer Hardware Ian McCrumRoom 5B18,
Computer Architecture and Organization
BLOCK DIAGRAM OF COMPUTER
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
Computer Organization
C.S. Choy95 COMPUTER ORGANIZATION Logic Design Skill to design digital components JAVA Language Skill to program a computer Computer Organization Skill.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
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.
COMP2011 Assembly Language Programming and Introduction to WRAMP.
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.
Data manipulation, Part one Introduction to computer, 2nd semester, 2010/2011 Mr.Nael Aburas Faculty of Information.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
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.
CS 111 – Sept. 15 Chapter 2 – Manipulating data by performing instructions “What is going on in the CPU?” Commitment: –Please read through section 2.3.
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.
ACOE2511 Assembly Language for the 80X86/Pentium Intel Microprocessors Lecturer: Dr. Konstantinos Tatas.
Lecture 7: 9/17/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
CS1Q Computer Systems Lecture 3 Simon Gay. Lecture 3CS1Q Computer Systems - Simon Gay2 Where we are Global computing: the Internet Networks and distributed.
ECEG-3202 Computer Architecture and Organization Chapter 7 Reduced Instruction Set Computers.
1.4 Representation of data in computer systems Instructions.
Electronic Analog Computer Dr. Amin Danial Asham by.
MICROOCESSORS AND MICROCONTROLLER:
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.
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/
ASSEMBLY LANGUAGE PROGRAMMING. Course Objectives Identify the major component of a PC-based system, describe the steps involving in assembling, linking,
Control Unit Lecture 6.
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Computer Architecture
Introduction to Microprocessor Programming
A Level Computer Science Topic 5: Computer Architecture and Assembly
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 Memory - stores both programs and data 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 Ada statements directly. The CPU has its own machine language which is simpler, but general enough that programs in Ada (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 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 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 Gay7 Registers: The ITM’s Variables The ITM has 16 registers, which are like Ada 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 Gay8 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 Gay9 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 Gay10 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 Gay11 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 Gay12 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 Gay13 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 Gay14 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 Gay15 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. Ada). 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 Gay16 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 Ada. 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 Gay17 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 Gay18 Example We can translate a fragment of Ada 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 Gay19 Example Now translate the Ada 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 Gay20 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 Gay21 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 Gay22 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 Ada statements into assembly language.