assembly - Runtime exception at 0x004002b0: address out of range 0x10400000 -
i'm learning mips assembly language , and i'm having issue part of program getting error "address out of range." please assist me this.
error line 294: runtime exception @ 0x004002b0: address out of range 0x10400000
.data filename: .space 8 filecontents: .space 50000 legalwords: .space 50000 correctwords: .space 50000 .text importfile: li $v0, 13 # open file la $a0, filename # load address filename li $a1, 0 #flags li $a2, 0 #mode 0: read, 1: write syscall # open file (file descriptor returned in $v0) addi $sp, $sp, -4 #make room on stack sw $s6, 0($sp) #save $s6 since using elsewhere move $s6, $v0 # save file descriptor in $s6 li $v0, 14 # system call read file move $a0, $s6 # file descriptor la $a1, filecontents # address buffer store read data li $a2, 500000 # maximum number of characters read syscall # read file li $v0, 16 # system call close file move $a0, $s6 # file descriptor close syscall # close file lw $s6, 0($sp) # restore $s6 addi $sp, $sp, 4 #restore stack . . . #fills word list until , asterix read #a new word stored every 12 bytes. fillwordlist: li $a1, 0 #positon in legalwords li $a2, 0 #currentword position counter fillwordliststart: lb $t0, filecontents($a0) # load current char beq $t0, 42, fillwordlistend # found end of legalwords '*' return beq $t0, 10, saveword #new line char found, current word loaded, go save sb $t0, currentword($a2) #save character currentword add $a2, $a2, 1 #move next position in currentword add $a0, $a0, 1 #move next position in filecontents j fillwordliststart saveword: addi $s1, $s1, 1 mul $t2, $a1, 12 #$t2 contains position in legalwords start storing currentword li $a2, 0 #reset current word position 0 li $t4, 32 #load ' ' char $t4 resetting currentword savewordstart: lb $t3, currentword($a2) #load char @ current position beq $t3, 0, savewordend #reached end of current word return sb $t3, legalwords($t2) #copy legalwords @ current position sb $t4, currentword($a2) add $t2, $t2, 1 add $t3, $t3, 1 add $a2, $a2, 1 j savewordstart savewordend: li $a2, 0 #reset current word position 0 add $a1, $a1, 1 #move next position in wordlist add $a0, $a0, 1 #move next position in filecontents j fillwordliststart fillwordlistend: jr $ra #-------------------------------end fill word list-----------------------------------------------# findfirstword: lb $t0, filecontents($a0) beq $t0, 10, findfirstwordreturn #branches on newline character add $a0, $a0, 1 findfirstwordreturn: add $a0, $a0, 1 move $v0, $a0 #return position of first word jr $ra findnineletterword: beq $v0, 10, findnineletterwordreturn #nine letter word found *start of legalwords j getlength findnineletterwordreturn: add $a0, $a0, -11 move $v0, $a0 jr $ra #----------------------gets length of current word in filecontents--------------------------------------------# getlength: li $a2, 0 #word length getlengthstart: lb $a1, filecontents($a0) beq $a1, 10, getlengthend #new line char found current word length stored add $a0, $a0, 1 #move forward 1 position in file contents add $a2, $a2, 1 #add 1 wordlength j getlengthstart getlengthend: add $a0, $a0, 1 move $v0, $a2 j findnineletterword
Comments
Post a Comment