我需要帮助了解MIPS的任务。我正在尝试翻译这个伪代码
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;
}
到目前为止,我已经使用提供的模板和研究不同的结构以及如何将它们翻译成mips来做到这一点,生病留下评论我有疑问。
.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
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:
我已经尝试了几个小时,研究和所有,我还没有能够找到我的问题的具体答案。这只是翻译的第一部分,如果我可以得到帮助,我相信我可以自己完成剩下的工作。谢谢。