我试图将C程序转换为MIPS汇编程序。以下是该程序我的C代码:(注:灯泡[数字]是用于由用户输入的“数量”初始化为全零个值的数组)将C程序转换为MIPS汇编语言程序
for(int i = 1; i <= number; i++)
for(int j = 1; j <= number; j++)
if(j % i == 0)
Bulbs[j-1] = (Bulbs[j-1] + 1) % 2;
什么我到目前为止是如下:
li $t0, 0 #$t0 is set to 0 to be used as index for for loop1
li $t1, 0 #$t1 is set to 0 to be used as index for for loop2
li $s2, 4 #integer 4 is stored in s2
mult $s3, $s2 #input number($s3) is multiplied by 4
mflo $s4 #result of multiplication is stored in $s4
loop1:
bgt $t0, $s4, end_loop1 #if t$0 > $s4(input number*4), exit loop1,
#performing multiplication by 4 since word occupies 4 bytes
addi $t3, $t3, 1 #t3 is initialized to serve as "i" from for loop1
loop2:
bgt $t1, $s4, end_loop2 #if $t1 > (input number*4