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 the string (before the null byte) if the string is shorter than the maximum length specified. If there is a newline in the string that you read, replace it with a null byte Do not use the newline when calculating the checksum.
To calculate our checksum, add up the ASCII codes for the characters in the string, then find the remainder after dividing by 64. Finally, add the ASCII code for blank to the remainder. This give you the checksum.
Hints
Sample Execution
Enter a string (. to end): Error Correction! The checksum is: C Enter a string (. to end): Java C C++ The checksum is: > Enter a string (. to end): UNIX Linux The checksum is: T Enter a string (. to end): macOS 10.12.2 The checksum is: % Enter a string (. to end): .
Program:

Sample output:

Code to copy:
####################### checksum.asm ###########################
.data
prompt: .asciiz "Enter a string (. to end): "
msg: .asciiz "The checksum is: "
newline:.asciiz "\n"
theString: .space 51
.text
main:
la $a0,prompt # prompt for input string
li $v0,4
syscall
li $v0, 8 # 8=read string
la $a0, theString
li $a1, 51 # set maximum length of string to 51
# (including null byte)
syscall # read string
li $t1,1 # len=0
la $t0,theString
L0:
lbu $t2,($t0)
beq $t2,$zero,exit_L0
beq $t2, 46 ,check # 46= ASCII of '.'
add $t0,$t0,1
add $t1,$t1,1
j L0
exit_L0:
j Chk_for_newline
check:
beq $t1,1,ExitProg # if length=0 and string is "."
# go to label ExitProg
Chk_for_newline:
la $t0,theString
L1:
lbu $t1,($t0) # load current character
beq $t1,$zero,sumLoop # if reached end of the string, go to sumLoop
beq $t1,10,replace # go to replace
j next
replace:
sb $zero,($t0)
next:
add $t0,$t0,1 # go to next character
j L1
sumLoop:
la $t0,theString
li $s0,0 # checksum=0
L2:
lbu $t1,($t0) # load current char
beq $t1,$zero,exitL1 # reached end of the string
add $s0,$s0,$t1 # add char to checksum
add $t0,$t0,1 # move to next character
j L2
exitL1:
div $s0,$s0,64 # divide the sum by 64
mfhi $s0 # store remainder into $s0
add $s0,$s0,32 # add ASCII code for blank(space)
la $a0,msg
li $v0,4
syscall
move $a0,$s0 # print the checksum
li $v0,11
syscall
la $a0,newline # print new line
li $v0,4
syscall
j main
ExitProg:
li $v0, 10
syscall
MIPS ASSEMBLY PROGRAM: PLEASE Write in MIPS Assembly language. Take strings as input and calculate and...
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...
Create a program that performs the following operations: 1. 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 is syscall 2....
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 programming question Problem 1: Write a program that asks the user to input a string (or no more than 50 characters). Your program should then output the length of the string. The string length should be determined using a separate function strlen that will accept the address of the string and return its length. For the purposes of this exercise, the length of a string will be defined as the number of non-null and non-newline characters until either the...
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...
Write a procedure, bfind( ), in C code using pointer-based and convert it into MIPS assembly language with clear and necessary comments. The procedure should take a single argument that is a pointer to a null-terminated string in register $a0. The bfind procedure should locate the first character b in the string and return its address. If there are no b’s in the string, then bfind should return a pointer to the null character at the end of the string....
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,...
Write a program in LEGv8 assembly to copy a null-terminated ASCII string from array y to array x; converting every 'a' character in the source string to 'b' in the destination string. In other words, for each character in array y: else Assume that the base address of the arrays x and y are in registers X0 and X1, respectively. The ASCII code for characters 'a' and 'b' is 113 and 114 respectively [25 pts]. * Null-terminated means that a...
ASSEMBLY LANGUAGE
Write a program using author's routine, WriteString, to print
"Hello World". This routine will output to the screen any character
data pointed to by the EDX register. It will continue to print
until it runs into the null character (zero). We need only to move
the address into the EDX register and calll his routine. Lookup in
the ASCII code chart the value reqresented by CR and LF. In the
program I will define these values using the...