I need help understanding MIPS for an assignment. I am trying to translate this pseudocode
S = “Jane Doe” //array S that stores your name as a string of bytes of ASCII characters
//S[0]=’J’=0x4A; S[1]=’a’=0x61; S[2]=’n’=0x6E; S[3]=’e’=0x65; S[4]=’ ‘=0x20; and so on…
//shr (shift right), and, xor are bitwise operators
//This loop calculates a table T that holds CRC constants
for (i = 0; i < 256; i++) {
temp = i;
for (j = 0; j < 8; j++) {
if (temp and 1) {
temp = (temp shr 1) xor 0xEDB88320;
}
else
temp = temp shr 1; //shift right one position
}
T[i] = temp;
}
So far I have done this using a template provided and by researching different structures and how to translate them into mips, ill leave comments by the lines I have questions about.
.data
S: .asciiz "two words"
T: .word 0:256
.text
la $s0, S # s0 holds the base address of S
la $s1, T # s1 holds the base address of T
everything above this line was provided in a template
loop1:
bgt $t0, 256, exit1
sw $t0, ($t1) #is this the proper way to store a temp variable?
loop2:
bgt $t2, 8, exit2
and $t1, 1, else1 #saying $t1 and 1 doesn't feel right to me, is this the correct translation of the if condition?
srl $t1, $t1, 1 #is srl the same as shr? my compiler says shr is not found
xor $t1, 0xEDB88320 #this is what throws an error in the compiler
else1:
srl $t1, $t1, 1
exit2:
sw $t1 T($t0)# is this how I store a value to an array?
exit1:
I have been trying this for a few hours, researching and all, and I haven't been able to find concrete answers to my questions. This is only the first part of the translation, if I could get help on this I'm sure I could get the rest on my own. Thank you.