Quantcast
Viewing latest article 6
Browse Latest Browse All 6

MIPS assembly for a simple for loop

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

This is my MIPS assembly code. Is it a correct translation? If you see any mistakes I would really like to know.

# tmp = $v0# j = $t0.globl main main:    li $v0,0loop:    bgt $t0,15,exit    addi $t0,$t0,1    mul $t1,$v0,2    add $v0,$t1, 3    j loop  exit:

Viewing latest article 6
Browse Latest Browse All 6

Trending Articles