4 Questions on Microprocessor Systems - Midterm 1 | CPEG 222, Exams of Microprocessors

Material Type: Exam; Class: Microprocessor Systems; Subject: Computer Engineering; University: University of Delaware; Term: Spring 2005;

Typology: Exams

Pre 2010

Uploaded on 09/02/2009

koofers-user-f5n
koofers-user-f5n 🇺🇸

10 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPEG 222 - MICROPROCESSOR BASED SYSTEMS Name:
Spring 2005 - Jorge Andres Garcia - Midterm 1
1. (35pts/25min) Analyzing and fixing a piece of code
(i) (5pts/5min) Comment the following code. Only sensible comments are welcome
LINE LABEL INSTRUCTION COMMENT
(0) my_var: DS.B 1
(1) T0: DC.B $0A
(2) T1: DC.B $0B
(3) T2: DC.B $0C
(4) T3: DC.B $0D
(5) ldhx #__SEG_END_SSTACK
(6) txs
(7) cli
(8) init: clr my_var
(9) bclr 3, my_var
(10) bclr 2, my_var
(11) bset 1, my_var
(12) bset 0, my_var
(13) bclr 4, my_var
(14) jsr label1
(15) label1: pshh
(16) pshx
(17) clrh
(18) ldhx my_var
(19) lda T0, X
(20) pulx
(21) pulh
(22) jmp init
(ii) (5pts/2min) What is the value loaded into accumulator A in line (19) the first time the code
runs?
How about the value loaded into A say, after a day of operation?
(iii) (8pts/8min) In your own words, tell me what the code is supposed to do. Do you see any
flaws in the way it is structured? Why? Explain
If you see any flaws, tell me how to fix them….
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download 4 Questions on Microprocessor Systems - Midterm 1 | CPEG 222 and more Exams Microprocessors in PDF only on Docsity!

CPEG 222 - MICROPROCESSOR BASED SYSTEMS Name:

Spring 2005 - Jorge Andres Garcia - Midterm 1

1. (35pts/25min) Analyzing and fixing a piece of code (i) (5pts/5min) Comment the following code. Only sensible comments are welcome LINE LABEL INSTRUCTION COMMENT (0) my_var: DS.B 1 (1) T0: DC.B $0A (2) T1: DC.B $0B (3) T2: DC.B $0C (4) T3: DC.B $0D (5) ldhx #__SEG_END_SSTACK (6) txs (7) cli (8) init: clr my_var (9) bclr 3, my_var (10) bclr 2, my_var (11) bset 1, my_var (12) bset 0, my_var (13) bclr 4, my_var (14) jsr label (15) label1: pshh (16) pshx (17) clrh (18) ldhx my_var (19) lda T0, X (20) pulx (21) pulh (22) jmp init (ii) (5pts/2min) What is the value loaded into accumulator A in line (19) the first time the code runs? How about the value loaded into A say, after a day of operation? (iii) (8pts/8min) In your own words, tell me what the code is supposed to do. Do you see any flaws in the way it is structured? Why? Explain If you see any flaws, tell me how to fix them….

(iv) (5pts/2min) Could you find a better way to write lines (8) thru (13)? (v) (2pts/1min) What type of addressing mode is being used in line (19)? (vi) (5pts/2min) What do lines (1) thru (4) do? (vii) (5pts/5min) What does line (7) do? If a (not shown) piece of your code consisted on an interrupt service routine to be executed every time a rising edge occurs at the IRQ pin of the microcontroller, what else needs to be done in order to service the interrupt with the highest priority? (Discuss in general the meaning of the status register that is associated to the IRQ pin, Im not looking for the exact names of the setting bits…)

(iii) (10pts/8min) Draw a block diagram of your design proposal

3. (25pts/20min) Writing code the right way. You have to design software in assembly that performs a simple operation on 2 out of 4 spots from memory (OP1, OP2, OP3 and OP4): (a) If SW1 is pressed, OP1 and OP2 are added and saved in RES (b) If SW2 is pressed, OP3 and OP4 are added and saved in RES (c) If the addition in either case is more than 15, the result RES should be zero. Note: assume that SW1 is connected to bit0 of port C and SW2 to bit1 of port C. Don’t worry about port initialization, only the logic to implement the functionality described above is necessary. (i) (13pts/8min) Draw a flow diagram that implements the desired functionality. (ii) (12pts/12min) Write the solution in assembly language based on the flow diagram. Correctness of your answer is based on how correlated parts (i) and (ii) are.