CDA3100 - SUMMER 2018 ASSIGNMENT 6 SUDOKU Objectives: Learn how to write an asse
ID: 3911422 • Letter: C
Question
CDA3100 - SUMMER 2018 ASSIGNMENT 6 SUDOKU
Objectives:
Learn how to write an assembly program that consists of functions, learn the MIPS calling conventions, and learn how to access a two-dimensional array in assembly language. This will also be an exercise in gaming and game strategy solutions.
The Classic Sudoku is a number placing puzzle based on a 9x9 grid with several given numbers. The object is to place the numbers 1 to 9 in the empty squares so that each row, each column and each 3x3 box contains the same number only once. The following is an example of a valid Sudoku puzzle.
Write in mips, and make sure it runs on QTSPIM
2
7
1
9
5
4
6
8
3
5
9
3
6
2
8
1
4
7
4
6
8
1
3
7
2
5
9
7
3
6
4
1
5
8
9
2
1
5
9
8
6
2
3
7
4
8
4
2
3
7
9
5
6
1
9
8
5
2
4
1
7
3
6
6
1
7
5
9
3
4
2
8
3
2
4
7
8
6
9
1
5
Specifications:
1. There will be 2 test files:
a. puzzle1.dat # Valid Puzzle.
b. puzzle2.dat # Invalid Puzzle
2. Use the sample code provided to read in the file name, open the file, and read the file into a character array.
3. The file will consist of 81 consecutive integer numbers separated by one space.
a. The first set of 9 numbers will be row 1st, the second set of 9 numbers will be the 2nd row, the third set of 9 numbers will be the 3rd Row, etc.
b. You can assume that the file will be correct and have exactly 81 numbers with no invalid integers ( i.e. less than 0 or greater than 9).
4. Your Program must incorporate the following:
a. parameter passing and return values
b. preserving register values, as presented in class
c. In addition, you should not have any conditional branch instructions that cross function boundaries.
d. A comment beside each instruction is required in the assembly program (or at a minimum a comment for a small group of related instructions) to help make your code more understandable. You should also have comments at the top of the file indicating your name, this course, and the assignment.
5. Your program must indicate whether the file that was submitted represents a valid solution, or whether there is an error in the row, column, and/or 3x3 quadrant.
Grading
In order to be graded the program must assemble and allow the grader to start the program.
- 10% - Proper declaration of the 2d array and references the array properly
- 10% - Program properly documented
- Contains comments that identifies the programmer - Contains comments that describe how the program works.
- 25% - Program is modular.
~ Has functions with at least one instance of passing parameters using standard calling conventions and preserving registers.
~ Has functions with at least one instance of returning a value using standard calling conventions and preserving registers - 55% - Correct implementation.
~ 10% Identifies valid files and continues to ask for a valid false
~ 15% Identifies valid Sudoku solutions
~ 30% Identifies errors with individual errors in Rows, Columns, or 3x3 Quadrants
input.dat File
2
7
1
9
5
4
6
8
3
5
9
3
6
2
8
1
4
7
4
6
8
1
3
7
2
5
9
7
3
6
4
1
5
8
9
2
1
5
9
8
6
2
3
7
4
8
4
2
3
7
9
5
6
1
9
8
5
2
4
1
7
3
6
6
1
7
5
9
3
4
2
8
3
2
4
7
8
6
9
1
5
Sample Output: puzzlel.dat file 1112131415161718191 14151617181911 12131 71819111213141516 121311151614191718 1516141819171311121 81917121311161415 131112161415181917 614151917181213111 91718131112151614 Valid Sudoku PuzzleExplanation / Answer
THE ARGUMENT SHOULD BE 0 The function unsigned int random(void); will be used in your implementation of RandomIntRange, which is described below. You can use any other functions from util.s that you want. InitRandom Before you start your first guessing game, you must initialize the random number generator by calling InitRandom, which you must implement: void InitRandom(int offset) InitRandom must initialize the random number generator by: ? getting the time-of-day (from time(0)) (Make sure you pass time the single argument of constant zero. This will allow your code to run on the MIPS virtual machine later.) ? adding a 4-digit number of your choice to the time (such as the last four digits of your student id), passed to InitRandom as offset ? passing the resulting seed to srandom() RandomIntRange Once the random number generator is initialized, you get a secret number by calling RandomIntRange, which you must implement. int RandomIntRange(int low, int high) This returns a pseudorandom integer in the range [low,high] by ? retrieving a random number from the generator using random(). This returns an integer in [0,MAX], where MAX is very large. ? converting the random number to a number in your range by performing appropriate arithmetic on it (see the More Help notes below) Putting it all together Your program will end up in several pieces, depending on how you write it. An example is: guess_main.s - your main program and get_guess RandomIntRange.s - RandomIntRange and InitRandom - the random number generator pieces create_question.s - the completed function to create the question - available in the asmt05 directory as create_question.s.skel util.s - a copy of util.s You can then create your program to run under MARS by cat-ing your files together and .include-ing util.s, or another way is by using the 'assemble all files in a directory' option. Requirements There are some requirements for how you write your program: ? Constant strings and integers may be initialized in static data (.data) and used by (but not modified by) functions in your program. Otherwise, data used by a function that is not kept in a register must be local (i.e., on the stack) or allocated dynamically (on the heap using malloc()). ? The values of min and max must be part of your question when asking for a guess. You must allow someone to change max easily by editing its static .data value before starting your program, and the current value, of course, must be displayed.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.