Question

In: Computer Science

For Project 2, write a program for MIPS that performs the following steps. It 1. Receives...

For Project 2, write a program for MIPS that performs the following steps. It

1. Receives a string of upper- and/or lowercase letters from keyboard (user types the letters on the SPIM console window).

2. Stores ASCII codes of the letters in stack.

3. Stop receiving letters when ? is typed by the user.

4. Converts uppercase letters to their lowercase letters and vice versa, and prints the converted string on the SPIM console window.

Assume only valid inputs are typed by the user (i.e., only alphabetic characters and ?). So, your program is not responsible for a wrong input; garbage in, garbage out (GIGO).

Solutions

Expert Solution

Greetings!!

Code:

.data
prompt: .asciiz "Enter the string of your choice: "
string: .space 250
size: .byte 250
.text
#display prompt message
la $a0,prompt
li $v0,4
syscall
#read string
la $a0,string
li $a1,250
li $v0,8
syscall
#processing
loop:
lb $t0,0($a0)       #load byte
beq $t0,0x0a,end   #if newline then goto end
beq $t0,32,skip       #if space then goto skip
bgt $t0,0x7B,invalid   #if greaterthan upperlimit goto invalid
blt $t0,0x40,invalid   #if less than lower limit goto invlid
bgt $t0,0x60,makeupper   #if greaterthan 60 goto makeupper
addi $t0,$t0,0x20   #smaller and hence add 0x20 or 32 to make upper
j skip
makeupper:
addi $t0,$t0,-32   #if upper, convert to lower by subtracting -32
skip:
sb $t0,0($a0)       #store byte
addi $a0,$a0,1       #increment array index
j loop           #repeat
invalid:
end:
#display string
la $a0,string
li $v0,4  
#termination
syscall
li $v0,10
syscall


Output screenshot:

Hope this helps


Related Solutions

1. Write a Python program that performs the following: 2. Defines an array of integers from...
1. Write a Python program that performs the following: 2. Defines an array of integers from 1 to 10. The numbers should be filled automatically without the need for user inputs 3. Find the sum of the numbers that are divisible by 3 (i.e., when a number is divided by 3, the remainder is zero) 4. Swap the positions of the maximum and minimum elements in the array. First, you need to find the maximum element as shown in the...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
Write a MIPS program that asks the user for 2 numbers. Output the sum of the...
Write a MIPS program that asks the user for 2 numbers. Output the sum of the 2 numbers. The difference between the 2 numbers (num1-num2) and (num2-num1) The value that is 305 more than the 1st number. The value that is 305 less than the 2nd number
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS)...
Coding Problem 1: In this program, you are asked to write a program in assembly (MIPS) which works as a simple calculator. The program will get two integer numbers, and based on the requested operation, the result should be shown to the user. a. The program should print a meaningful phrase for each input, and the result. i. “Enter the first number” ii. “Enter the second number” iii. “Enter the operation type” iv. “The result is” b. The user should...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
Write a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
In C: Write a complete program that performs the following task: Ask the user for the...
In C: Write a complete program that performs the following task: Ask the user for the number of sequences to display. For each sequence, Ask the user for a starting value Print out the value and double it (multiply by 2). Continue printing and doubling (all on the same line, separated by one space each) as long as the current number is less than 1000, or until 8 numbers have been printed on the line. You may assume that the...
Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884]...
Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884] (Copy the 32-bit data at data memory address 6884 to data memory address 6892.) 2. DM[7968] = DM[6796] + DM[6800] (Add the 32-bit data at data memory address 6792 and the 32-bit data at data memory address 6800, then store the sum into data memory address 7968.)
Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884]...
Write a MIPS assembly program to implement each of the following operations. 1. DM[6892] = DM[6884] (Copy the 32-bit data at data memory address 6884 to data memory address 6892.) 2. DM[7968] = DM[6796] + DM[6800] (Add the 32-bit data at data memory address 6792 and the 32-bit data at data memory address 6800, then store the sum into data memory address 7968.)
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1....
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods you...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT