A of .word's,
whose first dimension runs from 1 to 7, second from 1 to 4, and third
from 1 to 10. Assume array A is stored
beginning at memory address 1000 (base ten).
Assume also elements are stored in row major order extended
to three dimensions:A[1,1,1] is stored first,
A[1,1,2] second,
...
A[1,1,9],
A[1,1,10],
A[1,2,1],
A[1,2,2],
...A[1,3,9],
A[1,3,10],
A[1,4,1],
A[1,4,2],
...
A[1,4,9],
A[1,4,10],
A[2,1,1],
A[2,1,2],
...A[7,4,9],
A[7,4,10].
(a) How many bytes of storage are required to store array A?
(b) At what memory address is element A[7,1,10] stored?
(c) Which element of array A is stored in the memory word
just before element A[7,1,10]?
(d) Which element of array A is stored in the memory word
just after element A[7,1,10]?
sp: .word
charstack: .byte 0:256
This stack is defined such that as the stack grows, the value in
the stack pointer (sp) gets smaller. The stack pointer
is also defined to point to the next available place for data (not
the currently full location).
sp.
charstack_full.
The code fragment associated with this label is given:
.data
full_err_str: .asciiz "Stack full. Cannot complete push operation."
.text
charstack_full: puts full_err_str
done
PART C (3 points)
Now write a SAL code fragment that
pops a value off this stack, and places the value into the .byte
variable
my_char.
If the stack is empty, then
have the code branch to a location
called charstack_empty.
The code fragment associated with this label is given:
.data
empty_err_str: .asciiz "Stack empty. Cannot pop off char stack."
.text
charstack_empty: puts empty_err_str
done
$7,
$8, and $9 after the
follow MAL sequence:
li $6, 0x3c96
sll $7, $6, 20
sra $8, $7, 4
and $9, $7, $8
sw $12, ($13)
lw $3, -12($23)
sra $11, $9, 6
alpha and beta
have been declared as integers.
bgez alpha, my_gez
move beta, -1
b my_end
my_gez: bgt alpha, 0 my_gtz
move beta, 0
b my_end
my_gtz: move beta, 1
my_end:
Turn in your file containing answers by running the script:
handinHW3 hw3file
where hw3file is an example name of a file
containing the homework answers.
The handinHW script submits your homework for you.
No printout will be turned in.