Program:-
.data
prompt .ascizz "enter the string\n"
userInput: .space 100
error_msg: .ascizz "Empty string....error.Please try again\n"
character_msg: .ascizz "\nthe number of characters is :"
space_msg: .ascizz "\nthe number of spaces is :"
sentence_msg: .ascizz "\nthe number of sentences is :"
uppercase_msg: .ascizz "\nthe number of uppercase alphabets is
:"
lowercase_msg: .ascizz "\nthe number of lowercase alphabets is
:"
word_msg: .ascizz "\nthe number of words is :"
punc_msg: .ascizz "\nthe number of punctuations is :"
.text
.globl main
main:
la $a0,prompt
li $v0,4
syscall
li $v0, 8
la $a0, userInput
li $a1, 200
syscall
la $t0,userInput
#check for empty string
lb $t1,0($t0)
beq $t1,$zero,error_funct
#checking for conditions
la $t0,userInput
li $t2,0 #character count
li $t3,0 #space count
li $t4,0 #sentence count
li $t5,0 #upper_case count
li $t6,0 #lower_case count
loop:
lb $t1,0($t0)
beq $t1,$zero,prints
addi $t2,$t2,1
addi $t7,$0,32 #ascii for space
bne $t1,$t7,sentence_check
addi $t3,$t3,1
sentence_check:
addi $t7,$0,46 #ascii for dot
bne $t1,$t7,uppercase_check
addi $t4,$t4,1
uppercase_check:
addi $t7,$0,65 #ascii for A
bl $t1,$t7,lowercase_check
addi $t7,$0,90 #ascii for Z
bg $t1,$t7,lowercase_check
addi $t5,$t5,1
lowercase_check:
addi $t7,$0,97 #ascii for a
bl $t1,$t7,l_count_increment
addi $t7,$0,122 #ascii for Z
bg $t1,$t7,l_count_increment
addi $t6,$t6,1
l_count_increment:
addi $t0,$t0,1
b loop
prints:
la $a0,character_msg
li $v0,4
syscall
li $v0, 1
move $a0, $t2
syscall
la $a0,space_msg
li $v0,4
syscall
li $v0, 1
move $a0, $t3
syscall
la $a0,sentence_msg
li $v0,4
syscall
li $v0, 1
move $a0, $t4
syscall
la $a0,uppercase_msg
li $v0,4
syscall
li $v0, 1
move $a0, $t5
syscall
la $a0,lowercase_msg
li $v0,4
syscall
li $v0, 1
move $a0, $t6
syscall
la $a0,word_msg
li $v0,4
syscall
addi $t7,$t3,1
li $v0, 1
move $a0, $t7
syscall
la $a0,punc_msg
li $v0,4
syscall
#punctuation marks = total - spaces - uppercase count -
lowercase count
sub $t7,$t2,$t3
sub $t7,$t7,$t5
sub $t7,$t7,$t6
li $v0, 1
move $a0, $t7
syscall
exit:
li $v0, 10
syscall
error_funct:
la $a0,error_msg
li $v0,4
syscall
li $v0, 10
syscall
Note: Could you please consider my effort on this work and give me a UPVOTE. Thank you :)
Create a program that performs the following operations: 1. Prompt for and accept a string of...
Create a program that performs the following operations: Prompt for and accept a string of up to 80 characters from the user. • The memory buffer for this string is created by: buffer: .space 80 # create space for string input • The syscall to place input into the buffer looks like: li $v0, 8 # code for syscall read_string la $a0, buffer # tell syscall where the buffer is li $a1, 80 # tell syscall how big the buffer...
MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and print a simple checksum for each string. Make your string long enough to hold 50 characters. Don't forget to leave space for the null byte. Our checksum algorithm will produce a value which you can print with the syscall for printing a character. Stop reading strings when the user enters ".". The syscall to read a string (sycall code 8) adds a newline to...
Prompt the user and read in a string. Make your string large enough to hold 100 characters. 2. Count the number of words in the string. A word is one or more non-blank characters separated by one or more blanks. My suggestion is to use a flag (a boolean variable) to indicate whether or not you are in a word. Then you know you have found a word when the flag indicates that you are in a word and the...
Prompt the user to enter two character strings. The program will then create a new string which has the string that appears second, alphabetically, appended to the end of the string that shows up first alphabetically. Use a dash (-') to separate the two strings. You must implement the function string appendStrings(string, string), where the return value is the combined string. Display the newly created string. Your program must be able to handle both uppercase and lowercase characters. You are...
10. replaceSubstring Function Write a function named replaceSubstring. The function should accept three C-string or string object arguments. Let's call them string1, string2, and string3. It should search string for all occurrences of string2. When it finds an occurrence of Programming Challenges string2, it should replace it with string. For example, suppose the three arguments have the following values: stringt: "the dog jumped over the fence" string 2 "the" string3: "that" With these three arguments, the function would return a...
2. Searching a String: Write a MIPS assembly language program to do the following: Read a string and store it in memory. Limit the string length to 100 characters. Then, ask the user to enter a character. Search and count the number of occurrences of the character in the string. The search is not case sensitive. Lowercase and uppercase letters should be equal. Then ask the user to enter a string of two characters. Search and count the number of...
MIPS - Takes two inputs from the user, which are the lengths of two sides of a polygon. It adds those two lengths and prints the sum. Your task is modify the program to make it specific to a triangle, and to print the perimeter of that triangle. See blue highlighted. preamble: prompt1: prompt2: answer: endline: .data ascii .asciiz asciiz .asciiz asciiz .asciiz "\nThis program, written by <YOUR NAME>," " can be used to add the length of two sides...
im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...
C++ assignment. Please help me to complete this code: #include <string> #include <iostream> using namespace std; // Write your function here //////////////// STUDENT TESTING //////////////////// int run() { cout << "Student testing" << endl; strip(); return 0; } Here is the instruction: Write a filter function named strip that removes C++ comments from input, sending the uncommented portion of the program to output. Your program should work with both single line (//) comments, and multi-line (/* */) comments. + A...