Марс: GO выполнение прекращено нулевой инструкцией - PullRequest
0 голосов
/ 10 февраля 2020

Я новичок в MIPS и MARS, я пытаюсь написать программу, которая находит минимум и максимум в массиве, вот что у меня сейчас:

    .data

# An array, with hard-coded values, to use for testing
array1: .word 23, 45, -2, 4, 6, 42, 7, 35, 10, 2, -332, 101, 2, 3, 110, -1

size: 16
mini : .asciiz "Minimum is :"
maxi : .asciiz "\nMaximum is :"


    .globl main

main:
        la $a0,array1              #load address of array
        la $t5,16                  #load size of array
        jal minmax                 #call minmax subroutine
        move $t0,$v0               #store the value of $v0 in $t0
        move $t1,$v1               #store the value of $v1 in $t1
        li $v0,4                   #4 is the print string syscall
        la $a0,mini                #load address of string
        syscall                     #print string

        li $v0,1                   #1 is the ptint integer syscall
        move $a0,$t0               #load integer to be printed
        syscall                    #print integer

        li $v0,4                   #printing maxi
        la $a0,maxi 
        syscall 

        li $v0,1                   #printing $t1
        move $a0,$t1 
        syscall 

        li $v0,10                  #exit
        syscall

minmax:
        addi $sp,$sp,-8            #adjust stack pointer
        sw $s1,4($sp)              #save $s1
        sw $ra,0($sp)              #save $ra 
        lw $t0, 0($a0)             # initialize MIN as first element of the array
        lw $t1, 0($a0)             # initialize MAX as first element of the array
        addi $a0,$a0 ,4            # increment the pointer of the array
        addi $t5,$t5 ,-1           # incerement the size of the array

loop:
        lw $t2 , 0($a0)            # initialize $t2 as the next element of the array
        bge $t2,$t1 , max          # if $t2 >= $t1 go to max
        ble  $t2,$t0, min          # if $t2 <= $t0 go to min

min:
        move  $t0, $t2             # if $t2<$t0 , min($t0) = $t2
        j check                    # jump to check-size

max:    
        move $t1 ,$t2              # set max($t1) = $t2
        j check                    # jump to check

next:
        addi $a0,$a0 ,4            # increment the pointer of the array
        addi $t5,$t5 ,-1           # incerement the size of the array
        j loop

check:
        addi $t4,$t4,1             #inirialize t4 as 1 ($t4=1)
        bne  $a1, $t4 ,next        #if size is not 1 ( meaning that we haven't check all the elements in array) go back to loop
        move $v0,$t0               #save minimum value to $v0
        move $v1,$t1               #save maximum value to $v1
        lw $s1,4($sp)              #restore $s1
        lw $ra,0($sp)              #restore $ra
        addi $sp,$sp,8             #readjust $sp
        jr  $ra

, но когда я Запустите программу, я получаю эту ошибку: GO выполнение прекращено нулевой инструкцией.

Подскажите, пожалуйста, что означает эта ошибка и как я могу исправить свой код?

спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...