Implement a MIPS program that inputs an arbitrary length string from a user and
ID: 3566973 • Letter: I
Question
Implement a MIPS program that inputs an arbitrary length string from a user and outputs a string that reverses the case of its characters.
For example, given as input: Hello, World! The program should output: hELLO, wORLD!
I started this, but it doesn't quite do what it needs to. Here is what I have so far..The problem is it will change hELLO, wORLD! to HelloL@WorldA
.data
theString:
.space 20
prompt: .asciiz "Enter a string of characters: "
.text
main:
li $v0, 4
la $a0, prompt
syscall
li $v0, 8
la $a0, theString
li $a1, 20
syscall
li $v0, 4
syscall
la $t1,theString
for: lb $a0, 0($t1)
beqz $a0,out #to find out end of string
beq $a0,10,out #to find out end of string
slti $t2, $a0,91 #if $a0<91 $t2=1
beq $t2,1,small
beq $t2,0,capital
capital:
subu $a0, $a0, 32
li $v0,11
syscall
addi $t1,$t1,1
j for
small:
addi $a0, $a0, 32
li $v0,11
syscall
addi $t1,$t1,1
j for
out:
li $v0, 10
syscall
Explanation / Answer
Here is the MIPS program that inputs a string from a user and outputs a string that reverses the case of its characters
; char.asm: character conversion: uppercase to
lowercase
.model small
.stack 100h
CR equ 13d
LF equ 10d
.data
msg1 db
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.