Midterm_Exam_2_Takeh..

advertisement
Pierce College
CSIT 516
Midterm Examination
Takehome
25 October 2011
Name:
Answers - - KEY
1. Convert the following
4 points
from sign & magnitude
to 2’s complement binary (signed) representation:
a. – 4516  ___1111 1011 1011 ________________2
12 bit register
b. 4510  ____0000 0010 1101 ________________2
12 bit register
2. Convert the following
4 points
from 2’s complement (signed) representation in 12 bit registers
to sign & magnitude representation used in base 10:
a. 9B16  __________155___________________10
b. 5D16  __________93___________________10
3. Perform the following computations assuming a 13-bit, 2's complement
binary representation:
6 points
a.
1B15
ADD 0E21
0936
b.
C=
1
V=
0
1A25
ADD 1CF1
1716
C=
1
V=
0
4. Determine the output of the following machine language program.
8 points
C1000E
910010
F1000D
51000D
00
00
A94F
FFFD
M
5. Given the following program
28 points
0000
0003
0005
0007
BR
MAIN
.BLOCK
.BLOCK
.BLOCK
N1:
N2:
N3:
2
2
2
;
;
0009
000C
000F
0012
0015
0018
001B
001E
0021
0024
0027
002A
002D
0030
0033
0036
0039
003C
003F
0040
0043
0046
0049
004C
004F
0050
0053
0056
0059
005C
005F
0062
0065
0068
006B
006E
0071
0074
0077
007A
007D
007E
0081
0084
0085-
MAIN:
L1:
L2:
L3:
L4:
L5:
BRLT
L6:
L7:
L8:
L9:
DECI
DECI
LDA
CPA
BRLT
DECI
LDA
CPA
BRLT
BR
STA
DECI
LDA
CPA
BRLT
DECO
DECO
DECO
STOP
DECO
DECO
BR
DECO
DECO
STOP
STA
LDA
CPA
L3
DECO
DECO
BR
DECO
LDA
CPA
BRLT
BR
DECO
DECO
DECO
STOP
DECO
DECO
STOP
.END
N2, d
N3, d
N2, d
N3, d
L1
N1, d
N1, d
N3, d
L7
L6
N3, d
N1, d
N2, d
N1, d
L5
N1, d
N2, d
N3, D
N2, d
N3, d
L9
N1, d
N2, d
N1, d
N3, d
N1, d
N2, d
N1, d
L2
N3, d
N1, d
N2, d
L4
L8
N1, d
N3, d
N2, d
N2, d
N1, d
Trace the program and
describe what it
accomplishes;
justify and support your
claim.
Find and mark the code
lines that are never
executed; use high lighter
or braces to identify the
useless code
Find and mark the code
lines that jump into the
center of a loop; draw lines
to indicate the
errant code
Write a simpler program
that accomplishes the same
task, but is much smaller
than the given code
Potential Loop Violations
indicated by dark lines
leading toward the top of the
program; but no loops exist
in this program.
The code lines
highlighted in red are
lines which never
execute under any
conditions.
6. Given the following fragment of Pep 8 assembly Language code,
which instruction determines whether or not the branch occurs?
Why?
14 points
LDZ M0, d
LDA M1, d
ASLA
ASRZ
ROLA
ANDA
BRV
 .
 .
 .
L5: STA
 .
 .
 .
ASRZ
ROLA
ANDA
M2, d
L5
.
.
.
M4, d
.
.
.
do not modify the V bit
ASLA is the last instruction before the BRV instruction that can
modify the V status bit;
BRV uses only the V bit to determine whether or not to branch
7. Given the following program
CHARI
LDBYTEA
ANDA
STBYTEA
CHARO
STOP
.ASCII
.BLOCK
.WORD
.END
14 points
0x0010,d
0x0010,d
0x0015,d
0x0010,d
0x0010,d
“M//M”
1
0x00DF
a. Predict the output of the program if the input is [.
[
b. Predict the output of the program if the input is ~.
^
8. In the following code, determine the values of the symbols this, that, now
and then. Also determine the specified output values.
22 points
this
BR
then
.WORD
17
.ASCII "Now is the time to understand!!"
now: .EQUATE
39
that: .WORD
19
.BLOCK
9
charo
'\n',i
then: DECO
this,d
;output #1
charo
'\n',i
this:
DECO
now, i
;output #3
charo
'\n',i
STOP
msg1: .ASCII "output #1"
msg2: .ASCII "output #2"
msg3: .ASCII "output #3"
.END
0038
that
0024
then
0032
now
0027
output #1
14336
output #3
39
Download