Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP2121: Microprocessors and Interfacing

Similar presentations


Presentation on theme: "COMP2121: Microprocessors and Interfacing"— Presentation transcript:

1 COMP2121: Microprocessors and Interfacing
Final Exam Lecturer: Hui Wu Session 2, 2017

2 Final Exam Fri 17/11/2011 13:45, Centennial Room Randwick Racecourse.
2 hours. Closed book. 60% of the final marks.

3 Scope of Final Exam Topics not examinable:
Introduction to digital circuits Floating point numbers Serial input and output Analog input and output

4 Structure of Final Exam
Two Parts: Part I: Basic Concepts (50 marks) 6 questions. Part II: AVR Assembly Programming (50 marks) 3 questions First one compulsory Do either the second or the third

5 Sample Questions of Part I (1/8)
Consider the following program: ldi r0, 1 clr r1 clr r2 clr r3 loop: cpi r0, 201 breq end add r2, r0 adc r3, r1 inc r0 jmp loop end: nop

6 Sample Questions of Part I (2/8)
If the program is executed on an AVR microcontroller with a clock frequency of 8 MHz, what is its execution time?

7 Sample Questions of Part I (3/8)
Consider the following AVR assembly code. ldi r10, low(-1) ldi r11, high(-1) ldi r20, low(0x500) ldi r21, high(0x500) cp r10, r20 cpc r11, r21 brge comp2121 clr r16 rjmp end comp2121: ldi r16, 1 end: nop

8 Sample Questions of Part I (4/8)
Assume that the address of the instruction “ ldi r10, low(-1)” is 0x0202. After the above sequence of code is executed, what are the contents in r10, r11, r20, r21 and r16, respectively?

9 Sample Questions of Part I (5/8)
A C program consists of five functions. Their calling relations are shown as follows (the arguments and irrelevant C statements are omitted). int main(void) { func1(…); func2(…); }

10 Sample Questions of Part I (6/8)
int func1(…) { func1(…); } int func2(…) func3(…); func4(…);

11 Sample Questions of Part I (7/8)
func1() is a recursive function and calls itself 15 times for the actual parameters given in main(). Both func3() and func4() do not call any function. The sizes of all stack frames are shown as follows. main(): bytes. func1(): 100 bytes. func2(): 400 bytes. func3(): 1,400 bytes func4(): 300 bytes How much stack space is needed to execute this program correctly?

12 Sample Questions of Part I (8/8)
Consider the following keypad design for a toy. The keypad has only two keys. 10 symbols 0, 1, …, 9 need to be generated via the two keys. Give an encoding scheme such that the 10 symbols can be generated via the two keys, and explain how each symbol is generated.

13 Sample Questions of Part II (1/3)
Write an AVR assembly program to find the maximum value of a one-dimensional integer array A. Assume that the array A has 30 elements and each element is 2-byte long. Your program must store the array A in the data memory. Assume that A has been initialized. Therefore, your program does not need to initialize it.

14 Sample Questions of Part II (2/3)
Write an AVR assembly program to implement the following C program. int sum(int n); int main(void) { int n=100; sum(n); return 0; }

15 Sample Questions of Part II (3/3)
int sum(int n) { if (n<=0) return 0; else return (n+ sum(n-1)); } All local variables and parameters must be stored in the stack space. You need to choose a proper size for n and describe the stack frame structure using a diagram.


Download ppt "COMP2121: Microprocessors and Interfacing"

Similar presentations


Ads by Google