Answer:
Check the explanation
Explanation:
.data
prompt: .asciiz "Please enter your string :"
result_str: .asciiz "\nYour captalized string :"
error_prompt: .asciiz "\nInvalid Entry !"
buffer: .space 20
.text
.globl __start
__start:
ASKING_STR:
la $a0,prompt
li $v0,4
syscall
li $v0,8 #take in input
la $a0, buffer #load byte space into address
li $a1, 20 # allot the byte space for string
move $t0,$a0 #save string to t0
syscall
li $v0, 4
li $t0, 0
loop:
lb $t1, buffer($t0)
beq $t1, 0, exit
slti $t2,$t1,91
bne $t2,$0,UPPER_CHECK
slti $t2,$t1,123
bne $t2,$0,LOWER_TO_UPPER
UPPER_CHECK:
slti $t2,$t1,65
bne $t2,$0,INVALID_ENTRY
slti $t2,$t1,90
bne $t2,$0,NEXT
j INVALID_ENTRY
LOWER_TO_UPPER:
sub $t1, $t1, 32
sb $t1, buffer($t0)
NEXT:
addi $t0, $t0, 1
j loop
INVALID_ENTRY:
li $v0, 4
la $a0, error_prompt
syscall
j ASKING_STR
exit:
li $v0, 4
la $a0, result_str
syscall
li $v0, 4
la $a0, buffer
syscall
li $v0, 10
syscall