我必须将此C代码转换为Mips,然后在Qtspim上运行代码
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void) {
int sum = 0;
int i;
for(i=0; i < 1000; i++)
sum = sum + i;
printf("sum=%d", sum);
return 0;
}
我的Mips代码是
.data
.text
li $s1, 0
li $s2, 0
Loop:
slt $t0, $s2, 1000
beq $t0, $0, Exit
add $s2, $s2, $s1
addi $s1, $s1, 1
j Loop
Exit:
li $v0, 1
move $a0, $s2
请告诉我怎么了。
说“试图在0x00400024处执行非指令
答案 0 :(得分:0)
let colors = [
['#000','#00F','#0F0'],
['#0FF','#F00','#F0F'],
['#FF0','#FFF','#000']
]
let canvas_div = document.getElementById('canvas_div');
canvas_div.style.position = "fixed";
canvas_div.style.top = "50%";
canvas_div.style.left = "50%";
canvas_div.style.width = "0";
canvas_div.style.height = "0%";
canvas_div.style.transform = "scale(10) translate(-20px,-20px)";
for (i = 0; i < 3; i++){
for (j = 0; j < 3; j++){
let canvas = document.createElement('canvas');
canvas.width = 100;
canvas.height = 100;
canvas.style.position = "fixed";
canvas.style.top = `${i * 10}px`;
canvas.style.left = `${j * 10}px`;
canvas.style.width = "10px"
canvas.style.height = "10px"
let context = canvas.getContext("2d");
context.fillStyle = colors[i][j];
context.fillRect(-0,0,100,100);
canvas_div.appendChild(canvas);
}
}