Midterm for Microprocessor Systems | CPEG 222, Study notes of Microprocessors

Material Type: Notes; Class: Microprocessor Systems; Subject: Computer Engineering; University: University of Delaware; Term: Spring 2006;

Typology: Study notes

Pre 2010

Uploaded on 09/02/2009

koofers-user-iej-1
koofers-user-iej-1 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPEG 222 - MICROPROCESSOR BASED SYSTEMS Name:
Spring 2006 - Jorge Andres Garcia - Midterm 1
1. (30pts/20min) Analyzing and fixing a piece of code
(i) (8pts/5min) Write lines (11), (12), and (13) of the following subroutine code
(ii) (8pts/6min) Comment the code. Only sensible comments are welcome
Notes: INC_TIMES is a variable that contains a number between 0 and 9
INIT_ARRAY is the 16bit initial address of an array of constant values
LINE LABEL INSTRUCTION COMMENT
;subroutine begins
(1) label1: pshh
(2) pshx
(3) ldhx INIT_ARRAY
(4) lda INC_TIMES
(5) label2: cmp #0
(6) beq done_deal
(7) incx
(8) deca
(9) bra label2
(10) done_deal: lda ,X
(11)
(12)
(13)
;subroutine ends
(iii) (5pts/3min) In your own words, different from commenting the lines of code, tell me what it
does.
(iv) (6pts/5min) Suppose the memory contents shown below. If at the beginning of the
subroutine INIT_ARRAY = $182D and INC_TIMES = 3, what is the value stored in register
A at the end of the subroutine? What if INC_TIMES = 0?
Address Value(Hex)
$182C A2
$182D E0
$182E 52
$182F 1F
$1830 37
$1831 2E
(v) (3pts/1min) What type of addressing mode is being used in line (10)?
pf3
pf4
pf5

Partial preview of the text

Download Midterm for Microprocessor Systems | CPEG 222 and more Study notes Microprocessors in PDF only on Docsity!

CPEG 222 - MICROPROCESSOR BASED SYSTEMS Name:

Spring 2006 - Jorge Andres Garcia - Midterm 1

1. (30pts/20min) Analyzing and fixing a piece of code (i) (8pts/5min) Write lines (11), (12), and (13) of the following subroutine code (ii) (8pts/6min) Comment the code. Only sensible comments are welcome Notes: INC_TIMES is a variable that contains a number between 0 and 9 INIT_ARRAY is the 16bit initial address of an array of constant values LINE LABEL INSTRUCTION COMMENT ;subroutine begins (1) label1: pshh (2) pshx (3) ldhx INIT_ARRAY (4) lda INC_TIMES (5) label2: cmp # (6) beq done_deal (7) incx (8) deca (9) bra label (10) done_deal: lda ,X (11) (12) (13) ;subroutine ends (iii) (5pts/3min) In your own words, different from commenting the lines of code, tell me what it does. (iv) (6pts/5min) Suppose the memory contents shown below. If at the beginning of the subroutine INIT_ARRAY = $182D and INC_TIMES = 3 , what is the value stored in register A at the end of the subroutine? What if INC_TIMES = 0?

Address Value(Hex)

$182C A

$182D E

$182E 52

$182F 1F

$1831 2E

(v) (3pts/1min) What type of addressing mode is being used in line (10)?

2. (20pts/20min) Checking concepts. (i) (4pts/4min) Give assembly examples of four addressing modes. 1 2 3 4 (ii) (4pts/4min) Assume you have 10 memory positions (1 byte each) available in your memory to create a look-up table of numbers that are powers of two (2, 4, 8, 16, etc.). Which one is the last one? (iii) (2pts/2min) If you have an 8-bit microcontroller, how many memory locations are necessary to create a look-up table containing these numbers : 122, 238, 754, 1290? (iv) (2pts/2min) What if it were a 16-bit microcontroller? (v) (2pts/2min) Why the initialization of the stack pointer is one of the first things done in a program? (vi) (2pts/2min) What is not saved in the stack automatically by the microcontroller when executing an interrupt subroutine? (vii) (2pts/2min) What instruction must never be used to call a subroutine? Why? (viii) (2pts/2min) What instruction must never be used to end an interrupt service subroutine? Why?

4. (30pts/20min) Design. In many cars the seat belt alarm buzzer is also used to warn against leaving the key in the ignition or leaving the lights on. This is how such a system may operate: The alarm is to sound if the key is in the ignition when the door is open and the motor is not running, or if the lights are on when the key is not in the ignition, or if the driver belt is not fastened when the motor is running, or if the passenger seat is occupied and the passenger belt is not fastened when the motor is running. (i) (5pts/3min) Assuming there are sensors that produce digital signals out of the sensed variables of the car, describe the resources needed from your microcontroller (e.g. I need 1 port configured as input for this, 1 port configured as output for that, etc.) (ii) (5pts/3min) Sketch a block diagram of the system, clearly labeling the parts and indicating the direction of signals flow

(iii) (10pts/7min) Sketch a flow diagram of your software solution