Question

Convert the following code to assembly MIPS void checki() { int i = 0; while(i <...

Convert the following code to assembly MIPS

void checki()
{
int i = 0;
while(i < 10)
{
switch(i)
{
case 1:
i += 5;
break;
case 2:
i --;
break;
case 3:
i += 2;
break;
default:
i++;
}
}
}

void main()
{
checki();
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

please find the below code,, which is converted into assembly mips...

.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.text
.align   2
.globl   _Z6checkiv
$LFB0 = .
.set nomips16
   .ent   _Z6checkiv
   .type   _Z6checkiv, @function
Z6checkiv:
   .frame   $fp,24,$31       # vars= 8, regs= 1/0, args= 0, gp= 8
   .mask   0x40000000,-4
   .fmask   0x00000000,0
   .set   noreorder
   .set   nomacro
   addiu   $sp,$sp,-24
$LCFI0:
   sw   $fp,20($sp)
$LCFI1:
   move   $fp,$sp
   movz   $31,$31,$0
$LCFI2:
   sw   $0,8($fp)
   b   $L2
   nop

$L7:
   lw   $2,8($fp)
   li   $3,2           # 0x2
   beq   $2,$3,$L5
   nop

   li   $3,3           # 0x3
   beq   $2,$3,$L6
   nop

   li   $3,1           # 0x1
   bne   $2,$3,$L9
   nop

$L4:
   lw   $2,8($fp)
   nop
   addiu   $2,$2,5
   sw   $2,8($fp)
   b   $L2
   nop

$L5:
   lw   $2,8($fp)
   nop
   addiu   $2,$2,-1
   sw   $2,8($fp)
   b   $L2
   nop

$L6:
   lw   $2,8($fp)
   nop
   addiu   $2,$2,2
   sw   $2,8($fp)
   b   $L2
   nop

$L9:
   lw   $2,8($fp)
   nop
   addiu   $2,$2,1
   sw   $2,8($fp)
$L2:
   lw   $2,8($fp)
   nop
   slt   $2,$2,10
   andi   $2,$2,0x00ff
   bne   $2,$0,$L7
   nop

   move   $sp,$fp
   lw   $fp,20($sp)
   addiu   $sp,$sp,24
   j   $31
   nop

   .set   macro
   .set   reorder
   .end   _z6checkiv
$LFE0:
   .size   _z6checkiv, .-_z6checkiv
   .ident   "GCC: (debian 4.4.5-8) 4.4.5"

Add a comment
Know the answer?
Add Answer to:
Convert the following code to assembly MIPS void checki() { int i = 0; while(i <...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT