Convert this C function to MIPS bool singletonint value Thi

Convert this C function to MIPS ## bool singleton(int value) {//This function checks whether ## return (value != 0) && !(value & (value - 1)); ##} singleton: jr $ra

Solution

C function to MIPS:

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

   lw   $2,8($fp)
   nop
   addiu   $3,$2,-1
   lw   $2,8($fp)
   nop
   and   $2,$3,$2
   bne   $2,$0,$L2
   nop

   li   $2,1           # 0x1
   b   $L3
   nop

$L2:
   move   $2,$0
$L3:
   move   $sp,$fp
   lw   $fp,4($sp)
   addiu   $sp,$sp,8
   j   $31
   nop

   .set   macro
   .set   reorder
   .end   _Z9singletoni
$LFE0:
   .size   _Z9singletoni, .-_Z9singletoni
   .ident   \"GCC: (Debian 4.4.5-8) 4.4.5\"

 Convert this C function to MIPS ## bool singleton(int value) {//This function checks whether ## return (value != 0) && !(value & (value - 1)); ##}
 Convert this C function to MIPS ## bool singleton(int value) {//This function checks whether ## return (value != 0) && !(value & (value - 1)); ##}

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site