Docsity

ECE 199 Exam 2 Fall 2002, Exams of Biomedical Engineering

Toggle sidebar
bg1
ECE 199 Exam 2 Fall 2002
Tuesday, November 5th, 2002
Name:
1. Be sure your exam booklet has 7 pages.
2. Write your name at the top of each page.
3. This is a closed book exam.
4. You are allowed one 8.5 x 11 sheet of notes.
5. Absolutely no interaction between students is allowed.
6. Show all of your work.
7. Don’t panic, and good luck!
Problem 1 20 points
Problem 2 20 points
Problem 3 20 points
Problem 4 20 points
Problem 5 20 points
Total 100 points
pf3
pf4
pf5

Partial preview of the text

Download ECE 199 Exam 2 Fall 2002 and more Exams Biomedical Engineering in PDF only on Docsity!

ECE 199 Exam 2 Fall 2002

Tuesday, November 5

th

Name:

1. Be sure your exam booklet has 7 pages.

2. Write your name at the top of each page.

3. This is a closed book exam.

4. You are allowed one 8.5 x 11 sheet of notes.

5. Absolutely no interaction between students is allowed.

6. Show all of your work.

7. Don’t panic, and good luck!

Problem 1 20 points

Problem 2 20 points

Problem 3 20 points

Problem 4 20 points

Problem 5 20 points

Total 100 points

Problem 1 (20 points): Short Answer

Part A. What is the purpose of the Ready bit in the Keyboard Status Register? Be brief.

Part B. What is the PC of the instruction that executes immediately after the TRAP instruction in the

code below?

.ORIG x

LD R0, DATA

STI R0, TOP

TRAP x

ADD R0, R0,

DATA .FILL x

TOP .FILL x

Part C. The following subroutine can be used to output a digit to the monitor. But it has a serious bug.

What is it?

OUTPUT ST R0, SAVE_R

ST R1, SAVE_R

LD R1, ASCII_ZERO

ADD R0, R0, R

OUT

LD R1, SAVE_R

LD R0, SAVE_R

RET

ASCII_ZERO .FILL x30 ; x30 is ASCII for zero (’0’)

SAVE_R0 .FILL x

SAVE_R1 .FILL x

Problem 3 (20 points): LC-2 to C

Provide the C statements expressed by the provided LC-2 code fragments. Use the provided C code as a

starting point for your answer.

Part A

LDR R0, R6,

LDR R1, R6,

STR R0, R6,

STR R1, R6,

main() { int v1; int v2; int temp;

Part B

LDR R0, R6,

NOT R0, R

LDR R1, R6,

NOT R1, R

AND R2, R0, R

NOT R2, R

STR R2, R6,

main() { int v3; int v4; int v5;

Part C

AND R0, R0,

ADD R0, R0,

STR R0, R6,

FL1 AND R0, R0,

STR R0, R6,

FL1_2 LDR R0, R6,

LDR R1, R6,

NOT R1, R

ADD R1, R1,

ADD R0, R0, R

BRzp DONE

F LDR R0, R6, # ADD R0, R0, # STR R0, R6, #

LDR R0, R6, # ADD R0, R0, # STR R0, R6, # BRnzp FL1_

DONE … …

main() { int i; int j; int k;

Problem 5 (20 Points): Using Functions in C

#include <stdio.h>

int Swap(int a, int b);

main() { int a; int b;

scanf(”%d”, &a); scanf(”%d”, &b);

Swap(a, b);

printf(”a = %d\n”, a); printf(”b = %d\n”, b); }

/* This function swaps the value of the two input parameters */ int Swap(int a, int b) { int x;

x = a; a = b; b = x

return x; }

Part A. If the user enters 23 45 for the input, what is the output of this program?

Part B. Suggest a way to fix this program using only the concepts described in class thus far?