MIPS assembly for a simple for loop

后端 未结 4 1352
长发绾君心
长发绾君心 2021-02-09 00:24

I need to translate this C code to MIPS assembly. Here is the C code:

int tmp = 0; 
for (int  j = 0; j < 15; ++j) 
     tmp = tmp * 2 + 3

Th

4条回答
  •  野性不改
    2021-02-09 01:03

    I also don't know what MIPS simulator you're running, but I know some of them don't constants and they demand you assign those to registers. So like bgt Rsrc1, Src2, label, normally if you put an integer in src2 the computer will translate that but I know for some you'll get an error doing add $v0, $t1, 3 as it won't translate add into addi. Same with mul. I know my SPIM simulator doesn't allow it.

提交回复
热议问题