ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Similar documents
ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Chapter 6 Programming the LC-3

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Annie Lin, Mohit Verma

UNIVERSITY OF WISCONSIN MADISON

appendix a The LC-3 ISA A.1 Overview

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Mohit Verma, Annie Lin

Introduction to Computer Engineering. Chapter 5 The LC-3. Instruction Set Architecture

Introduction to Computer. Chapter 5 The LC-3. Instruction Set Architecture

LC-3 Instruction Set Architecture

Intro. to Computer Architecture Homework 4 CSE 240 Autumn 2005 DUE: Mon. 10 October 2005

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

20/08/14. Computer Systems 1. Instruction Processing: FETCH. Instruction Processing: DECODE

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Annie Lin, Mohit Verma

ECE 411 Exam 1. This exam has 5 problems. Make sure you have a complete exam before you begin.

CS 2461: Computer Architecture I

ECE/CS 252 Fall 2011 Homework 4 (25 points) // Due in Lecture Mon Oct. 17, 2011

News. CSE 130: Programming Languages. Environments & Closures. Functions are first-class values. Recap: Functions as first-class values

EEL 5722C Field-Programmable Gate Array Design

Final Exam Solution Sunday, December 15, 10:05-12:05 PM

CLEMSON ALGEBRA PROJECT UNIT 4: INEQUALITIES IN TWO VARIABLES

CMU Introduction to Computer Architecture, Spring 2012 Handout 9/ HW 4: Pipelining

Trap Vector Table. Interrupt Vector Table. Operating System and Supervisor Stack. Available for User Programs. Device Register Addresses

Ch. 5: The LC-3. PC-Relative Addressing Mode. Data Movement Instructions. James Goodman!

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

Lesson 10.4 Multiplying Binomials

Chapter 5 The LC-3. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2

CS 135: Computer Architecture I

ECE 468, Fall Midterm 2

EECS1022 Winter 2018 Additional Notes Tracing Point, PointCollector, and PointCollectorTester

Mid-Term Exam Solutions

Computing Layers. Chapter 5 The LC-3

CPSC W1 University of British Columbia

Running Applications

2.2. Changing One Dimension

Load -- read data from memory to register. Store -- write data from register to memory. Load effective address -- compute address, save in register

ADD R3, R4, #5 LDR R3, R4, #5

Variables and Bindings

Graphing square root functions. What would be the base graph for the square root function? What is the table of values?

LC-3 ISA - II. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 10 February 17, 2011

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

11/6/2016. Let s Solve a Problem. ECE 120: Introduction to Computing. Overview of Our Task. Programs are Finite State Machines

Binghamton University. CS-120 Summer LC3 Memory. Text: Introduction to Computer Systems : Sections 5.1.1, 5.3

Pipelining combinational circuits

COSC121: Computer Systems: Review

ECE 204 Numerical Methods for Computer Engineers MIDTERM EXAMINATION /4:30-6:00

Introduction to Computer Engineering. CS/ECE 252 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin Madison

Pipelining combinational circuits

SI232 Set #20: Laundry, Co-dependency, and other Hazards of Modern (Architecture) Life. Chapter 6 ADMIN. Reading for Chapter 6: 6.1,

CS 2461: Computer Architecture I

Instruction Set Architecture

University of Toronto Faculty of Applied Science and Engineering Edward S. Rogers Sr. Department of Electrical and Computer Engineering

CS 270 Fall 2013 Mock Final

CPSC 311: Definition of Programming Languages: Assignment 4: Stepping

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

Outline. Definition. 2 Height-Balance. 3 Searches. 4 Rotations. 5 Insertion. 6 Deletions. 7 Reference. 1 Every node is either red or black.

Module 3 Graphing and Optimization

Cumulative Review Problems Packet # 1

EECS 3201: Digital Logic Design Lecture 4. Ihab Amer, PhD, SMIEEE, P.Eng.

Memory Usage in Programs

Programming Languages

CS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin

The Graph Programming Language GP

Dynamic Histograms for Non-Stationary Updates

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Chapter 4: Programming with MATLAB

Week 10. Topic 1 Polynomial Functions

Advanced Computer Architecture

Comparison of Communication Manager Administrator Account Management CM3.1 vs. CM4.0

10/31/2016. The LC-3 ISA Has Three Kinds of Opcodes. ECE 120: Introduction to Computing. ADD and AND Have Two Addressing Modes

COS 126 General Computer Science Fall Exam 1

Tail Recursion: Factorial. Begin at the beginning. How does it execute? Tail recursion. Tail recursive factorial. Tail recursive factorial

Section 1.5 Transformation of Functions

LC-3 Instruction Set Architecture. Textbook Chapter 5

Math 7 Notes - Unit 4 Pattern & Functions

CSE 373: Data Structures and Algorithms

I Doubt It Lesson 6-1 Transforming Functions

2.1 Transformers: Shifty y s A Develop Understanding Task

Chapter 3 Path Optimization

Department of Electrical and Computer Engineering The University of Texas at Austin

Recap. Recap. If-then-else expressions. If-then-else expressions. If-then-else expressions. If-then-else expressions

Side note: Tail Recursion. Begin at the beginning. Side note: Tail Recursion. Base Types. Base Type: int. Base Type: int

COSC121: Computer Systems: Review

Transcription:

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar S. Sohi TAs: Newsha Ardalani and Rebecca Lam Midterm Eamination 3 In Class (5 minutes) Friday, November 8, 2 Weight: 7.5% NO: BOOK(S), NOTE(S), CALCULATORS OF ANY SORT. This eam has pages, including one page for the LC3 Instruction Set and two blank pages at the end. Plan your time carefully, since some problems are longer than others. You must turn in pages through 7. LAST NAME: FIRST NAME: SECTION: ID#

Problem Maimum Points Actual Points 2 2 4 3 6 4 6 5 6 6 6 Total 3 2

Problem (2 Points) When a computer eecutes an instruction, the state of the computer is changed as a result of that eecution. Is there any difference in the state of LC-3 computer as a result of eecuting instruction below vs eecuting instruction 2 below? Eplain. We can assume the state of the LC-3 computer before eecution is the same in both cases. Instruction : ; R <- R + # Instruction 2: ; Branch to incremented PC if any of P, Z or N is set Instruction sets the condition code but instruction 2 does not. Problem 2 (4 Points) A program wishes to load a value from memory into R, and based on the value loaded into R, eecutes code starting at 36 if the value loaded is positive, eecutes code starting at 33 if the value is negative, or eecutes code starting at location 33 if the value loaded is zero. The first instruction of this program (load a value into R) is shown at address 3. Your job: Write the instructions for locations 3 and 32. ADDRESS INSTRUCTION COMMENT 3 Load a value from memory location 3 into R 3 32 or or BRp 36 or BRn 33 Brn 33 or Brp 36 Problem 3 (6 Points) 3

Answer the following short answer questions with no more than 4 sentences each. a. ( point) ( point) Suppose the number of opcodes for the LC-3 increases to 32. If the instruction size stays the same, how is the range of addresses that BR instruction can branch to affected? log2(32) = 5 so our opcode field epands by bit. This means that our PCoffset becomes 8 bits, meaning the PCoffset range becomes -2 8- to 2 8- -. Thus we can branch to PC + 2 7 to PC + 2 7 b. ( point) Suppose the number of registers for the LC-3 is decreased by half. If the instruction size stays the same, how is the NOT instruction changed? If we decrease the number of registers in the LC-3 then we will need less bit per register field. This means our DR and SR fields will be 2 bits long, so we will have two additional unused bits for the NOT instruction. c. (2 points) Write two of the three constructs that comprise the systematic decomposition model and define them. Sequential: Do task and then task 2 Conditional: If the condition is true do task, else do task 2 Iterative: Do a task repeatedly while condition is true d. (2 points) Write two of the three different types of program errors and define them. Synta: Typing error that results in an illegal operation Logic: Program is legal, but results don t match the problem statement Data: Input data is different from what is epected 4

Problem 4 (6 Points) An LC-3 program is located in memory locations 3 to 36. It starts eecuting at 3. If we keep track of all values loaded into the MAR as the program eecutes, we will get a sequence that starts as follows. Such a sequence is referred to as a trace. MAR Trace 3 35 3 32 36 4 33 2 We have shown below some of the bits stored in locations 3 to 36. Your job is to fill in each blank space with a or, as appropriate. 3 3 32 33 34 35 36 5

Problem 5 (6 Points) Given the following LC-3 program, epress the final value of R in terms of the initial value of R2 after eecution of the last instruction. Show comments for each line. ADDRESS INSTRUCTION COMMENT 3 R3 = R3 AND 3 R3 = R3 + 7 = 7 32 R = R2 + 33 R = R + R (Begin loop) At end of loop, R = R2 << 7 34 R3 = R3-35 If R3 >, branch to 33 36 R2 = NOT (R2) 37 R = R + NOT(R2) 38 HALT R = R2 << 7 + NOT(R2) or R = R2 * 2 7 + NOT(R2) 6

Problem 6 (6 points) Suppose we wish to write a program that performs a deletion of one element from a list of elements sorted in descending order without duplicates, where the element to be deleted is stored in R. The program works as follows: Knowing that the element to be deleted is in R, we load the first value of the list into R2. If the value of R2 is greater than R, we load the net value in the list into R2, and we keep doing this while R2 is greater than R. If the value of R2 is less than R, we halt the program. If the value of R2 is equal to R, we load the net value in the list into the memory location that R2 used to be in. And we keep doing this for the rest of the list. Eample: The following table shows the list before and after 3 is deleted from the list Address Initial Value Final Value 45 6 6 45 5 5 452 4 4 453 3 2 454 2 455 unknown Fill in the si missing blanks in the following flow chart. 7