Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Uses MIPs and must look like the output displayed below - I attempted #1 - 4 but i'm not sure if it's the correct

- Uses MIPs and must look like the output displayed below

- I attempted #1 - 4 but i'm not sure if it's the correct way to do it

------------

The steps for the code:

  1. Print the string at label num to the screen as a string (use syscall) on its own line

  2. Prompt the user (print to the screen) to enter a single lowercase letter using the label prompt (use a syscall). Error checking isnt necessary (assume that the user follows directions)

  3. Read in the 1 character from the user (use syscall 12) and store the character (sb) into memory at label num. Save this character value in a saved temporary register for later use

  4. Print a newline (label endl) to the screen. Print the label num to the screen as a string (use syscall) on its own line. Load the byte at address num + 2 into a temporary register (referred to as Reg A). Add 32 to Reg A and store it back into Reg and store the value back into memory at address num + 2. Print the string at label num to the screen as a string (use syscall) on its own line.

  5. Load the word at the label num into a temporary register (referred to as Reg B). Shift Reg B right logical by 8 bits and store the value back into Reg B

  6. Shift Reg A left by 3 bytes (24 bits) placing the result back into Reg A. Add the value of Reg A to Reg B and store the result of the operation as a word (sw) into memory at the label num

  7. Print the label num to the screen as a string (use syscall) on its own line

  8. Store byte the value of Register 0 (aka $0) into the address of (num + 4)

  9. Print the label num to the screen as a string (use syscall) on its own line

  10. Load the word of data stored at label num into a temporary register, Reg A

  11. Rotate the value right 4 bits and store the result back into Reg A. Print the label num to the screen as a string (use syscall) on its own line

  12. Store the modified value, Reg A, as a word into memory at the label num. Print the label num to the screen as a string (use syscall) on its own line

  13. Rotate the value right 4 more bits. Store the modified value into memory at the label num. Print the label num to the screen as a string (use syscall) on its own line

  14. Use the print string syscall to print the string starting at the label myspace on its own line

  15. Load the word of data stored at label myspace into a temporary register, Reg A. Add the saved register, from instruction 3 to the value, replacing the value in Reg A. Store word the result back into memory at label myspace. Use the print string syscall with the label myspace on its own line again

  16. Add 1 to Reg A and store the byte into memory at myspace + 1. Use the print syscall with the label myspace again

  17. Print a newline and then quit the program

Code:

.globl main .text main:

# Your code goes here

#step 1 li $v0, 4 la $a0, num syscall #step 2 addi $v0, $0, 4 la $a0, prompt syscall li $v0, 8 syscall #step 3 li $v0, 12 sb $v0, 12($0) #idk if this is correct #step 4 li $v0, 4 la $a0, endl syscall li $v0, 4 la $a0, num syscall

.data prompt: .asciiz "Enter a lowercase letter: " endl: .asciiz " " .align 2 num: .word 0x44434241 myspace: .byte '#', 0x00, '@', '%' stop: .byte 0x00

Output:

image text in transcribedimage text in transcribed

Example expected MARS output [1/5/21 @ 10am - Labels added to help see which step produces which output] ABCD# Enter a lowercase letter: t tBCD# tBcD# BcDc# BcDc Step 1 Step 2 Step 4 First print Step 4 Second print Step 7 Step 9 Step 11 Step 12 Step 13 Step 14 Step 15 Step 16-17 BcDc 4F4& cDcB t tu@% program is finished running ABCD# Enter a lowercase letter: z ZBCD# zBcD# BcDc# BcDc BcDc 4F4& cDcB z z{@% program is finished running

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

Step: 3

blur-text-image

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

You can convey the same meaning without (utilizing) the same words.

Answered: 1 week ago