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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started