| 
 | 
 
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册  
 
×
 
void main(){ 
int n,i,sum; // assume that $s0 is for n, $t0 for i and $s1 for sum 
/* MIPS code for reading an integer. */ 
addi $v0, $zeros, 5 
syscall 
add $s0, $zeros, $v0 
/*---------------------------------------------*/ 
// mainly translate the following code into MIPS code 
sum=0; 
for (i=1; i<=n; i++) 
sum+=i; 
 
/* MIPS code for printing an integer */ 
addi $v0,$zero,1 
add $a0,$zeros,$s1 
syscall 
/*--------------------------------------------*/ 
addi $v0,$zeros,10 
syscall 
/*---------------------------------------------*/ 
} |   
 
 
 
 |