Question: this is a MIPS program Exercise 5: Consider the following program (you dont need to create a new source file, just read the code and
this is a MIPS program
Exercise 5: Consider the following program (you dont need to create a new source file, just read the code and
answer the questions):
.text
la $s0,neg1byte
la $s1,oneword
la $s2,twowords
la $s3,smallstring
lb $t0,3($s1)
add $s1,$s1,$t0
lb $t1,0($s1)
addi $s1,$s1,2
add $s2,$s1,$t1
sb $t0,0($s2)
addi $s1,$s1,7
add $a0,$s1,$t0
li $v0,4
syscall
lw $t0,0($s3)
sh $t0,-5($s2)
li $v0,10
syscall
.data
neg1byte: .byte -1
oneword: .word 0x02030405
twowords: .word 02,03
smallstring: .asciiz abc
halfwords: .half 10,11,12,13,14,15
Assume that neg1byte represents address 0x10010000, and that all unspecified bytes in memory contain 00.
1. How many bytes are allocated in the data section, from the starting address neg1byte to the end of the data stored at halfwords (count any extra bytes allocated by the data directives)?
List your predicted values for the bytes stored in the Data Segment before the program executes:
Data Segment
Address Value (+0) Value (+4) Value (+8) Value (+C) Value (+10) Value (+14) Value (+18) Value (+1C)
0x10010000
2. Fill in the following table to show the contents of registers $s0-s3 and $t0-$t1 after each instruction is executed.
Only fill in the entries that change for each instruction. If a value stored in memory is modified by an instruction, also record that address and its new value on that line. Assume all registers contain a value of 0 initially!
$s0 $s1 $s2 $s3 $t0 $t1 $a0 addr: val
la $s0,neg1byte
la $s1,oneword
la $s2,twowords
la $s3,smallstring
lb $t0,3($s1)
add $s1,$s1,$t0
lb $t1,0($s1)
addi $s1,$s1,2
add $s2,$s1,$t1
sb $t0,0($s2)
addi $s1,$s1,7
add $a0,$s1,$t0
li $v0,4
syscall
lw $t0,0($s3)
sh $t0,-5($s2)
What should be displayed in the Run I/O window at the end of the program?
Record your predicted values of the bytes stored in the data section after the program is done executing (only record the new values in memory, in the correct location; you dont have to rewrite your whole table):
Data Segment
Address Value (+0) Value (+4) Value (+8) Value (+C) Value (+10) Value (+14) Value (+18) Value (+1C)
0x10010000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
