title: Taking in a String, cutting the first character, then converting to int
body: <p>The code I'm working on takes in a string from the user in the form "X123" (not limited to 3 characters) where X can be any non-number character, and 123 can be any series of number characters. The code then strips the non-number, converts the number part to an int, adds 5, and prints the result. </p>
  
  <pre><code> .data
      msgerror: .asciiz "The string does not contain valid digits."
      input: .space 9 
      open: .asciiz "Enter a string:\n"
      close: .asciiz "The value +5 is:\n"
  
  .text
  .globl main
  
  main:
  
      li $v0, 4
      la $a0, open
      syscall
  
      li $v0, 8      
      la $a0, input        #read a string into a0
      move $t0, $a0
      syscall
  
      li $t3,0
      li $t4,9
      la $t0, input        #address of string
      lbu $t1, 1($t0)        #Get first digit of actual number
      li $a1, 10           #Ascii of line feed
      li $a0, 0            #accumulator
  
      addi $t1,$t1,-48  #Convert from ASCII to digit
      move $a2, $t1         #$a2=$t1 goto checkdigit
      jal checkdigit
      add $a0, $a0, $t1      #Accumulates
      addi $t0, $t0, 1      #Advance string pointer 
      lbu $t1, ($t0)        #Get next digit
  
  buc1:   
      beq $t1, $a1, print #if $t1=10(linefeed) then print
      addi $t1,$t1,-48  #Convert from ASCII to digit
      move $a2, $t1         #$a2=$t1 goto checkdigit
      jal checkdigit
      mul $t2, $a0, 10  #Multiply by 10
      add $a0, $t2, $t1      #Accumulates
      addi $t0, $t0, 1      #Advance string pointer 
      lbu $t1, ($t0)        #Get next digit 
      b buc1
  
  
  
  
  print:  
      add $a0, $a0, 5
      li $v0, 1         
      syscall
      b end
  
  checkdigit:
      blt $a2, $t3, error  
      bgt $a2, $t4, error
      jr $ra
  
  
  
  
  error:
      la $a0, msgerror
      li $v0, 4            #print eror
      syscall
  
  end:    
     li $v0, 10           #end program
     syscall
  </code></pre>
  
  <p>However, my code ends up producing: </p>
  
  <pre><code>Enter a string:
  x123
  The value +5 is:
  1128
  </code></pre>
  
  <p>(128 is the expected).</p>
  
  <p>How can I make one of the duplicate numbers go away? I've tried incrementing the address by 1 with print statements, but it seems not to work with anything else/not as intended.</p>
  
  <pre><code>li $v0,4
  la $a0, aString
  add $a0, $a0, 1
  syscall
  </code></pre>
  
  <p>The above snippet produces 23 if 123 is entered, but I can't get it to apply to the above. </p>
  
  <p>Easier overall approaches are welcome too. New to mips, so I hardly think mine is all that great.</p>