Question: Assembly code Create a program that performs the following operations: 1. Prompt for and accept a string of up to 85 characters from the user.
Assembly code
Create a program that performs the following operations: 1. Prompt for and accept a string of up to 85 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, 85 # tell syscall how big the buffer is syscall 2. Determine how long the string which was entered. Every string that is entered will have a newline character (0x0a) appended to its end and then lastly the null character (0x00). Do not count either of these characters when reporting the string length (stop scanning when you reach the newline character). You can use the la instruction to place the address of the buffer in a register. The lb (load byte is used just like lw) instruction can be used to read a byte from memory into a register (it will be placed on the right end of the register and the upper part of the register will be zeroed out. Use code similar to this to count the characters in the string. la $t0, buffer # place address of buffer in $t0 myloop: lb $t1, 0($t0) # read byte located at address in $t0 . . # logic including code to leave loop . addi $t0, $t0, 1 # increment address in $t0 j myloop # jump to myloop loopDone: 3. Determine how many uppercase letters are in the string. 4. Determine how many lowercase letters are in the string. 5. Determine how many digits are in the string. 6. Determine how many spaces are in the string. 7. Subtract the sum of 3-6 from the string length to determine how many other characters are in the string. 8. Your output should look approximately like this (user input is show in bold here): Enter a string: abc234## Your string contains: 16 characters. There are 3 upper case characters. There are 4 lower case characters. There are 4 digits. There are 0 spaces. There are 5 other characters. 9. use a separate loop for each of the task from 3 to 6 rather than attempting to do all in a single loop
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
