DPST1092 22T2
Assignment 1: mipstermind, Mipstermind
Copyright By Assignmentchef assignmentchef
DPST1092 22T2
Assignment 1: mipstermind, Mipstermind
version: 1.0
last updated: 2022-07-02 09:00:00
to give you experience writing MIPS assembly code
to give you experience with data and control structures in MIPS
Getting Started
Create a new directory for this assignment
called mipstermind,
change to this directory,
and fetch the provided code
by running these commands:
mkdir mipstermind
cd mipstermind
1092 fetch mipstermind
This will add the following files into the directory:
mipstermind.c: an implementation of Mastermind in C,
mipstermind.s: a stub assembly file to complete.
It will also add some game-configuration MIPS files.
When running Mipstermind, you will need to load one
of the following files alongside your mipstermind.s file:
easy.s: some very easy settings
normal.s: the classic Mastermind settings
hard.s: a harder challenge
expert.s: try if you dare!
mipstermind.c: Mipstermind
1092 mipsy normal.s mipstermind.s
Guesslength:4
Validguesses:1-6
Howmanyturns:10
Enterarandomseed:0
[Turn1]
Enteryourguess:1234
Correctguessesincorrectplace:0
Correctguessesinincorrectplace:3
[Turn2]
Enteryourguess:4321
Correctguessesincorrectplace:1
Correctguessesinincorrectplace:2
[Turn3]
Enteryourguess:4431
Correctguessesincorrectplace:1
Correctguessesinincorrectplace:3
[Turn4]
Enteryourguess:4134
Correctguessesincorrectplace:2
Correctguessesinincorrectplace:2
[Turn5]
Enteryourguess:4143
Youwin,congratulations!
mipstermind.c is an implementation of
the classic board game Mastermind!
An example game of Mastermind can be seen to the right.
A game of Mastermind takes place over a number of turns,
as you battle the computer to guess its secret codeword!
Each turn, you are allowed to make a single guess
of the codeword.
If your guess is correct, you win the game!
However, if you run out of turns, you lose the game.
In order to aid you in your task, after each guess,
you are given some puzzling information to help
guide your further guesses.
In particular, you are told how many of your
guesses were correct in the correct place,
and how many were correct, but in the incorrect place.
Using this information, you can (hopefully) make a
guess that is somewhat closer to the secret codeword.
To get a feel for this game,
try it out in a terminal:
dcc mipstermind.c -o mipstermind
./mipstermind
You should read through mipstermind.c.
There are comments throughout it
that should help you understand
what the program is doing
which youll need for the next part of the assignment.
mipstermind.s: The Assignment
Your task in this assignment is
to implement mipstermind.s in MIPS assembly.
You have been provided with some assembly
and some helpful information in mipstermind.s.
Read through the provided code carefully,
then add MIPS assembly
so it executes exactly the same as mipstermind.c.
Two utility functions and the beginning
of main have already been
translated to MIPS assembly for you.
You have to implement the following
unfinished functions in MIPS assembly:
play_game,
generate_solution,
play_turn,
read_guess,
copy_solution_into_temp,
calculate_correct_place, and
calculate_incorrect_place
You must translate each function separately to MIPS assembler and
following the standard calling conventions used in lectures.
To run your MIPS code, you will need to use
a game configuration alongside your mipstermind.s
code. Heres an example of how to run your code with the
normal game settings:
1092 mipsy normal.s mipstermind.s
Note that normal.s needs to come before
mipstermind.s, because your code
relies on constants that are provided by normal.s.
To test your implementation,
you can compile the provided C implementation,
run it to collect the expected output,
run your assembly implementation to collect observed output,
and then compare them for example:
dcc mipstermind.c -o mipstermind
echo 0 4 1 4 3 > input
cat input | ./mipstermind | tee c.out
cat input | 1092 mipsy normal.s mipstermind.s | tee mips.out
diff -s c.out mips.out
Files c.out and mips.out are identical
Try this for different sequences of inputs, along with different game types.
autotest will not be as helpful as usual forthis assignment,
autotest will still perform some useful tests
to ensure your code is OK.
Use mipsy rathern than spim to run your code.
You may find it easier to implement
the smaller functions before moving
on to the larger ones.
mipsy supports defining constants
somewhat like #define in C:
#define TURN_NORMAL 0
#define TURN_WIN1
#define NULL_GUESS -1
But the syntax is a bit different:
TURN_NORMAL =0
TURN_WIN=1
NULL_GUESS= -1
Assumptions and Clarifications
Like all good programmers,
you should make as few assumptions as possible.
Your submitted code must be hand-written MIPS assembly,
which you yourself have written.
You may not submit code in other languages.
You may not submit compiled output.
You may not copy a solution
from an online source (e.g., Github).
Your functions may be tested separately.
They must implement the corresponding C function and they must follow MIPS calling conventions.
There will be a correctness penalty
for assignments that do not follow
standard MIPS calling conventions including:
that function arguments shall be passed in
registers $a0$a3;
that function return values shall be passed through
registers $v0$v1;
that values in registers $s0$s7
shall be preserved across function calls:
if a function changes these registers,
it must restore the original value before returning.
If you need clarification on
what you can and cannot use or do for this assignment,
ask in the class forum.
You are required to submit
intermediate versions of your assignment.
See below for details.
Assessment
When you think your program is working,
you can use autotest
to run some simple automated tests:
1092 autotest mipstermind mipstermind.s
Submission
When you are finished working on the assignment,
you must submit your work by running give:
give dp1092 ass1_mipstermind mipstermind.s
You must run give before Week 8 Monday 23:59:59
to obtain the marks for this assignment.
Note that this is an individual exercise,
the work you submit with give must be entirely your own.
You can run give multiple times.
Only your last submission will be marked.
You cannot obtain marks by e-mailing your code to tutors or lecturers.
You can check your latest submission on CSE servers with:
1092 classrun -check ass1_mipstermind
Manual marking will be done by your tutor,
who will mark for style and readability,
as described in the Assessment section below.
After your tutor has assessed your work,
you can collect your assignment by typing on the command line:
1092 classrun -collect ass1_mipstermind
The resulting mark will also be available by typing:
1092 classrun -sturec
This assignment is tentatively due Week 8 Monday 23:59:59.
If your assignment is submitted after this date,
each hour it is late
reduces the maximum mark it can achieve by 2%.
For example,
if an assignment worth 74% was submitted 10 hours late,
the late submission would have no effect.
If the same assignment was submitted 15 hours late,
it would be awarded 70%,
the maximum mark it can achieve at that time.
Assessment Scheme
This assignment will contribute 9 marks to your final DPST1092 mark.
80% of the marks for assignment 1 will come
from the performance of your code on a large series of tests.
20% of the marks for assignment 1 will come from hand marking.
These marks will be awarded on the basis of
clarity, commenting, elegance and style.
In other words, you will be assessed on
how easy it is for a human to read and understand your program.
An indicative assessment scheme follows.
The lecturer may vary the assessment scheme
after inspecting the assignment submissions,
but it is likely to be broadly similar to the following:
beautiful, clearly-documented code;
implements all behaviour perfectly
very readable code;
implements most behaviour perfectly
readable code;
some correctly-implemented behaviours
PS (50-60)
good progress, but not passing autotests
knowingly providing your work to anyone
and it is subsequently submitted (by anyone).
submitting any other persons work; this includes joint work.
misconduct
submitting another persons work without their consent;
paying another person to do work for you.
Intermediate Versions of Work
You are required to submit intermediate versions of your assignment.
Every time you work on the assignment
and make some progress
you should copy your work to your CSE account
and submit it using the give command below.
It is fine if intermediate versions do not compile
or otherwise fail submission tests.
Only the final submitted version of your assignment will be marked.
Attribution of Work
This is an individual assignment.
The work you submit must be entirely your own work,
apart from any exceptions explicitly included
in the assignment specification above.
Submission of work partially or completely derived from any other person
or jointly written with any other person is not permitted.
You are only permitted to request help with the assignment
in the course forum, help sessions,
or from the teaching staff (the lecturer(s) and tutors) of DPST1092.
Do not provide or show your assignment work to any other person
(including by posting it on the forum),
apart from the teaching staff of DPST1092.
If you knowingly provide or show your assignment work
to another person for any reason,
and work derived from it is submitted,
you may be penalized,
even if that work was submitted
without your knowledge or consent;
this may apply even if your work is submitted by
a third party unknown to you.
You will not be penalized
if your work is taken
without your consent or knowledge.
Do not place your assignment work in online repositories such as github
or any where else that is publically accessible.
You may use a private repository.
Submissions that violate these conditions will be penalised.
Penalties may include negative marks,
automatic failure of the course,
and possibly other academic discipline.
We are also required to report
acts of plagiarism or other student misconduct:
if students involved hold scholarships,
this may result in a loss of the scholarship.
This may also result in the loss of a student visa.
Assignment submissions will be examined,
both automatically and manually,
for such submissions.
Change Log
Version 1.0
(2022-07-02 09:00:00)
Initial release.
CS: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.