arrays - MIPS accepting blank input -


i have function in mips collects user input , puts array of integers. how not crash on blank input? there sort of catch unaware of?

obviously test has performed in loop, how can know being input if not integer. value 5 in $v0 register ensures integers collected.

here function:

#################################################################################### # gather numbers # collection loop in order user input numbers, integers # accepted, , blank inputs. # a0 = base address of array. #################################################################################### gather_numbers: addi $sp, $sp, -16 sw $a0, 0($sp) sw $s0, 4($sp) sw $s1, 8($sp) sw $t1, 12($sp)  move $s0, $a0 #the address of array lw $s1, size # load size li $t1, 0 # enters loop  start_gather_numbers: beq $t1, 9999, exit_gather_numbers               li $v0, 5 # read integer               syscall               sw $v0, 0($s0)               move $t1, $v0 # put value t1 tested               addi $s0, $s0, 4 #increment address               addi $s1, $s1, 1 # increment size               j start_gather_numbers exit_gather_numbers:  addi $s1, $s1, -1 # fix size                   sw $s1, size # store size               lw $a0, 0($sp) # pop stack               lw $s0, 4($sp)               lw $s1, 8($sp)               lw $t1, 12($sp)               addi $sp, $sp, 12               jr $ra 

i figured out how use exception handlers. when exception thrown, program jumps different address. can put custom instructions @ specific address complier follow. helps program die gracefully, or continue correcting input.

check out link http://courses.missouristate.edu/kenvollmar/mars/help/marsexceptions.html


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -