创建数组mips时出错

时间:2011-07-28 20:03:32

标签: assembly mips

我喜欢通过系统调用来创建一个mips数组但是我在D:\ mips \ create数组行20中得到错误错误:0x00400028处的运行时异常:请求(1074003968)超过可用堆存储(系统调用9)。

我的代码是:

.data
    question1_msg: .asciiz "How much integer do you want to give?\n"
    question2_msg: .asciiz "give a number?\n"
.text

question_numbers:
    la $a0, question1_msg #load the question in $a0
    li $v0, 4
    syscall

answer_numbers: 
    li $v0, 5  #read the anwser of previous question
    syscall
    move $t0, $a0

generate_array:   
    sll $t0, $t0, 2 #create array
    move $a0, $t0
    li $v0, 9
    syscall
    move $t3, $v0 #put the stack pointer in a temperay register

add_numbers_array:
    bge $t1, $t0, exit # if $t1 > $t0 then exit

    #ask questions
    la $a0, question2_msg #load the question in $a0
    li $v0, 4
    syscall

    #read numbers
    li $v0, 5
    syscall
    move $t2, $a0

    #add number en go to the next array point
    sw $t2, ($t3)
    add $t3, $t3, 4

    #get back to the begin of the loop
    b add_numbers_array


exit :
li $v0 , 10 # let the code end
syscall

1 个答案:

答案 0 :(得分:0)

根据:http://www.doc.ic.ac.uk/lab/secondyear/spim/node8.html syscall 5返回的整数在$v0中,因此您将垃圾传递到下一个尝试分配内存的系统调用。