MIPSym Assembly Write a function to print all the values in the tuple array. Thi
ID: 3840370 • Letter: M
Question
MIPSym Assembly
Write a function to print all the values in the tuple array. This function will be used for debugging. It should take the list of tuples as a first argument and the number of tuples as a second argument.
Pseudo code is as follows:
void printTuples(int *tuples, int num) {
int i;
for (i=0; i<num; i++) {
print i;
print “:”;
print tuples[i][0];
print tuples[i][1];
print tuples[i][2];
print tuples[i][3];
print “ ”;
}
}
The test program should run as follows:
1) Allocate the tuples[][] array
2) Initialize the tuples[][] array to zero
3) num=getTuples(&tuples)
4) printTuples(&tuples,num)
Explanation / Answer
load:
lw register_destination, RAM_source
#copy word (4 bytes) at source RAM location to destination register.
lb register_destination, RAM_source
#copy byte at source RAM location to low-order byte of destination register,
# and sign-e.g.tend to higher-order bytes
store word:
sw register_source, RAM_destination
#store word in source register into RAM destination
sb register_source, RAM_destination
#store byte (low-order) in source register into RAM destination
load immediate:
li register_destination, value
#load immediate value into destination register
example:
.data
var1: .word 23 # declare storage for var1; initial value is 23
.text
__start:
lw $t0, var1 # load contents of RAM location into register $t0: $t0 = var1
li $t1, 5 # $t1 = 5 ("load immediate")
sw $t1, var1 # store contents of register $t1 into RAM: var1 = $t1
done
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.