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

Similar documents
CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT 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 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 COMPUTER SCIENCES DEPARTMENT 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. Instructor: Rahul Nayar TAs: Mohit Verma, Annie Lin

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

Midterm 2 Review Chapters 4-16 LC-3

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

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

CS 135: Computer Architecture I

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

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

UNIVERSITY OF WISCONSIN MADISON

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

CIT 593: Intro to Computer Systems Homework #4: Assembly Language Due October 18, 2012, 4:30pm. Name

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

Chapter 7 Assembly Language. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University

Assembly Language. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

appendix a The LC-3 ISA A.1 Overview

ECE 109 Sections 602 to 605 Final exam Fall December, 2007

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

Computing Layers. Chapter 7 Assembly Language

Chapter 7 Assembly Language

UNIVERSITY OF WISCONSIN MADISON

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

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

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

Register Files. Single Bus Architecture. Register Files. Single Bus Processor. Term Project: using VHDL. Accumulator based architecture

That is, we branch to JUMP_HERE, do whatever we need to do, and then branch to JUMP_BACK, which is where we started.

Chapter 9 TRAP Routines and Subroutines

Chapter 5 - ISA. 1.The Von Neumann Model. The Stored Program Computer. Von Neumann Model. Memory

University of Illinois at Urbana-Champaign First Midterm Exam, ECE 220 Honors Section

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

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

Lec-memMapIOtrapJSR SYS_BUS

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

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

LC-3 Subroutines and Traps. (Textbook Chapter 9)"

LC-3 Assembly Language

Chapter 9 TRAP Routines and Subroutines

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

Input & Output. Lecture 16. James Goodman (revised by Robert Sheehan) Computer Science 210 s1c Computer Systems 1 Lecture Notes

Chapter 9 TRAP Routines and Subroutines

LC-3 TRAP Routines. Textbook Chapter 9

System Calls. Chapter 9 TRAP Routines and Subroutines

TRAPs and Subroutines. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

1/17/2018. Task: Print a Number in Binary. ECE 220: Computer Systems & Programming. First Step: Break the Task into a Sequence of Two

Chapter 4 The Von Neumann Model

CS 2461: Computer Architecture I

LC-3 Input and Output

LC-3 Input and Output

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

ECE Homework 8

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

Memory Usage in Programs

8.1 I/O Basics Device Registers. chapter

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

COSC121: Computer Systems: Review

Subroutines & Traps. Announcements. New due date for assignment 2 5pm Wednesday, 5May

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

I/O. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

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

LC-2 Programmer s Reference and User Guide

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

Chapter 8 I/O. Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. But where does data in memory come from?

LC-3 Architecture. (Ch4 ish material)

Routines and Subroutines

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

Chapter 4 The Von Neumann Model

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

1/30/2018. Conventions Provide Implicit Information. ECE 220: Computer Systems & Programming. Arithmetic with Trees is Unambiguous

Assembly Language. 7.1 Assembly Language Programming Moving Up o Level. chapter

Syntax of LC-3 assembly: Language elements. Instructions

11/10/2016. Review the Problem to Be Solved. ECE 120: Introduction to Computing. What Shall We Keep in the Registers? Where Are the Pieces in Memory?

Assembly Language. 7.1 Assembly Language Programming Moving Up o Level. chapter

Our Simulation Equivalent: -- readmemb( "os.bin" ) -- PC <== x0200

11/16/2016. Review Our Process for Programming. ECE 120: Introduction to Computing. A Typical Programming Process. Can a Computer Help Us Program?

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

컴퓨터개념및실습. 기말고사 review

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

Chapter 8 I/O. Computing Layers. I/O: Connecting to Outside World. I/O: Connecting to the Outside World

LC-3 Instruction Set Architecture

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

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

Instruction Set Architecture

Chapter 6 Programming the LC-3

Homework 06. Push Z Push Y Pop Y Push X Pop X Push W Push V Pop V Push U Pop U Pop W Pop Z Push T Push S

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

Chapter 8 Input/Output

Lab 1. Warm-up : discovering the target machine, LC-3

Fill in your name, section, and username. DO NOT OPEN THIS TEST UNTIL YOU ARE TOLD TO DO SO.

CSE 351 Midterm - Winter 2015

Implementing Functions at the Machine Level

Name: University of Michigan uniqname: (NOT your student ID number!)

Input/Output Interfaces: Ch

Transcription:

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON Prof. Mark D. Hill & Prof. Parmesh Ramanathan TAs Kasturi Bidarkar, Ryan Johnson, Jie Liu, & Ramachandran Syamkumar Midterm Examination 4 In Class (50 minutes) Friday, December 11, 2009 Weight: 15% CLOSED BOOK, NOTE, CALCULATOR, PHONE, & COMPUTER. The exam in two-sided and has THIRTEEN pages, including one blank page and a copy of the Standard ASCII Table, some Trap Service Routines description and the LC-3 Instruction Set handout on the final page (please feel free to detach this final page). Plan your time carefully, since some problems are longer than others. NAME: SECTION: ID#:

Problem Number Maximum Points Points Awarded 1 6 2 8 3 2 4 7 5 4 6 3 Total 30

Problem 1: Assembly Language A) (2 Point) Circle which (if any) of the following pseudo-ops can be used multiple times in a single assembly file:.orig.fill.blkw.stringz.end B) (1 Point) How many memory locations are used by the following assembly directive:.stringz Football 9 C) (3 Points) Briefly explain the three assembly errors in the following program:.orig x3000 INIT AND R1, R1, #0 ADD R1, R1, #32 ADD ADD R1, R1, #-1 BRnz ADD HALT INIT.BLKW 1.END 1) ADD used as label 2) INIT used twice 3) 32 requires more than the 5 bit immediate field

Problem 2: Two-Pass Assembly Process An assembly language LC-3 program is given below: ; ; Program to multiply a number by the constant 6 ;.ORIG x3010 LD R1, SIX LD R2, NUMBER AND R3, R3, #0 ; Clear R3. It will contain the product. ; The inner loop AGAIN ADD R3, R3, R2 ADD R1, R1, #-1 ; R1 keeps track of the iteration. BRp AGAIN HALT NUMBER.BLKW 1 SIX.FILL x0006.end A) (4 points) Fill in the symbol table created by the first pass of the assembler on the above program: Symbol Name Address SIX NUMBER AGAIN x3018 x3017 x3013

The binary version of the above assembly file created after the second pass of the assembler is given below (with 4 lines missing): a. b. 0010 0100 0000 0101 ;LD R2, NUMBER 0101 0110 1110 0000 ;AND R3, R3, #0 0001 0110 1100 0010 ;ADD R3, R3, R2 0001 0010 0111 1111 ;ADD R1, R1, #-1 0000 0011 1111 1101 ;BRp AGAIN c. 0000 0000 0000 0000 ;NUMBER.BLKW 1 d. B) (4 points) Circle the correct values to fill in for the missing lines: a: 1) 0011 0000 0001 0000 2) 0010 0010 0000 1000 3) 0011 0000 0101 0000 b: 1) 0011 0000 0000 0000 2) 0010 0010 0000 0111 3) 0010 0010 0000 1000 c: 1) 1101 0000 0000 0110 2) 1100 0001 1100 0000 3) 1111 0000 0010 0101 d: 1) 0000 0000 0000 0110 2) 0000 0000 0000 0000 3) 1111 1111 1111 1111

Problem 3: Trap Routines (2 points) How many TRAP service routines can be defined on the LC-3? Why? 256, because TRAP = 11110000 Trapvect8, 2^8 = 256 Problem 4: I/O Suppose we modify the LC-3 ISA to use the opcode 1101 for I/O operations. The assembly instruction is written as: IO <Command>. We define the following commands: Assembly Binary Function IO 0 1101 0000 0000 0000 Check KBSR, set flags to N if ready, Z if not ready IO 1 1101 0000 0000 0001 Load R0 with the contents of KBDR IO 2 1101 0000 0000 0010 Check DSR, set flags to N if ready, Z if not ready IO 3 1101 0000 0000 0011 Load DDR with the contents of R0 Remember: KBSR - Bit[15] is 1 if keyboard has data to be read, else 0 KBDR - Contains keyboard data to be read DSR - Bit[15] is 1 if monitor is ready to accept data for output DDR - Register that accepts data for output to the monitor A) (1 point) Circle the correct combination that describes this modified LC-3 system: a. Memory mapped and interrupt driven b. Special opcode for I/O and interrupt driven c. Memory mapped and polling d. Special opcode for I/O and polling

The following is an LC-3 assembly program which uses the modified ISA:.ORIG x3000 LD R0, ASCII LD R1, NEG LOOP IO 2 BRzp LOOP IO 3 ADD R0, R0, #-1 ADD R3, R0, R1 BRp LOOP HALT ASCII.FILL x0047 NEG.FILL xffbd.end B) (3 points) What is the output of the program on the LC-3 display? GFED C) (3 points) Briefly explain why is it important to call IO 0 each time before calling IO 1: Need to ensure a valid character exists in they keyboard data register or IO 1 may return corrupted data.

Problem 5: Subroutines Consider the following LC-3 assembly program (assume the SAVERX labels are correctly defined elsewhere):.orig x3000 ST R0, SAVER0 ST R1, SAVER1 JSR SUB1 LD R0, SAVER0 LD R1, SAVER1 HALT SUB1 ST R7, SAVER7 ST R3, SAVER3 ST R2, SAVER2 JSR SUB2 CHECK1 AND R1, R1, #0 LD R7, SAVER7 LD R3, SAVER3 LD R2, SAVER2 RET SUB2 AND R0, R0, #0 CHECK2 RET A) (1 point) What is the value of R7 at CHECK1? x300a B) (1 point) What is the value of R7 at CHECK2? x300a C) (1 point) Which registers are caller saved? R0, R1 D) (1 point) Which registers are callee saved? R2, R3, R7

Problem 6: Halting Problems (1 point each) Mark statements as True or False. T / F : Given enough time, it is possible to write a program that determines whether any possible program halts (does not loop forever) on a specific instance of the program's inputs. T / F : Given enough time, it is possible to write a program that determines whether any possible program halts (does not loop forever) on all of the program's possible inputs. T / F : Given enough time, it is possible to write a program to solve any problem that one can precisely specify.

Scratch Sheet (in case you need additional space for some of your answers)