Write a complete MIPS program that asks the user for a strin

Write a complete MIPS program that asks the user for a string and a character, replaces all instances of the specified character with ‘#’ and then inverts the case of all remaining letters from uppercase to lowercase and from lowercase to uppercase. Then print the string to standard output (using a syscall). To call your ‘replaceLetterWithHash and ‘invertCase’ functions, use the jump and link (jal) instruction.

The replaceLetterWithHash function takes two arguments as inputs. Use the MIPS calling convention; use $a registers to pass the arguments to your function. The first argument contains the string address and the second argument contains the character to replace.

The invertCase function takes the address of a string and transforms the lowercase characters in the string to their corresponding uppercase ones and converts the uppercase letters in the string into lowercase ones. Use the MIPS calling convention to pass the argument to your function.

Solution

Here\'s the code which works perfectly:

.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

Write a complete MIPS program that asks the user for a string and a character, replaces all instances of the specified character with ‘#’ and then inverts the c
Write a complete MIPS program that asks the user for a string and a character, replaces all instances of the specified character with ‘#’ and then inverts the c

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site