1. Engineering
  2. Computer Science
  3. a program declares two integer size of integer data type...

Question: a program declares two integer size of integer data type...

Question details

A program declares two integer (size of integer data type: 4 bytes) global variables: a,
b[5]. The following are the initialization of these global variables.
a = 1;
b[5] = f0,0,0,0,0g;
Consider the base address to these global variables be 2018. The base address is placed
in a global pointer register ($gp). The program executes the following set of assembly
instructions:
lw $r1, 0($gp)
lw $r2, 4($gp)
add $r2, $r2, $r1
lw $r1, 8($gp)
add $r1, $r2, $r1
sw $r1, 12($gp)
ori $r3, $r1, 4
sw $r3, 16($gp)
sub $r4, $r3, $r1
sw $r4, 0($gp)
(a) Annotate the above MIPS instructions to indicate source registers and destination
registers. (10 points)
(b) Mention the memory addresses for all the global variables, i.e., a, b[0], b[1], ...,
b[4]. (10 points)
(c) What are the values stored in the global variables after executing the MIPS pro-
gram. (10 points)

Do not copy and paste it please

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution