1. Homepage
  2. Coding
  3. COMP1521 Computer Systems Fundamentals - Assignment 1: Nonograms in MIPS

COMP1521 Computer Systems Fundamentals - Assignment 1: Nonograms in MIPS

Order Now
UNSWCOMP1521Computer Systems FundamentalsNonograms in MIPSMIPSC

Assignment 1: Nonograms in MIPS

version: 1.0 last updated: 2024-09-25 11:30:00 Assignment Writing Service

Aims

  • to give you experience writing MIPS assembly code
  • to give you experience translating C to MIPS
  • to give you experience with data and control structures in MIPS

Getting Started

Create a new directory for this assignment called nonograms, change to this directory, and fetch the provided code by running these commands: Assignment Writing Service

mkdir -m 700 nonograms
cd nonograms
1521 fetch nonograms

If you're not working at CSE, you can download the provided files as a zip file or a tar file. Assignment Writing Service

This will add the following files into the directory: Assignment Writing Service

  • nonograms.s: a stub MIPS assembly file to complete.
  • nonograms.c: a reference implementation of nonograms in C.
  • nonograms.simple.c: a copy of the reference implementation of nonograms, for you to simplify.
  • input.txt: example input file.
  • nonograms.mk: a make fragment for compiling nonograms.c.

Nonograms: The Puzzle

1521 mipsy nonograms.s
Enter the height: 3
Enter the width: 3
Enter solution: 1 1 -1 -1
Loaded 1 solution coordinates

        
      1 
     ABC
    a...
  1 b...
    c...
 >> m
Enter first coord: b
Enter second coord: B
Enter choice (# to select, x to cross out, . to deselect): #
        
      1 
     ABC
    a...
  1 b.#.
    c...
Congrats, you won!

nonograms.c is an implementation of a program to play nonograms (also known as Picross). Assignment Writing Service

A nonogram puzzle takes place on a 2D grid, where the player must mark a set of cells, according to number clues placed on the edge of the puzzle. Assignment Writing Service

Each row and column contains a sequence of numbers which correspond to the correct lengths of consecutive runs of marked cells in that row/column. For example, the numbers 2 3 1 mean that row/column has a run of 2 marked cells, then 3 marked cells, then 1 marked cells, with gaps of at least one cell between them. Assignment Writing Service

The m commands allows the player to mark, unmark or cross out (indicate that the cell should definitely be unmarked) a cell based on the row (lowercase letter) and column (uppercase letter). Assignment Writing Service

An example game of nonograms can be seen to the right. Assignment Writing Service

To get a feel for this game, try it out in a terminal: Assignment Writing Service

dcc nonograms.c -o nonograms
./nonograms

You should read through nonograms.c. There are comments throughout it that should help you understand what the program is doing [citation needed] — which you'll need for the next part of the assignment. Assignment Writing Service

Online player

The following is an online version of the game which you may find useful to help understand the game mechanics, as well as to create your own puzzles (you can copy-paste the output of the Current grid box). Assignment Writing Service

Current grid:
-1 -1

If you happen to create any fun/difficult puzzles feel free to post them on the course forum. Assignment Writing Service

nonograms.s: The Assignment

Your task in this assignment is to implement nonograms.s in MIPS assembly. Assignment Writing Service

You have been provided with some assembly and some helpful information in nonograms.s. Read through the provided code carefully, then add MIPS assembly so it executes exactly the same as nonograms.c. Assignment Writing Service

The functions get_command and dump_game_state have already been translated to MIPS assembly for you. Assignment Writing Service

You have to implement the following functions in MIPS assembly: Assignment Writing Service

  • main
  • prompt_for_dimension
  • initialise_game
  • game_loop
  • decode_coordinate
  • read_solution
  • lookup_clue
  • compute_all_clues
  • make_move
  • print_game
  • compute_clue
  • is_game_over

Assignment Writing Service

You must translate each function separately to MIPS assembler, following the standard calling conventions used in lectures. When translating a function, you must not make any assumptions about the behaviour or side effects of any function which is called. Assignment Writing Service

Subsets

This assignment is split into three subsets. Later subsets will involve more complex translation. Assignment Writing Service

SubsetFunctionsPerformance Weight
Subset 1
  • main
  • prompt_for_dimension
  • initialise_game
  • game_loop
45%
Subset 2
  • decode_coordinate
  • read_solution
  • lookup_clue
  • compute_all_clues
30%
Subset 3
  • make_move
  • print_game
  • compute_clue
  • is_game_over
25%

The performance mark for the final subset also includes tests which run the program as a whole. Assignment Writing Service

Commands

The get_command function calls various other functions. When translating you should follow the exact behaviour of the C code, however when testing you may find it useful to consult the following table of commands. Assignment Writing Service


CommandDescriptionFunction called
mAllow the player to make a movemake_move
qExit the program
dOutput debugging informationdump_game_state
sDisplay clue numbers for the current selection
SDisplay clue numbers for the solution
?Show the solution grid (for cheating)print_game

Assignment Writing Service

Running & Testing

To run your MIPS code, simply enter the following in your terminal: Assignment Writing Service

1521 mipsy nonograms.s

Once you have finished your translation, 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. Assignment Writing Service

The game takes a lot of input, so it's a good idea to write a file with the input you want to test, and then pipe that into your program. Assignment Writing Service

You have been given a file called input.txt as an example. Assignment Writing Service

dcc nonograms.c -o nonograms
cat input.txt | ./nonograms | tee c.out
cat input.txt | 1521 mipsy nonograms.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. When testing some functions you may find using the d command (which calls dump_game_state) to be useful. Assignment Writing Service

Hints

  • You should implement all the functions from one subset before moving on to the next. Assignment Writing Service

  • You may find the provided get_command, and dump_game_state function implementations to be useful guidance for your implementation including comments, label names, indentation and register usage. Assignment Writing Service

Simplified C code

You are encouraged to simplify your C code to remove any loop constructs and if-else statements, and test that your simplified code works correctly before translating it to MIPS, in a separate file nonograms.simple.c. Assignment Writing Service

This file will not be marked - you do not need to submit it. Assignment Writing Service

In order to allow you to check that your simplified code works correctly, we have provided a simple set of automated tests. Assignment Writing Service

You can run these tests by running the following command: Assignment Writing Service

1521 autotest nonograms.simple

Assumptions, Clarifications, and Restrictions

  • Like all good programmers, you should make as few assumptions as possible. Assignment Writing Service

  • 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. Assignment Writing Service

  • You may not copy a solution from an online source. e.g. Github. Assignment Writing Service

  • Your functions will be tested individually. They must exactly match the behaviour of the corresponding C function and they must follow MIPS calling conventions. Assignment Writing Service

  • You may assume the input provided to nonograms.s will be correctly formatted. For example, where a number is expected the input will not be a letter. Assignment Writing Service

  • The C code defines constants using #define. Your MIPS translation should use the corresponding provided named constants, in the places where a #define is used in the C code. You should not use a #define constant in your MIPS translation if it is not used in the corresponding part of the C code. Assignment Writing Service

  • There will be a correctness penalty for assignments that do not follow standard MIPS calling conventions including: Assignment Writing Service

    • Function arguments are passed in registers $a0..$a3. Assignment Writing Service

    • Function return values are passed in register $v0 Assignment Writing Service

    • Values in registers $s0..$s7 are preserved across function calls.
      If a function changes these registers, it must restore the original value before returning. Assignment Writing Service

    • The only registers' values that can be relied upon across a function call are $s0..$s7$gp$sp, and $fp.
      All other registers must be assumed to be have, an undefined value after a function call, except $v0 which has the function return value. Assignment Writing Service

  • If you need clarification on what you can and cannot use or do for this assignment, ask in the class forum. Assignment Writing Service

  • You are required to submit intermediate versions of your assignment. See below for details. Assignment Writing Service

联系辅导老师!
私密保护
WeChat 微信
UNSW代写,COMP1521代写,Computer Systems Fundamentals代写,Nonograms in MIPS代写,MIPS代写,C代写,UNSW代编,COMP1521代编,Computer Systems Fundamentals代编,Nonograms in MIPS代编,MIPS代编,C代编,UNSW代考,COMP1521代考,Computer Systems Fundamentals代考,Nonograms in MIPS代考,MIPS代考,C代考,UNSW代做,COMP1521代做,Computer Systems Fundamentals代做,Nonograms in MIPS代做,MIPS代做,C代做,UNSWhelp,COMP1521help,Computer Systems Fundamentalshelp,Nonograms in MIPShelp,MIPShelp,Chelp,UNSW作业代写,COMP1521作业代写,Computer Systems Fundamentals作业代写,Nonograms in MIPS作业代写,MIPS作业代写,C作业代写,UNSW编程代写,COMP1521编程代写,Computer Systems Fundamentals编程代写,Nonograms in MIPS编程代写,MIPS编程代写,C编程代写,UNSW作业答案,COMP1521作业答案,Computer Systems Fundamentals作业答案,Nonograms in MIPS作业答案,MIPS作业答案,C作业答案,