
ECE 383 - Microcomputers
Summer 2009 โ Quiz 2 Solution
Problems:
1. What is the value of register or memory after each instruction โฆ
a. LDD #$1112 ; D = $1112
b. TFR D, X ; X = $1112
c. STD 0, X ; $1112 -- $11 $1113 -- $12
d. LDAA 1, +X ; A = $12
e. LDAB 1, โX ; B = $11
f. STD 0, X ; D = $1211
$1112 -- $12 $1113 -- $11
2. What is the value of registers after each instruction given the initial values of memories and register Y?
$1010: $10 Y = $1010 SP = $3C00
$1011: $11
$1012: $10
$1013: $11
a. LDAA 2, +Y ; A = $10 Y = $1012
b. LDAA 1, Yโ ; A = $10 Y = $1011
c. LDD $1011 ; D = $1110
d. LDY #1 ; Y = $0001
e. PSHD ; SP= $3BFE $3BFF = $10
f. PSHY ; SP= $3BFC $3BFD = $01
g. PULD ; SP= $3BFE D = $0001
3. What is the Assembly code for the following flowchart? (Heating, Cooling and Alarm are subroutines.)
ALARM
T>100
T>60
T
F
F
count++
COOLING HEATING
T
Start
Count=1
Count>100
RTS
F
T
MOVB #1, COUNT
LOOP: LDAA COUNT
CMPA #100
BGT END_LOOP
LDAA T
CMPA #100
BGT ALARM
CMPA #60
BGT COOLING
HEATING: JSR HEAT_SUB
BRA NEXT
COOLING: JSR COOL_SUB
BRA NEXT
ALARM: JSR ALARM_SUB
NEXT: INC COUNT
BRA LOOP
END_LOOP: RTS