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
/*---------------------------------------------*/
}
打赏帖 | |
---|---|
【Cortex-M】Systick Timer使用被打赏10分 | |
分享汽车防盗系统的组成与分类(一)被打赏5分 | |
VOFA+波形显示+JYD-31蓝牙发送和解析不定长数据被打赏10分 | |
【换取手持数字示波器】-STM32F4PWM控制LED灯管亮度被打赏22分 | |
【换取手持数字示波器】STM32F4驱动RPR-0521RS照度、接近一体型传感器被打赏23分 | |
宏定义和const关键字定义被打赏5分 | |
【分享开发笔记,赚取电动螺丝刀】几个单片机I2S外设的BLCK时钟对比被打赏20分 | |
【功率监测与控制系统DIY活动成果贴】DIY功率计与LabVIEW数据采集被打赏100分 | |
【分享开发笔记,赚取电动螺丝刀】使用ESP32S3调试I2S音频模块MAX98357被打赏22分 | |
【Freertos】任务管理被打赏10分 |