Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MIPS program that has two procedures.The first procedure is tolower to convert a null terminated string to all lowercase. Do not convert characters

Write a MIPS program that has two procedures.The first procedure is tolower to convert a null terminated string to all lowercase. Do not convert characters that are already lowercase. Count the number characters that you convert to lowercase. Pass the memory location of the from string to convert in $a0. Pass the memory address of the string to copy the converted string into in $a1. Return the number of characters that were translated in $v0. The second procedure is toupper to convert a null terminated string to all uppercase. Do not convert characters that are already uppercase. Count the number of characters that you convert to uppercase. Pass the memory location of the from string to convert in $a0. Pass the memory address of the string to copy the converted string into in $a1. Return the number of characters that were translated in $v0. In your mainline, Ask the user for a string to convert to lowercase. Print the converted string and the number to characters translated. Ask the user for a string to convert to uppercase. Print the converted string and the number to characters translated.

Example output:

Enter a string to convert to lowercase: Hello World. I am 100 years old!

The converted string is: hello world. i am 100 years old!

The number of translations is: 3

Enter a string to convert to uppercase: Hello World. I am 100 years old!

The converted string is: HELLO WORLD. I AM 100 YEARS OLD!

The number of translations is: 18

This is what I have it only converts one character to lowercase, I wanted to make sure that worked before trying my loop.I'm not sure how the loop should be written, or how to correctly do the translations.

.data getlower: .asciiz "Enter a string to convert to lowercase:" getupper: .asciiz "Enter a string to convert to uppercase:" convertedstring: .asciiz "The converted string is:" maxstring: .word 100 #allows you to store this many characters -1 for the null inString: .space 0 #or can use .asciiz storebyte: .byte #stores byte .text

#print "Enter a string to conver to lowercase:" la $a0,getlower li $v0,4 syscall

#code to store the string (allows the user to provide input) la $a0, inString lw $a1, maxstring #stores our characters li $v0,8 syscall

jal tolower

j exit

#procedure to convert uppercase to lower case tolower:

#create a loop to check each character to convert it from uppercase to lowercase

#loop:

#try to convert one letter H=72 if asciiz value is between 65 and 90 convert capital to lower case lb $t0,0,($a0) #adds 32 to convert capital letters to lowercase letters add $t0,$t0,32 sb $t0,storebyte la $a0,storebyte li $v0,4 syscall

#j loop:

jr $ra

exit:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Are robots going to displace all workers? Explain your answer.

Answered: 1 week ago