Question: I have to write a MIPS assembly that asks the user for a string, and inverts the case of every letter in it. My code

I have to write a MIPS assembly that asks the user for a string, and inverts the case of every letter in it.

My code so far only changes the lower case letters to upper case but doesn't change the upper case to lower case.

.data input: .space 20 newline: .asciiz " "

.text .globl main main: li v0, 8 li a1, 20 la a0, input syscall

li v0, 4 li t0, 0

loop: lb t1, input(t0) beq t1, 0, exit blt t1, 'a', case bgt t1, 'z', case sub t1, t1, 32 sb t1, input(t0)

case: addi t0, t0, 1 j loop

exit: li v0, 4 la a0, input syscall

li v0, 10 syscall

The correct output example should be: HelLo WorLd!!!1! -> hELlO wORlD!!!1!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!