Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I believe this is a simple topic. For those who understand him, please help me, don't hesitate, thank you! 1/ revCaseMin.asm # Starter code for

I believe this is a simple topic.

For those who understand him,

please help me, don't hesitate, thank you!

image text in transcribed

1/ revCaseMin.asm

# Starter code for reversing the case of a 30 character input. # Put in comments your name and date please. You will be # revising this code. # # Created by Dianne Foreback # Students should modify this code # # This code displays the authors name (you must change # outpAuth to display YourFirstName and YourLastName". # # The code then prompts the user for input # stores the user input into memory "varStr" # then displays the users input that is stored in"varStr" # # You will need to write code per the specs for # procedures main, revCase and function findMin. # # revCase will to reverse the case of the characters # in varStr. You must use a loop to do this. Another buffer # varStrRev is created to hold the reversed case string. # # Please refer to the specs for this project, this is just starter code. # # In MARS, make certain in "Settings" to check # "popup dialog for input syscalls 5,6,7,8,12" # .data # data segment .align 2 # align the next string on a word boundary outpAuth: .asciiz "This is YourFirstName YourLastName presenting revCaseMin. " outpPrompt: .asciiz "Please enter 30 characters (upper/lower case mixed): " .align 2 #align next prompt on a word boundary outpStr: .asciiz "You entered the string: " .align 2 # align users input on a word boundary varStr: .space 32 # will hold the user's input string thestring of 20 bytes # last two chars are \0 (a new line and null char) # If user enters 31 characters then clicks "enter" or hits the # enter key, the will not be inserted into the 21st element # (the actual users character is placed in 31st element). the # 32nd element will hold the \0 character. # .byte 32 will also work instead of .space 32 .align 2 # align next prompt on word boundary outpStrRev: .asciiz "Your string in reverse case is: " .align 2 # align the output on word boundary varStrRev: .space 32 # reserve 32 characters for the reverse case string .align 2 # align on a word boundary outpStrMin: .asciiz "The min ASCII character after reversal is: " # .text # code section begins .globl main main: # # system call to display the author of this code # la $a0,outpAuth # system call 4 for print string needs address of string in $a0 li $v0,4 # system call 4 for print string needs 4 in $v0 syscall # # system call to prompt user for input # la $a0,outpPrompt # system call 4 for print string needs address of string in $a0 li $v0,4 # system call 4 for print string needs 4 in $v0 syscall # # system call to store user input into string thestring # li $v0,8 # system call 8 for read string needs its call number 8 in $v0 # get return values la $a0,varStr # put the address of thestring buffer in $t0 li $a1,32 # maximum length of string to load, null char always at end # but note, the is also included providing total len  

2/ sum0-100.asm

# prints sums of squares of integers from 0 to 100 # Code from Computer Organization and Design 5th edition # Patterson and Hennessy # Appendix A.1 # Modified by Dianne Foreback to run on MARS simulator # # This code file demos a loop .text .globl main main: subu $sp, $sp, 32 sw $ra, 20($sp) sd $a0, 32($sp) sw $0, 24($sp) sw $0, 28($sp) loop: lw $t6, 28($sp) mul $t7, $t6, $t6 lw $t8, 24($sp) addu $t9, $t8, $t7 sw $t9, 24($sp) #result stored in $t9 addu $t0, $t6, 1 sw $t0, 28($sp) ble $t0, 100, loop la $a0, str #syscall requires $a0 to hold null terminated string #code to print the string using a system call li $v0, 4 # syscall 4 is print string syscall li $v0, 1 # syscall to print integer add $a0, $t9, $zero # register $t9 holds the result syscall # exit MARS gracefully with syscall 10 li $v0, 10 syscall .data .align 0 str: .asciiz "The sum of squares from 0 .. 100 is "

3/ revString_lb_lbu.asm

# Dianne Foreback # Feb 2016 # # Code to show # 1. the difference between lb and lbu # 2. to reverse an input string # # Prompts the user for input of 4 characters. # Stores the user input into memory "thestring" # then displays the stored "thestring" , reverses it # placing the reversed string in "thestringRev", # and displays the reversed string # # This code does NOT use looping # # # If using MARS, make certain in "Settings" to check # "prompt dialog for input syscalls 5,6,7,8,12" # .data # data segment .align 2 # align the next string on a word boundary number: .word -1 # -1 placed in memory prompt: .asciiz "Please enter 4 characters (upper/lower or mixed case): " .align 2 #align next prompt on a word boundary display: .asciiz "You entered the string: " .align 2 # align users input on a word boundary displayRev: .asciiz "And your string reversed is: " .align 2 thestring: .space 6 # will hold the user's input string thestring of 4 bytes # last two chars are \0 (a new line and null char) # If user enters 5 characters then clicks "enter" or hits the # enter key, the will not be inserted into the 6th element # (the actual users character is placed in 5th element). the # 6th element will hold the \0 character. .align 2 # aligns on a word boundary thestringRev: .space 6 # reserve four bytes for the reversed string .text # code section begins .globl main main: ################################################################ # load byte example shows difference between lbu and lb la $t0, number # put the adress of number buffer in $t0 lbu $t1, 0($t0) # first byte of number in the register $t0, zero extended lb $t2, 0($t0) # first byte of number placed in register $t2 is sign extended ############################################################### # system call to prompt user la $a0,prompt # system call 4 for print string needs address of string in $a0 li $v0,4 # system call 4 for print string needs 4 in $v0 syscall ############################################################### # system call to store user input into string thestring li $v0,8 # system call 8 for read string needs its call number 8 in $v0 # get return values la $a0,thestring # put the address of thestring buffer in $t0 li $a1,22 # maximum length of string to load, null char always at end # but note, the is also included providing total len   Write an assembly program revCaseMin.asm where: 1. The main () procedure a. prompts the user to enter 30 characters and stores these characters as a character array into memory b. invokes the revCase ) procedure that accepts as an argument the base address of this character array and the number of characters in this array 2. The revCase() procedure Has two parameters, the base address of a character array and the number of characters in this array. You may not hard code the argument value 30 within this procedure but instead use the 2nd parameter of the procedure. Recall registers $a0 and $a1 will be populated by the calling procedure main ( ) . a. b. Calculates the reverse case of the characters entered by the user placing them in a character array and prints the characters in reverse case using a loop. c. Invokes the function findMin) passing in the required arguments and uses the return value from findMinO. The return value from findMin() is the minimum character entered by the user after the character string is reversed in case. See details that follow for findMin() Prints the minimum character returned from the function findMin() d. 3. The findMin ) function has two parameters: the first parameter is the base address of the character array it will examine and the second is the number of characters that it will examine to find the minimum ASCII character. findMin () returns in $v0 the minimum ASCII character from the string it examined. You may not hard code the value 30 but must instead use the value in the first argument register $al to aid in the looping structure for finding the minimum character, 4. All register conventions and procedure invocation conventions must be adhered--review the MIPS reference sheet for preserving registers across procedure calls and these conventions. Use the starter code file, revCaseMin.asm, making the necessary modifications for this project. Remember, to place YOUR name at the top of the code 5.  Write an assembly program revCaseMin.asm where: 1. The main () procedure a. prompts the user to enter 30 characters and stores these characters as a character array into memory b. invokes the revCase ) procedure that accepts as an argument the base address of this character array and the number of characters in this array 2. The revCase() procedure Has two parameters, the base address of a character array and the number of characters in this array. You may not hard code the argument value 30 within this procedure but instead use the 2nd parameter of the procedure. Recall registers $a0 and $a1 will be populated by the calling procedure main ( ) . a. b. Calculates the reverse case of the characters entered by the user placing them in a character array and prints the characters in reverse case using a loop. c. Invokes the function findMin) passing in the required arguments and uses the return value from findMinO. The return value from findMin() is the minimum character entered by the user after the character string is reversed in case. See details that follow for findMin() Prints the minimum character returned from the function findMin() d. 3. The findMin ) function has two parameters: the first parameter is the base address of the character array it will examine and the second is the number of characters that it will examine to find the minimum ASCII character. findMin () returns in $v0 the minimum ASCII character from the string it examined. You may not hard code the value 30 but must instead use the value in the first argument register $al to aid in the looping structure for finding the minimum character, 4. All register conventions and procedure invocation conventions must be adhered--review the MIPS reference sheet for preserving registers across procedure calls and these conventions. Use the starter code file, revCaseMin.asm, making the necessary modifications for this project. Remember, to place YOUR name at the top of the code 5

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

Advances In Databases And Information Systems Second East European Symposium Adbis 98 Poznan Poland September 1998 Proceedings Lncs 1475

Authors: Witold Litwin ,Tadeusz Morzy ,Gottfried Vossen

1st Edition

3540649247, 978-3540649243

More Books

Students also viewed these Databases questions