The program accepts a single-letter keyboard input at a time. The letter inputs must be lower case a through z (no upper-case or non-letter characters allowed; only lower-case letters). Only one letter must be input at a time; make sure that the character is ONLY a lower-case letter.
• In the data declaration, declare an alphabetized string of letters (named “str”), a-z.
• The program must input a character from the keyboard, determine its place in the string, and make a space in the string for this character, inserting it in the proper alphabetical order.
• After the alphabetized string of 26 letters, declare a sequence of 30 nulls (using the “.space” directive), as expansion space for the string as you insert characters into the alphabetized list.
• At any point, you can ask to print the current string (i.e., with as many letter inserts as have been made so far) by inputting capital P from the keyboard.
• Finally, this program MUST use a recursive routine to insert the letter in the correct point in the program.
My code so far
.data
str: .asciiz"abcdefghijklmnopqrstuvwxyz\n"
espace: .space 30
prompt: .asciiz "Please enter a lowercase letter \n"
error1: .asciiz "Error! Please input a lowercase letter. \n"
answer: .asciiz "The alphebetized letters so far are \n"
.text
main: la $s0,0
li $v0,4
la $a0,prompt
syscall
loop: li $v0,12
syscall
move $t0,$v0
blt $t0,61,error #if less than a
bgt $t0,80,error #if more than z
bge $t0,0x50,print #when user enters P, print
loop2: lb $t2,str($s0) #load first byte of string
bge $t0,$t2,store #if input char=string char, store it
addi $s0,$s0,1 #next char in string
j loop
store: la $t0,str+26
li $t1,'a'
sb $t1,($t0) # append an 'a' to the string
sb $zero,1($t0) # add a NULL terminator after the 'a'
sw $t0,str($s0) #store char in string
addi $s0,$s0,1
j loop
error: li $v0,4
la $a0,error1 #print error message
syscall
j loop #jump back to loop
print: li $v0,4
la $a0,answer #print dialogue
syscall
li $v0,4
la $a0,str #print string
syscall
I just need to know how to write the code so that it inputs the character in the string