Search code examples
assemblymipsspim

attempt to execute non-instruction


i have some code in mips assembler and i'm getting something like in the title. As you can see, i have $li $v0, 10 and syscall so does anybody know what's wrong with it?

        .data
text0:  .asciiz "Enter strng: \n"   
buf0:   .space 100

    .text
    .globl main

main:
    la $a0, text0                   
    li $v0, 4                       
    syscall                         

    la $a0, buf0                    
    li $a1, 99                      
    li $v0, 8                       
    syscall                         

    li $t0, 'a'                     
    li $t1, 'z'                     
    li $t2, 0x20

    la $t3, buf0                    


loop_begin:
    lb $t4, ($t3)                   
    beq $t4, $zero, loop_end        

    blt $t4, $t0, increment_ptr     
    bgt $t4, $t1, increment_ptr     
    sub $t4, $t4, $t2               
    sb $t4, ($t3)                   
increment_ptr:
    addi $t3, $t3, 1                
    b loop_begin                    
loop_end:

    la $a0, buf0                    
    li $v1, 4                       
    syscall                         

    li $v0, 10                      
    syscall

Solution

  • I can't reproduce your error message. Perhaps you did a Reinitialize in SPIM without reloading the assembly file.

    Anyway, you're not setting up the final print_string system call properly:

    li $v1, 4   # <-- SHOULD BE $v0                       
    syscall
    

    If you had used the single-stepping feature in SPIM to debug your code you probably would've found this, so I suggest that you make use of it for future development.