2011-07-28 9 views
1

私はmyscを使用してsyscallsを使用して配列を作成したいのですが、エラーが発生します:D:\ mips \ create array line 20:実行時例外0x00400028:request(1074003968)システムコール9)。array mipsを作成する際にエラーが発生する

鉱山コードです:

.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.htmlsyscall 5によって返される整数は$v0であるので、あなたがメモリを割り当てよう次のシステムコールにゴミを渡しています。

+0

ありがとうございました。それは私の側から大きなミスでした。それが今問題になった – Bjorn