Homework P&H Ch. 2
Answer the following questions about Patterson and Hennessy, Chapter 2.
You only need to turn in those that have a point count assigned.
-
What are the five categories of machine instructions in modern
processors?
Give an example of each.
-
In general terms, describe how a while loop is implemented in assembly
language.
How does a do-while loop differ?
-
(1 point)
In general terms, describe how an if-else statement is implemented in
assembly language.
-
(1 point)
Suppose that your program has a simple subprogram with label
mySubprogram
.
-
What does the calling code need to do first?
-
What is the MAL code to call the subprogram?
-
What is the MAL code to return from the subprogram?
-
(1 point)
The following questions concern a MAL subprogram that uses a run-time
stack.
-
What kinds of information can the run-time stack contain?
-
How does the subprogram allocate space on the run-time stack?
-
What must the subprogram do before returning?
-
(1 point)
Suppose you have a struct in assembly language that is declared as
follows:
struct: double 0.0 # struct.d
float 1.0 # struct.f
word 15 # struct.i
byte 'x' # struct.c
-
What is the total size of
struct
?
-
If the address of
struct
is in $t0 what is the MAL code
for loading struct.d
into $f2?
-
If the address of
struct
is in $t0 what is the MAL code
for storing $f4 into struct.f
?
-
If the address of
struct
is in $t0 what is the MAL code
for loading struct.i
into $t1?
-
If the address of
struct
is in $t0 what is the MAL code
for storing $t2 into struct.c
?
-
(1 point)
An array with 120 entries is declared statically in MAL by the
following code:
A: double 1.0:120
-
What is the MAL code to put the base address of A into $t0?
-
If an entry's index is in $t1 what is the MAL code to put the
address of the entry into $t2?
-
What is the MAL code to load the entry into $f4?