2011-07-28 2 views
1

mysc와 함께 syscalls를 사용하여 배열을 만들고 싶지만 오류가 발생합니다. D : \ mips \ create 배열 행에서 오류 발생 20 : 런타임 예외 (0x00400028) : 요청 (1074003968)이 사용 가능한 힙 저장소를 초과합니다 syscall 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 

답변

0

이에 따르면 http://www.doc.ic.ac.uk/lab/secondyear/spim/node8.html$v0syscall 5에 의해 반환되는 정수, 그래서 당신은 당신이 메모리를 할당하려고 다음 콜에 쓰레기를 전달하고 있습니다.

+0

감사합니다. 내 측면에서 큰 실수였습니다. 그게 문제 였어. 이제 거의 효과가있다. – Bjorn