Exam 1
Part I: ClosedBook INotes (75 pts)
NAME
I. What register is used to keep track of the address of the next instruction to be
executed is:
a.
b.
.c)
d.
Index Registers
Stack Pointer
Program counter
Condition code register.
a.
b.
c.
d.
MROM
EPROM
PROM
EEPROM
a.
b.
c.
d.
Store
Dec
Jmp
Load
4. In 68HCII, what are the size of the following registers in the order: B, D, SP,
CCR:
a.
b.
c.
d.
c
d
Decimal Hexadecimal
#
$
#
$
Nothin
a.
b.
c.
d.
Immediate
Register
Extended
Inherent
Immediate
Register
Extended
Inherent
Immediate
Register
Extended
Inherent
Arithmetic
Branching
Loading
Incrementing
11. How many different memory locations can the 68HCli address (hint: think of the
size of address bus):
a.
b.
c.
d.
256
262,144
65536
16384
12. When using branch instructions, the branch offset (BRA offset) has a range of:
'i
a. -64 to 63 bytes.
b. Dependson the size of the assemblyprogram.
c. Depends on the type of branch instruction used.
d. -128 to 127 bytes.
13. What are the contents of the D register and the memory locations after executing
LDD $00001 Before the instruction: [D] = $1010; [$0000] = $20; [$0001] = $30.
a
b)
c
d)
[D]
1010
0000
2030
3020
r$OOO
11
10
30
30
30
[$0000]
10
20
20
20
17. Which cond~tionalbranch instruction in the following list will not branch if the
condition flags are N=C=1 and Z=V=O:
a.
b.
c.
d.
BCS target
B~ target
:a,CCtarget
Bve target
18. Find the values of the condition flags N, Z, V and e after executing SUBA #$50.
Given: [A] = #$70, N=O, Z=I, v=o and C=1. (IDNT: N is set ifMSB of the result
is set; Z is set if result is zero; V is set if tWos complement overflow results; e is
set if a carry is generated.):
'N
a 1
b) 0
c 1
d) 0
Z
1
0
0
0
V C
0 1
1 1
0 0
0 0
19. Compute the new values of accumulator A and the e flag after executing the
instruction ASLA. The original value in A is $74 (01110100) and the C flag is 1.
(Hint: 0 moves into LSB and MSB moves into C) :
a.
b.
c.
d.
"~"I
, .--l
~~
-~ ~.; \.~
."
J:-_.
1
(;
20. If the memory location at $00 contains $F6 and the e flag is 1, what are the new
values of this memory location and the e flag after the execution ofLSR $OO?
(Hint: 0 into MSB and LSB into C):
1f b
a.
b.
c.
d.
0'
-::.
\\
"
I \0
I.') ,~Q--"3--y
~~IC]---)?
LO
,~!j
21. Compute the new values of accumulator B and the e flag after executing the
instruction ROLB. The original value in B is $BE and the C flag is 1.
(Hint: einto LSB and MSB into C):
a.
b.
c.
d.
f PA~ -;::
"
)~
\0' \ \., 0
22. A program requires a delay of 1 msec. The frequency ofE clock cycle is 2 MHz.
Calculate the number ofE clock cycles required for this delay:
a.
b.
c.
d.
20000.
10000.
2000.
1000.
+
.-:: ---'
,..~
~
= $33;
[SP]
executingPSHA?
a.
b.
c.
d.
7. 1'1 ~l
= $OOFF.What
2Mtil
~
-qJC)
", - ~
'11':r:l<;'...~.
$33
$FF
$OF
Unknownvalue.
24. Suppose[SP] = $OOFB.What are the contents of index register X after executing
TSX?
a.
b.
c.
d.
$OOFA
$OOFB
$OOFC
Unknown value.
25. Suppose [SP] = $OOFC.[X] =;: $3040. [$OOFD] = $20. What are the contents of
[$OOFB],[$OOFC]and[$OOFD]after executing PSHX?
a.
b.
c.
d.
$30,$40,$20
$40, $30,$20
$20,$40,$30
$20, $30, $40
Sf f
~
I} (1ft
., ~o
1{}t] fl7 :: 170
'f,::
b';7g/lf1.1
26. What are the contents of the A and B accumulators after executing ADDD
#$1050? The contents before executing the instruction: [A] = $20; [B] = $30:
a.
b.
c.
d.
1.n
-\,~
--1t)
1':1
~---=
79
"6
27. What are the contents of the A accumulator after executing LDAA #100?
a. The instruction generates an error.
b. [A]
= $64.
c. [A] = $100.
d. Depends on the previous contents of the accumulator.
~DI ()9
ZZ 2
I
I
I
I
a.
b.
c.
d.
y..
-: )
-;.
1.
30. If the reg. SP = $F7C3, then the instruction PULA retrieves reg. A from the stack
and sets the SP to:
a.
b.
c.
d.
Remains unchanged.
$F7C2
$F7C4
Depends on the data in the stack.
C
X
D
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
NAME
\q
---'J-S
EEL4767 Computer System Design I, Spring 2005
E~l
Part 2: Closed Book/2 Pages of Notes (25 pts)
NAME
LlA.tc{
trJt,
Using the INCHAR and OUTA subroutines write a program that inputs two ASCn
numbers between 0 and 9. Your program should check and make sure that the keyboard
input is a valid number between (0-9). Once your program has determined that the key
entered is a valid number, it should echo it to the screen. Next, your program should
compute
A(.L:f1 0-4 :::.~J-?:'"
Result = INumber 1 - Numher2
where
Finally, your program should output the result to the screen as an ASCII number.
~
O(~
100
iQOo1..
LV1-
Lf1- JS~
1 i'lLBA(J.
(MfA ~1-;O
~t~
..."''''
c.",fA li> ~ 1
tEa
["'fA
u&
c"'tA
ML\"
"" 1- >1-
N"~
&8-
~i 33
N"'~
CfI\ 'f\.
~19"
\)fG.
(f' p~
6tu
[MPA
1'JtX
(/1 fJA
~o.
c" fA
"w fI\.
-Ii.1 )~
1W.f'1
~13b
J'lL4T"\
~j77
tJuf'1
~." ~
1)~
rJUM
c'" pA
f;t El
~i~~
JRA
/,HpV\
Lf1-
ST
LPI
ORG $0100
LDS" #$OOFF
JSR INCHAR
CMPA #$30
BLO LPI
CMPA
#$39
BHI LPI
JSR OUTA
TAB
LP2
JSR INCHAR
CMPA #$30
BLO LP2
CMPA
#$39
BHI LP2
JSR OUTA
CBA
SUBTR
BHS SUBTR
SEE WHICH
PSHA
PSHB
PULA
PULB
SBA
ADDA #$30
JSR OUTA
EQ
JMP ST
INCHAR PSHB
RCHRI LDAB $102E
ANDB #$20
BEQ RCHRI
LDAA $102F
PULB
RTS
OUTA PSHB
WCHRl LDAB $102E
ANDB #$80
BEQ WCHRl
STAA $102F
PULB
RTS
CRLF LDAA #$OD
JSR OUTA
LDAA #$OA
JSR OUTA
RTS
END
IS POSITIVE
SOURCE
INPUT
CHARACTER
IN THE A
GO WRITE
THE CHAR