I like to make an array with mips by means of syscalls but i get the error Error in D:\mips\create array line 20: Runtime exception at 0x00400028: request (1074003968) exceeds available heap storage (syscall 9).
mine code is:
.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
According to this: http://www.doc.ic.ac.uk/lab/secondyear/spim/node8.html the integer returned by
syscall 5is in$v0, so you are passing garbage to the next syscall where you try to allocate memory.