Menu

#78 bne Machinecode incorrect

v1.0_(example)
closed
nobody
bug (3)
1
2017-04-06
2017-04-05
Thomas P.
No

Given Program

Address Machinecode Machinecode in Binary Assembler Instruction
0x00400000 0x20080000 001000 00000 01000 0000000000000000 addi $t0, $0, 0
0x00400004 0x20090001 001000 00000 01001 0000000000000001 addi $t1, $0, 1
0x00400008 0x0089502A 000000 00100 01001 01010 00000 101010 slt $t2, $a0, $t1
0x0040000C 0x15400003 000101 01010 00000 0000000000000011 bne $t2, $0, 0x3
0x00400010 0x01094020 000000 01000 01001 01000 00000 100000 add $t0, $t0, $t1
0x00400014 0x21290002 001000 01001 01001 0000000000000010 addi $t1, $t1, 2
0x00400018 0x08100002 000010 00000100000000000000000010 j 0x4000008
0x0040001C 0x01001020 000000 01000 00000 00010 00000 100000 add $v0, $t0, $0
------------------------ --------------------------------------- ----------------------

ASM-Code which would create the same Machinecode in QTSpim as the given one

addi  $t0, $0, 0        # $t0 = 0
addi  $t1, $0, 1        # $t1 = 1
label_1:
slt   $t2, $a0, $t1     # $t2 = $a0 < $t1 ? 1 : 0
bne   $t2, $0, label_2  # if $t2 == 0 then <label_2>
add   $t0, $t0, $t1     # $t0 = $t0 + $t1
addi  $t1, $t1, 2       # $t1 = $t1 + 2
label_2:                # <<<< This label should be after the jump
j     label_1           # jump <label_1>
add   $v0, $t0, $0      # $v0 = $t0

ASM-Code which actually represents the Machinecode

addi  $t0, $0, 0        # $t0 = 0
addi  $t1, $0, 1        # $t1 = 1
label_1:
slt   $t2, $a0, $t1     # $t2 = $a0 < $t1 ? 1 : 0
bne   $t2, $0, label_2  # if $t2 == 0 then <label_2>
add   $t0, $t0, $t1     # $t0 = $t0 + $t1
addi  $t1, $t1, 2       # $t1 = $t1 + 2
j     label_1           # jump <label_1>
label_2:
add   $v0, $t0, $0      # $v0 = $t0

Discussion

  • James Larus

    James Larus - 2017-04-06
    • status: open --> closed
     
  • James Larus

    James Larus - 2017-04-06

    Please provide a valid spim program that demonstrate this error. The "Given Program" is not valid input to spim and I cannot reproduce your problem. Also indicate which mode of spim you are using (bare/delayed branches/etc).

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB