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;
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With