Attempt to execute non instruction
assembly, mips
Solution
The assembly code seems ok. I guess your problem is that you have delayed branching enabled in QtSpim. This means that the instruction that follows a branch is always executed, regardless of the action taken by the branch.
The easy fix is either to disable delayed branching, or to add a `NOP` after any branch instruction.
In your code:
.text
main:
li $s0,5 # setting j to 5
li $t0,0 # setting i to zero
loop:
slti $t1,$t0,8
bne $t1,1,Exit
nop # added a nop to prevent the addition when branch is taken
add $s0,$s0,$t0
addi $t0,$t0,1
beq $s0,10,Exit
j loop
nop # added a nop to prevent executing unknown data after the unconditional jump
Exit:
j Exit # code added so we don't drop off executing after this point
nop
Problem
This is a mips assembly code for a C code.I am simulating it using Qtspim, but I am getting an error as titled above. ``` .text # j=$s0 , i=$t0 main: li $s0,5 # setting j to 5 li $t0,0 # setting i to zero loop: slti $t1,$t0,8 bne $t1,1,Exit add $s0,$s0,$t0 addi $t0,$t0,1 beq $s0,10,Exit j loop Exit: ``` The C code which I am trying to convert into assembly is as below ``` j=5; for(t=0,i<8;i++){ j=j+1; if(j==10) return; } ```