Wednesday, May 15
190 pts. (will
be normalized to 200 in the gradebook)
I. Data
Representation
a. (10
pts.) Write down (in
hexadecimal) the internal representation of the integer –13. Be sure to provide all hexadecimal digits.
b. (10
pts.) Write down (again in hex)
the internal representation of the double precision number –13.0. You need write down only the digits in the
first word of the representation.
c. (10
pts.) The assembly language
statement
string: .asciz "This
is a string"
Will
cause data to be placed in memory at the address known as 'string'. What will be placed here? How is the end of the string indicated?
II. Data
Structures
a. (15
pts.) The following function
(written in C) adds two four-by-four arrays together and places the result in
result in a third. Implement this
procedure (as a complete procedure) in assembly language:
void
addit(int a[4][4], int b[4][4], int c[4][4]) {
int
i,j;
for
(i = 0; i < 3; ++i)
for (j = 0; j < 3;
++j)
c[i][j] = a[i][j]
+ b[i][j];
}
b. (15 pts.) Suppose that we have
struct
partstruct {
char pno[12];
int qty;
cost double;
struct
partstruct *next;
}
and that %i0 points to the address of one of these
structures. These records form a linked
list of records.
i) Write
the assembly language statements which will place the qty of the current
record (i.e., the one pointed to by %i0)
into %o0.
ii) Write
the assembly language statements which will place the address of the next
record in the linked list into %i0.
iii) What
might cause a problem if the array pno were 10 entries long instead of 12?
III. Control structures
Iteration was pretty well covered in the preceding set of
questions, but let's have a simple if-then-else question with a
call-by-location twist.
1. (15
pts). The integer function max takes two
arguments, each of which is the address of an integer. It returns the larger of the two (the larger
value – not the address of the memory location containing the larger value).
IV. Some
miscellaneous questions:
a. (15
pts.) You are camping with
friends during the summer months, and while relaxing at the end of the day the
conversation turns (as it so often does) to programming and to programming
languages. You mention that you have
just finished a course on assembly language programming (dropping, for the
moment, mention of architecture). A
friend, who knows something of programming, asks why anyone would study
that. Give a good one paragraph answer.
b. (15
pts.) Another friend has
finished the first two semesters of computer science using C++ and a very
supportive development tool (Visual C++, for example). Your friend is moving to unix, and is a bit
confused by the use of gcc to compile and link programs. Give a good one paragraph explanation,
perhaps including a diagram.
c. (10
pts.) What is pipelining?
d. (10
pts.) What is the difference
between an annulled branch and one that is not annulled, and what does that
have to do with pipelining?
e. (5
pts.) Give an example of a synthetic
instruction, explaining why it is synthetic
f. (10
pts.) Do one of the
following. Give your answer both in
binary and in hex.
i) The
instruction sub %r3, -1, %r5 is a format
three instruction with op = 10, op3 =
000100. How would this instruction
assemble?
ii) The
instruction ble prev is a branch
instruction with op = 00, cond = 0010, and op2 (as an integer branch) =
010. prev labels an instruction 4
instructions back from this instruction.
How would this instruction assemble?
V. Floating
point
a. (20
pts.) Write a complete assembly
language routine which will accept three double precision floating point
numbers (a, b, and c) as arguments, and which will return
VI. Some
architecture
a. (15
pts.) Use NAND and NOR gates and
inverters to construct a circuit with two inputs A0 and A1 and four outputs (O0 – O3). O0 – O3 are data lines
coming out. A0 and A1 determine which
output line should be active (A1 = 1 and A0 = 0 should
select O2 for example). If an
output is selected, then it should be a 1 and all others should be 0.
b. (15
pts. each) Look at the diagrams
(from Tanenbaum) labeled Diagram A and Diagram B on the last two pages of this
exam. Pick one, describe what it does,
identify and describe subsystems (which are labeled in diagram A and should be
circled in diagram B), and say what the inputs and outputs do.
Diagram A
(please do not remove this page)
.
Diagram B
(please do not remove this page)