Write a MIPS Program to perform the conversion of 32-bit sign/magnitude binary to 2s complement numbers?


So i have been working on this and this is what i got so far Please help me if i did it wrong or i can fix something here. Thank You.

$ LC0: .ascii “Enter %d bit binary value: 0” $ LC1: .ascii “Original binary = %s20” $ LC2: .ascii “Ones complement = %s20” $ LC3: .ascii “Twos complement = %s20” main: addiu $ sp,$ sp,-144 sw $ 31,140($ sp) li $ 5,32 # 0x20 lui $ 4,%hi($ LC0) addiu $ 4,$ 4,%lo($ LC0) jal printf nop

    addiu   $  4,$  sp,24     jal     gets     nop      addiu   $  3,$  sp,24     addiu   $  2,$  sp,60     addiu   $  5,$  sp,92     li      $  6,49                 # 0x31     li      $  7,48                 # 0x30     li      $  9,49                 # 0x31     li      $  8,48                 # 0x30 

$ L4: lb $ 4,0($ 3) nop bne $ 4,$ 6,$ L2 nop

    b       $  L3     sb      $  8,0($  2) 

$ L2: bne $ 4,$ 7,$ L3 nop

    sb      $  9,0($  2) 

$ L3: addiu $ 2,$ 2,1 bne $ 2,$ 5,$ L4 addiu $ 3,$ 3,1

    sb      $  0,92($  sp)     addiu   $  4,$  sp,91     addiu   $  2,$  sp,127     addiu   $  5,$  sp,95     li      $  8,1                        # 0x1     li      $  6,49                 # 0x31     li      $  7,48                 # 0x30     li      $  9,1                        # 0x1     li      $  11,49                  # 0x31     li      $  10,48                  # 0x30 

$ L8: lb $ 3,0($ 4) nop bne $ 3,$ 6,$ L5 nop

    bne     $  8,$  9,$  L6     nop      b       $  L7     sb      $  10,0($  2) 

$ L5: bne $ 3,$ 7,$ L6 nop

    bne     $  8,$  9,$  L6     nop      sb      $  11,0($  2)     b       $  L7     move    $  8,$  0 

$ L6: sb $ 3,0($ 2) $ L7: addiu $ 2,$ 2,-1 bne $ 2,$ 5,$ L8 addiu $ 4,$ 4,-1

    sb      $  0,128($  sp)     addiu   $  5,$  sp,24     lui     $  4,%hi($  LC1)     addiu   $  4,$  4,%lo($  LC1)     jal     printf     nop      addiu   $  5,$  sp,60     lui     $  4,%hi($  LC2)     addiu   $  4,$  4,%lo($  LC2)     jal     printf     nop      addiu   $  5,$  sp,96     lui     $  4,%hi($  LC3)     addiu   $  4,$  4,%lo($  LC3)     jal     printf     nop      move    $  2,$  0     lw      $  31,140($  sp)     nop     j       $  31     addiu   $  sp,$  sp,144