Microprocessors Quiz 5 - Boise State University ECE 332, Quizzes of Microprocessors

The fifth quiz for the microprocessors course at boise state university's department of electrical and computer engineering. The quiz includes two parts: the first part asks students to show the outputs generated by a given program, and the second part asks students to explain the role of certain registers and the purpose of interrupt service routines (isr).

Typology: Quizzes

Pre 2010

Uploaded on 09/17/2009

koofers-user-laf
koofers-user-laf ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1 of 2
Boise State University
Department of Electrical and Computer Engineering
ECE 332 Microprocessors, Quiz 5 โ€“ October 3, 2007 (this is a 30 points quiz)
Name: ______________________________
1. Show the outputs generated by this program.
#include <stdio.h>
#define COUNT 2
unsigned int i=0;
void f2() { i++; }
unsigned int f1(unsigned int x, unsigned int y)
{
static count = 0;
count++;
f2();
printf("count = %d\n", count);
return (x+y);
}
int main(void)
{
unsigned int i=1;
i++;
{
unsigned int i, sum=0;
for (i=0;i<COUNT;i++) {
sum = f1(i,i+1);
printf(" i = %d\n", i);
}
printf(" i = %d\n", i);
}
printf(" i = %d\n", i);
}
Output:
count = 1
i = 0
count = 2
i = 1
i = 2
i = 2
pf2

Partial preview of the text

Download Microprocessors Quiz 5 - Boise State University ECE 332 and more Quizzes Microprocessors in PDF only on Docsity!

1 of 2

Boise State University

Department of Electrical and Computer Engineering

ECE 332 Microprocessors, Quiz 5 โ€“ October 3, 2007 ( this is a 30 points quiz )

Name: ______________________________

1. Show the outputs generated by this program.

#include <stdio.h>

#define COUNT 2 unsigned int i=0;

void f2() { i++; }

unsigned int f1(unsigned int x, unsigned int y) { static count = 0;

count++; f2(); printf("count = %d\n", count); return (x+y); }

int main(void) { unsigned int i=1; i++; { unsigned int i, sum=0; for (i=0;i<COUNT;i++) { sum = f1(i,i+1); printf(" i = %d\n", i); } printf(" i = %d\n", i);

} printf(" i = %d\n", i); }

Output:

count = 1

i = 0

count = 2

i = 1

i = 2

i = 2

2 of 2

2. Explain the role of registers ctl0, ctl1, ctl3, and ctl4.

ctl0 โ€“ only one-bit is used, the PIE bit determine whether the processor will accept interrupt.

ctl1 โ€“ a copy of ctl0 is saved to ctl1 when an exception occurred.

ctl3 โ€“ show which hardware irq has been enable

ctl4 โ€“ show what irq is outstanding

3. What is the purpose of ISR?

ISR โ€“ interrupt service routine. The objective of ISR is to service interrupt.

4. Write an assembly program to sum the following numbers.

VCOUNT: .word 8 VALUES: .word 2,3,5,7,11,13,17,

movia r5,VCOUNT # address of value count

ldw r3,0(r5) # value count

movia r7,VALUES # address of values

movi r2,0 # zero counter

movi r4,0 # zero sum

loop:

beq r2,r3,loop_end

ldw r6,0(r7) # get value

add r4,r4,r6 # add to sum

addi r2,r2,

addi r7,r7,

br loop