Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt to execute non instruction

Tags:

assembly

mips

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;
}
like image 423
Assasins Avatar asked Nov 08 '12 13:11

Assasins


1 Answers

If you are having problems with "attempt to execute non istruction at address 0x..." try adding at the end of your code this :

li $v0,10
syscall

the pc counter will always add +4 to the pc (because instructions are stored in multiplies of 4) and it will do this until you won't say EXIT FROM PROGRAM.

Yes ,the procedure of terminating the program is fault of the programmer,so you will write a exit syscall in order to terminate your code.

For who did some code in 8086 can remember that there was a .EXIT routine that return the control of the program to the DOS, so it's the same as syscall

like image 157
Zeal Avatar answered Oct 27 '22 00:10

Zeal