CS 230 Winter 2022 Assignment 4 : Arrays, Standard Input/Output, and the Stack Due Date: Monday, March 7, 11:59 p.m.
• All submissions are to be completed through MarkUs (https://markus.student.cs.uwaterloo.ca/markus_cs230_w/en/assignments)
• Read the policy described in Learn regarding late submissions (https://www.student.cs.uwaterloo.ca/~cs230/w22/outline.shtml)
• Solutions for assignments will not be posted.
Copyright By PowCoder代写 加微信 powcoder
• Your programs must assemble and run properly with the given MIPS assembler binasm
in the student.cs environment.
• The majority of the marks for this assignment will based on correctness. If your program does not assemble, then the correctness marks will be 0. Test your submission thoroughly before submitting.
• Correctness marks are based on passing test cases. No part marks are assigned to the code that is written. Part marks are assigned based on the number of test cases passed.
• Registers are a limited resource. They provide very fast access to data, so programs should optimize their use. A few marks for Question 1 will be assigned to the use of registers. There are no restrictions on the number of registers used for Questions 2 or 3.
• Your solution should include comments at the beginning that include your name, your Quest ID, and a brief description of the program.
• You are not required to comment every line of your program. However, you should include inline comments that highlight the logical steps of your solution.
• You must not change the values of registers $26 through $29 in your programs. However, you are allowed to use any other registers while completing your solutions. The stack ($30) should be restored to its original state at the end of your programs. The contents of registers that are explicitly mentioned in the problem description must meet the specification, however other registers (less than $26) may have random values as required by your solution.
• You may use subprograms in your solutions if you wish, however they are not required. For this assignment only, if you do use subprograms, you are not required to follow the register conventions described in Module 02, Slide 29.
• Double check your submissions in MarkUs after you have uploaded them. It is your responsibility to ensure that the uploaded version is readable in MarkUs.
• Questions 1, 2, 3 are weighted approximately equally.
CS 230 Winter 2022 Assignment 4 Graham
1. Assume that an array has been initialized with integers, where the array location is in register $1 and the array length is in register $2. Write an assembly program that negates the contents of the array.
For example, if the array started with values [7, 0, 15, -3, 6], when the program is done the array will contain the values [-7, 0, -15, 3, -6].
The contents of registers $1 and $2 must be the same at the end of your program as they were at the beginning; however their values may change within the body of the program. If the values of registers $1 and $2 are incorrect, then correctness marks for this question will be 0.
• Test your solution using the arraydump front end. For more information about
how arraydump works, see the solutions to the Lecture 10 practice problems.
• You must use as few registers as possible to receive full marks. The exact number required for full marks will not be published; this is something you need to judge for yourself.
• You should not avoid using registers by temporarily saving values to memory. Memory access with the lw and sw instructions is very slow compared to accessing data in registers, so it would be counter-productive to save a value to memory rather than use a register.
• You cannot use the stack for this question. Submit the file a4q1.asm.
2. Assume that an array has been initialized with integers, where the array location is in register $1 and the array length is in register $2. Write a program that calculates the sum of the numbers in that array that are strictly greater than the average of the numbers in that array. The sum you calculate must be placed in register $1. For example, if the array contains the values 2, 5, 8, -3, 1, then the result in register $1 would be 13, since 2, -3, and 1 are less than or equal to the average, and 5 and 8 are strictly greater than the average. If the size of the array is 0, then the total is 0.
Note, most of the the tests will be on data with positive average. However, there will be at least one test where the average is less than 0.
Submit the file a4q2.asm.
CS 230 Winter 2022 Assignment 4 Graham
3. Wordle is an online word puzzle (https://www.nytimes.com/games/wordle) where people try to guess a word based on feedback from previous guesses. It has become very popular and now there are many variations. This question will have you write a program that provides feedback based on the Wordle puzzle rules.
Write an assembly program that reads two strings from the keyboard. Each string is a single line of input composed of uppercase letters only followed by a new line character. The ASCII code value of a newline character is the hex number 0xA. The strings will be the same length and have at least one letter.
The first string should be considered the target word. This is the word you would be trying to guess in Wordle. The second string should be considered your guess. After you make a guess, feedback is given. There are three possibilities for each letter in the guess:
• This letter appears in the target at the same position. We will call this an exact match.
• This letter appears in the target at a different position. We will call this a partial match.
• This letter does not appear in the target. We will call this no match.
Your program will record the number of exact matches in register $21, partial matches in register $22, and no matches in register $23 for each letter in the guess. It will also print out a summary description of the matching by using a dot (.) to indicate an perfect match, using a plus sign (+) to indicate an partial match, and using a
question mark (?) to indicate no match for each letter in the guess. This summary should be printed on a single line of output followed by a newline character.
The test data for this question will be broken into four categories:
• words with exactly 5 letters and no partial matches
• words with any number of letters and no partial matches
• words with any number of letters, but the letters in each word are distinct, and there may be partial matches
• words with any number of letters and possible duplicate letters in the guess and/or target and there may be partial matches. Where there are duplicate letters that are a partial match, but fewer occurrences of that letter in the target than in the guess (e.g. the last sample test case), then the leftmost occurrences will be considered the partial matches.
Each category will have approximately 41 of the test cases. The last category may be difficult to solve. When working on this problem we highly recommend that you write the program in stages. Write a program that covers at least some of the test cases and submit that to MarkUs as soon as you have something that works correctly. Leave handling the last case until everything else in the assignment is complete and submitted.
CS 230 Winter 2022 Assignment 4
are some sample test cases:
Exact Match Count
Partial Match Count ($22)
No Match Count ($23)
Screen Output
Note that this is not a complete set of test cases, Submit the file a4q3.asm.
but it should be a good guide.
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com