QUIZ. Name all the 4 parts of the fetch-execute cycle.

Similar documents
QUIZ. Name all the 4 parts of the fetch-execute cycle.

Low-level software. Components Circuits Gates Transistors

Extra-credit QUIZ Pipelining -due next time-

Low-Level Programming Languages and Pseudocode

LOW-LEVEL PROGRAMMING LANAGUAGES AND PSEUDOCODE. Introduction to Computer Engineering 2015 Spring by Euiseong Seo

High-level software (Ch.9) Algorithms and data structures. Low-level software. Components Circuits Gates Transistors

Write "Nell" Write "N" Write "e" Write "l" Write "l" Write "N" Write 4E (hex) Write "e" W rite 65 (hex) Write "l" W rite 6C (hex)

Chapter. Assembly Language

CSC 221: Computer Organization, Spring 2009

Wednesday, March 12, 2014

Wednesday, February 7, 2018

Wednesday, February 4, Chapter 4

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

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

Monday, February 16, 2015

Monday, February 11, 2013

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

Unified Engineering Fall 2004

QUIZ: Generations of computer technology. Hardware:

Wednesday, February 15, 2017

CS 101, Mock Computer Architecture

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

Wednesday, September 13, Chapter 4

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

Introduction to Computers - Chapter 4

User. Application program. Interfaces. Operating system. Hardware

Tutorial for Chapter 3, 4

Wednesday, September 21, 2016

Copyright 2000 N. AYDIN. All rights reserved. 1

csitnepal Unit 3 Basic Computer Organization and Design

Teaching London Computing

2.2 THE MARIE Instruction Set Architecture

Laboratory. Low-Level. Languages. Objective. References. Study simple machine language and assembly language programs.

CS 105 Review Questions #3

Chapter 2. Binary Values and Number Systems

Show how to connect three Full Adders to implement a 3-bit ripple-carry adder

COSC121: Computer Systems: Review

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 2, 2016

EE 3170 Microcontroller Applications

Advanced Parallel Architecture Lesson 3. Annalisa Massini /2015

Chapter. Computer Architecture

Introduction to MiniSim A Simple von Neumann Machine

Quiz on Ch.4 is at the end of Ch.4 slides

Module 5 - CPU Design

The LC3's micro-coded controller ("useq") is nothing more than a finite-state machine (FSM). It has these inputs:

Monday, March 13, 2017

A rubric for programming assignments

QUIZ: What value is stored in a after this

COMPUTER ORGANIZATION & ARCHITECTURE

2. Computer Evolution and Performance

Dec Hex Bin ORG ; ZERO. Introduction To Computing

CS 31: Intro to Systems Digital Logic. Kevin Webb Swarthmore College February 3, 2015

QUIZ: Generations of computer technology. Hardware:

5-1 Instruction Codes

CMPS 10 Introduction to Computer Science Lecture Notes

Computer Organization CS 206 T Lec# 2: Instruction Sets

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

A Review of Chapter 5 and. CSc 2010 Spring 2012 Instructor: Qian Hu

Introduction to Computer Science. Homework 1

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Microcontroller Systems

Computer architecture Assignment 3

Lecture 5 Assembly Programming: Arithmetic

Von Neumann Architecture

Wednesday, April 22, 2015

Monday, March 9, 2015

Arab Open University. Computer Organization and Architecture - T103

the SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first.

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Wednesday, September 27, 2017

COSC121: Computer Systems: Review

Monday, October 17, 2016

Year 10 OCR GCSE Computer Science (9-1)

CMPUT 101 with Solutions Quiz 2 (50 minutes) November 16, 2000

Chapter 6 Programming the LC-3

Chapter 4. MARIE: An Introduction to a Simple Computer. Chapter 4 Objectives. 4.1 Introduction. 4.2 CPU Basics

Memory General R0 Registers R1 R2. Input Register 1. Input Register 2. Program Counter. Instruction Register

Unit II Basic Computer Organization

2010 Summer Answers [OS I]

Wednesday, April 19, 2017

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

ORG ; TWO. Assembly Language Programming

Switching to AQA from OCR

1 Little Man Computer

COS 140: Foundations of Computer Science

16.1. Unit 16. Computer Organization Design of a Simple Processor

2c. Content of Computer systems (Component 01)

Instruction Sets: Characteristics and Functions Addressing Modes

Information Science 1

CPU ARCHITECTURE. QUESTION 1 Explain how the width of the data bus and system clock speed affect the performance of a computer system.

LC-3 Assembly Language. (Textbook Chapter 7)"

Sparse Notes on an MIPS Processor s Architecture and its Assembly Language

Final Labs and Tutors

UNIT 1 REFERENCE 1 PREPARED BY S.RAVINDRAKUMAR, LECT/ECE, CHETTINAD COLLEGE OF ENGG AND TECH, KARUR

CHAPTER SIX BASIC COMPUTER ORGANIZATION AND DESIGN

UNIT-II. Part-2: CENTRAL PROCESSING UNIT

Learning objectives. Computer principles The characteristics of contemporary processors, input, output and storage devices

The MARIE Architecture

EE 3170 Microcontroller Applications

Transcription:

QUIZ Name all the 4 parts of the fetch-execute cycle. 1

Solution Name all the 4 parts of the fetch-execute cycle. 2

QUIZ Name two fundamental differences between magnetic drives and optical drives: 3

Solution Name two fundamental differences between magnetic drives and optical drives: Data is stored using magnetic properties vs. optical properties. In a HDD, the speed of rotation is constant, but in an optical drive rotation is faster on the inner tracks, resulting in Constant Linear Velocity (CLV) 4

QUIZ Define Embedded Systems 5

QUIZ What are two ways to create a non-vn architecture? What are the 3 parallel architectures we covered? 6

Solution What are two ways to create a non-vn architecture? A: By using more than one MM, or by using more than one CPU. What are the 3 parallel architectures we covered? Pipelined CPUs Synchronous CPUs Parallel (non-synchronous) CPUs 7

QUIZ Pipelining A computer pipeline has 4 processors, as shown above. Each processor takes 15 µs to execute, and each instruction must go sequentially through all 4 processors. A program has 10 instructions. Calculate how long it takes to run it: without pipelining with pipelining 8

Extra-credit QUIZ 9

Low-level software Components Circuits Gates Transistors

Abstractions and more abstractions You are here 11

6.1 Computer Operations Computer = programmable electronic device that can store, retrieve, and process data Von Neumann architecture: Data and instructions to manipulate the data are represented in the same way (binary) and are stored in the same place (memory) For processing, both data and instructions have to be brought into the CPU (fetch-execute cycle) 12

6.2 Machine Language Machine language = The language made up of binary coded instructions built into the hardware of a particular computer and used directly by the computer Why would anyone use machine language? (Hint: they had no choice. Why?) Image source: http://www.alpcentauri.info/chapter_18.html 13

Remember: The Fetch-Execute Cycle According to the CPU s machine language 14

Characteristics of machine language: Every processor type has its own set of specific machine instructions The relationship between the processor and the instructions it can carry out is completely integrated Each machine-language instruction does only one very low-level task 15

Pep/8 Virtual Computer Virtual computer A hypothetical machine designed to contain the important features of a real machine Pep/8 A virtual computer designed by Stanley Warford that has 39 machine-language instructions (We re going to cover only a few of them!) 16

Extra-credit 17

Pep/8 Registers The program counter (PC) (contains the address of the next instruction to be executed) The instruction register (IR) (contains a copy of the instruction being executed) The accumulator (register A) The memory unit is made up of 65,636 Bytes of storage Can you figure out how long the Pep/8 address is? 18

QUIZ The previous version of Pep, Pep/7, could use only 12 bits for memory addresses. How many memory cells could Pep/7 address? 19

24 bits 16 bits Explain the address format! 20

Can you show what instructions look like in memory? Explain the address format! 21

Instruction Format 22

Instruction Format Operation code, a.k.a. opcode Specifies which instruction is to be carried out Register specifier Specifies which register is to be used (only use A in this chapter) Addressing-mode specifier Says how to interpret the operand part of the instruction: Direct Immediate Say that again?!? 23

Instruction Format Addressing-mode specifier Says how to interpret the operand part of the instruction: Direct Immediate 2 + 3 Immediate A + B Direct?? 24

Immediate and direct addressing modes 25

26 QUIZ: Immediate vs. direct addressing We have this Pep instruction: SUB 30 from accumulator A What exactly will Pep subtract?

27 Solution We have this Pep instruction: SUB 30 from accumulator A What exactly will Pep subtract? A: It depends on the addressing mode! If immediate (000), then the integer 30 goes in A. If direct (001), then the content of the memory address 30 goes in A.

PEP/8 machine instructions 28

What does this instruction mean, what is its hex code, and what exactly does it do? 29 EOL 1

QUIZ Name all the 4 parts of the fetch-execute cycle. What do IR, A, and PC stand for in the computer s architecture? Name and explain the 2 addressing modes we ve covered. 30

31 QUIZ: Immediate vs. direct addressing We have this Pep instruction: LOAD 20 (decimal) into accumulator A What exactly will Pep load?

What does this instruction mean, what is its hex code, and what exactly does it do? 32

What does this instruction mean, what is its hex code, and what exactly does it do? 33

What do these instructions mean, what are their hex codes, and what exactly do they do? 34

Wait a second... 35

Conclusions It is useless to write operands into IR. IR is written only in the FETCH stage of the Fetch-Execute cycle, when the 3 bytes of the instruction are brought from memory. Operands can be written only to: Accumulator Memory Some instructions cannot have the immediate addressing mode 36

What do these instructions mean, what are their hex codes, and what exactly do they do? 37

What does this instruction mean, what is its hex code, and what exactly does it do? Why is there only one on this page?

What do these instructions mean, what are their hex codes, and what exactly do they do? 39

Problem 17 / 190 The PEP/8 memory has the following contents: 0001 A2 0002 11 0003 00 0004 FF What are the contents of reg. A after this instruction is executed: C1 00 02 The first step is 40

Problem 17 / 190 The PEP/8 memory has the following contents: 0001 A2 0002 11 0003 00 0004 FF What are the contents of reg. A after this instruction is executed: C1 00 02 1100 0001 0000 0000 0000 0010 41

Problem 16 / 189 The PEP/8 memory has the following contents: 0001 A2 0002 11 0003 00 0004 FF What are the contents of reg. A after this instruction is executed: C1 00 01 42

0001 A2 0002 11 0003 00 0004 FF Instruction executed: C1 00 01 43

6.3 Program to write "Hello" Every program ends with this! 44

Your turn! What does this program do? 1111 0000 1 0000 1111

Steps for executing a machine-language program Machine code program in a file on disk Loader Execute Program in memory 46

SKIP Pep/8 Simulator 47

Fact: Writing programs in machine language sucks! (i.e. it is time-consuming, boring, errorprone, unintuitive, etc.) 48

that s why we invented assembly language 49

6.4 Assembly Language Assembly language A language that uses mnemonic codes to represent machine-language instructions Assembler A program that reads each of the instructions in mnemonic form and translates it into the machine-language equivalent 50

Steps for executing an assembly-language program Loader 51 Execute Program in memory

Pep/8 Assembly Language Opcode is 04 Opcode is 31 Opcode is 38 Opcode is 39 52

Hello program in assembly mnemonic operand addressing mode comments CHARO CHARO CHARO CHARO CHARO STOP.END 0x0048, i ;Outputs character 'H' 0x0065, i 0x006C, i 0x006C, i 0x006F, i What in the world is this?! 53

A New Program Problem: Read and sum three values and print the sum How would you do it by hand? 54

Declaring variables in assembly: We simply reserve space in memory for them! Labels they are just placeholders for memory addresses 55

Assembler directives, a.k.a. pseudo-ops What is the difference between operations and pseudo operations? 56

Completed Program sum:.word 0x0000 num1:.block 2 num2:.block 2 num3:.block 2 main: LDA sum,d DECI num1,d ADDA num1,d DECI num2,d ADDA num2,d DECI num3,d ADDA num3,d STA sum,d DECO sum,d STOP.END 57

We have covered the beginning of section 6.4. We stopped before the sub-section A Program with Branching. Read the text carefully and make sure you can explain in your own words what each instruction accomplishes. Quick work (do in notebook for next time): 16, 17, 19, 21-26 EoHW 2 58

Problem 33 / 191 The PEP/8 memory has the following program in memory (in hex): 0001 49 0002 00 0003 08 0004 51 0005 00 0006 08 0007 00 Convert the program to binary and explain in your own words what it does. 59

Completed Program Houston, we have a problem! How does the CPU know that the program starts here? sum:.word 0x0000 num1:.block 2 num2:.block 2 Num3:.BLOCK 2 main: LDA sum,d DECI num1,d ADDA num1,d DECI num2,d ADDA num2,d DECI num3,d ADDA num3,d STA sum,d DECO sum,d STOP.END 60

Solution: Branch instruction BR main sum:.word 0x0000 num1:.block 2 num2:.block 2 num3:.block 2 main: LDA sum,d DECI num1,d ADDA num1,d DECI num2,d ADDA num2,d DECI num3,d ADDA num3,d STA sum,d DECO sum,d STOP.END See comments on next slide 61

Unconditional branch! Completed Program 62

Your turn! Change the program so it adds only two numbers: always 7 + 42 63

Decision-making instructions BR Set PC to operand unconditionally BRLT i Set PC to operand if A < 0 BREQ i Set PC to operand if A = 0 64

Decision-making problem: Same as previous sum program, but print the sum only if positive or zero; if negative, print an error message negmsg: CHARO 0x0045,i BR finish main: LDA sum,d BRLT negmsg STA sum,d DECO sum,d finish: STOP Read and add the numbers, as before What ASCII code is this? 65

Decision making problem: Same as before, but print the sum only if positive or zero; if negative, print E (Error) negmsg: CHARO 0x0045,i BR finish main: LDA sum,d BRLT negmsg STA sum,d DECO sum,d finish: STOP How many ways are there to reach finish? ASCII code for 'E'

QUIZ: What does this program do? BR main a:.block 2 main: DECI a, d LDA a, d SUBA 0x002A, i STA a, d DECO a, d STOP.END 67

Solution BR main a:.block 2 main: DECI a, d LDA a, d SUBA 0x002A, i STA a, d DECO a, d STOP.END A: It subtracts 42 from the number entered, and displays the result. 68

QUIZ: Write an assembly program to subtract 20 10 from 42 10 and put the result in memory Take inspiration from this previous program: BR main sum:.word 0x0000 num1:.block 2 num2:.block 2 num3:.block 2 main: LDA sum,d DECI num1,d ADDA num1,d DECI num2,d ADDA num2,d DECI num3,d ADDA num3,d STA sum,d DECO sum,d STOP.END 69

Three problems for more study Write a PEP assembly program that adds the number 3 to a number entered by the user, and prints : the result if equal to zero, otherwise it prints nothing. the result if less than zero, otherwise it prints nothing. the result if greater than zero, otherwise it prints nothing. 70

A Program with a Loop (p.174-5) CPA must always be followed by a conditional branch! 71

High-level software (Ch.9) Algorithms (and data structures) Low-level software Components Circuits Gates Transistors

6.5 Algorithms and Pseudocode Algorithm = A sequence of steps for solving a problem Muḥammad ibn Mūsā al-khwārizmī (780-850A.D.) 73

Remember: Decision-making instructions BR Set PC to operand unconditionally BRLT i Set PC to operand if A < 0 BREQ i Set PC to operand if A = 0 74

Not in text How to describe an algorithm in an intuitive way? Flowcharts! We use decision-making instructions to build: branches loops 75

Problems with flowcharts: They re hard to follow when they get complex Not in text 76

Problems with flowcharts: They re hard to follow when they get complex They re hard to draw in electronic documents Not in text 77

Problems with flowcharts: They re hard to follow when they get complex They re hard to draw in electronic documents Not in text Our text uses only pseudocode 78

6.5 Algorithms and Pseudocode Pseudocode = A mixture of English and formatting rules to make the steps in an algorithm explicit There are no syntax rules in pseudocode! Pseudocode is not case sensitive! Example: Repeated-division algorithm (convert base-10 number to other bases): While ( the quotient is not zero ) Divide the decimal number by the new base Make the remainder the next digit to the left in the answer Replace the original decimal number with the quotient 79

Pseudocode functionality Pseudocode has all of the concepts encountered in any high-level programming language, only the syntax is informal: Variables Assignment I/O Selection / decision Repetition / loop Boolean expressions 80

We can follow a pseudocode algorithm w/pencil & paper, a.k.a. desk checking While ( the quotient is not zero ) Divide the decimal number by the new base Make the remainder the next digit to the left in the answer Replace the original decimal number with What is 93 in base 8? 93/8 gives 11 remainder 5 11/8 gives 1 remainder 3 1/ 8 gives 0 remainder 1 answer 1 3 5 81

Organizing the solution in a computer-like way gives us better idea of what is required for the computer to execute it, e.g. two numbers need to be entered, etc. 82

SKIP 6.6 Testing 83

Read and take notes in notebook: Bio: Konrad Zuse Ethics: Software Piracy and Copyrighting Have you every "borrowed" software from a friend? Have you ever "lent" software to a friend? Did you know that about 100,000 jobs are lost in the US every year due to such "borrowing" and "lending?" 84

Homework - Due Thursday, Nov.1 End of chapter exercises: 10, 11, 12, 13, 14, 15, 18, 20 Correction in 20: use E1 instead of E0 27, 34 Hint for 34: machine code 31 means decimal input, DECI 41 - Hint: On how many bits are integers represented in Pep/8? 44, 45 Hint for 45: Very similar to the text program!

All PEP instructions, with machine codes 00 Stop STOP 04 Branch unconditional BR 08 Branch if Less Than BRLT 0A Branch if equal BREQ 31 Decimal Input Direct DECI 38 Decimal Output Immediate DECO 39 Decimal Output Direct DECO 49 Char. Input Direct CHARI 50 Char. Output Immediate CHARO 51 Char. Output Direct CHARO 70 Add to A Immediate ADDA 71 Add to A Direct ADDA 80 Subtract from A Immediate SUBA 81 Subtract from A Direct SUBA C0 Load into A Immediate LDA C1 Load into A Direct LDA E1 Store A Direct STA 86

Chapter Review Questions List the operations that a computer can perform Describe the important features of the Pep/8 virtual machine Distinguish between immediate addressing mode and direct addressing mode Write a simple machine-language program Distinguish between machine language and assembly language 87

Chapter Review Questions Describe the steps in creating and running an assembly-language program Write a simple program in assembly program Distinguish between instructions to the assembler (a.k.a. directives) and instructions to be translated into machine code (a.k.a. executable instructions) Distinguish between following an algorithm and developing one 88

Chapter Review Questions Describe the pseudocode constructs used in expressing an algorithm Use pseudocode to express and algorithm Distinguish between black-box and clear-box testing 89