0

I don't know what's wrong with this code. Thanks in advance

 .data
    array: .space 40
    prompt: .asciiz "Enter an integer (0 to quit):"
    text: .asciiz "After sorting, the list of integers is:"
        .text
        .globl main
    main:
        la $a1, array
    read_numbers:
        li $v0, 4
        la $a0, prompt
        syscall

        li $v0, 5
        syscall

        sw $v0, 0($a1)
        addiu $a1, $a1, 4

        beqz $v0, sort
        j read_numbers

    sort:
        la $a1, array

        li $v0, 4
        la $a0, text
        syscall
    loop:
        lw $t0, 0($a1)
        addiu $a1, $a1, 4

        beqz $t0, done

        li $v0, 1
        move $a0, $t0
        syscall

        j loop


    done:

I'm trying to make an array and fill it with unordered numbers and sort them after that. i'm able to input them but the output isn't being sorted with providing an error attempt to execute non-instruction at 0x00400080.

  • 1
    `done:` <-- What's supposed to happen here? If you want your program to end you need to state that explicitly by using system call 10, otherwise the simulator will just go on and try to fetch whatever random words it finds, and execute them as instructions. – Michael Apr 25 '16 at 05:39
  • could you please tell me where and how to put the system call 10 ? Thank you – user3724875 Apr 25 '16 at 05:44
  • 1
    _Where?_ At the place where you want execution of your program to end. Only you know where that is. _How?_ By using system call 10. You're already using multiple system calls in your code, so I assume you know how to use them. Google _"SPIM system calls"_. – Michael Apr 25 '16 at 05:51

0 Answers0