I was trying to solve this homework assignment but was unable to come up with a solution. Below is the problem,
Translate this code into MIPS machine
once_more:
lw $5, 48($6)
sub $5, $5, $2
bne $5, $0, once_more
Now the problem I am facing is that I have no idea what should be the value of the registers in this problem (I only studied $t0-$t7(8-15) and $s0-$s7 (16-23) values). Can anyone please help me with the values of these registers?
Thanks in advance.
Based on this document, I think the registers being referenced are as follows:
$5->$a1$6->$a2$2->$v0$0is the$zeroregister.$a-registers hold arguments, while$v1registers hold results. One of the purposes of these registers is for use by syscalls; for example, theprint_intsyscall will print the value in$a0as an integer.Translating these to machine code will mean that you need to convert the assembly statement into the binary machine equivalent. The MIPS Green Card will help you here. Look at the “Basic Instruction Formats” section for an explanation of how the instructions are laid out in binary.