Write a complete MIPS program to toggle the case of all alphabetic characters in
ID: 3606019 • Letter: W
Question
Write a complete MIPS program to toggle the case of all alphabetic characters in a C-string held in RAM in your program. Declare the string with a reasonable value (a 5 or 6 word sentence with spaces and punctuation) and print it before and after toggling the case of all alphabetic characters in the string. Do not add notes to the top of the program, but you may comment individual lines. The upper-case characters are 32 less than their corresponding lower-case characters. (less than 40 lines of code)
Explanation / Answer
.data
string4:.space 82
strPrompt:.asciiz "Please enter a string: "
.text
.globl main
main:
la $a0, strPrompt
li $v0, 4
syscall
la $a0, string4
li $a1, 80
li $v0, 8
syscall
la $a0, string4
li $v0, 4
syscall
la $t0, string4
li $t1, 0
loop4:
lb $t1, 0($t0)
nop
nop
beqz $t1, done4
bgt $t1, 90, else
nop
addi $t1, $t1, 0x20
sb $t1, 0($t0)
addi $t0, $t0, 1
j loop4
nop
else:
addi $t1, $t1, -0x20
sb $t1, 0($t0)
addi $t0, $t0, 1
j loop4
nop:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.