1. Homepage
  2. Programming
  3. DPST1092 Computer Systems Fundamentals - Assignment 1: Pacman in MIPS

DPST1092 Computer Systems Fundamentals - Assignment 1: Pacman in MIPS

Engage in a Conversation
AustraliaUNSWComputer Systems FundamentalsPacman in MIPSCMIPSDPST1092

Assignment 1: Pacman in MIPS

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 pacman, change to this directory, and fetch the provided code by running these commands: CourseNana.COM

mkdir -m 700 pacman
cd pacman
1092 fetch pacman

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

This will add the following files into the directory: CourseNana.COM

  • pacman.s: a stub MIPS assembly file to complete.
  • pacman.c: a reference implementation of Pacman in C.
  • pacman_EOF.c: additional C file for testing.
  • input.txt: example input file.

Pacman: The Game

1092 mipsy pacman.s
Enter a non-zero number for the seed: 42
Welcome to 1092 Pacman!
# = wall
@ = you
. = dot
M = ghost

The objective is to collect all the dots.
Use WASD to move.
Ghosts will move every time you move.
Touching them will end the game.
#############
#...........#
#.#########.#
#.#M#.......#
#.#####.###.#
#...M.#@#...#
#.#####.###.#
#.#.#...#M..#
#.....#...#.#
#############
You've collected 0 out of 53 dots.
Choose next move (wasd): -- CUT --

pacman.c is an implementation of Pacman, a classic arcade game. CourseNana.COM

An example game of Pacman can be seen to the right. CourseNana.COM

A game of Pacman takes place on a 2D grid, as the player tries to collect dots while avoiding ghosts! CourseNana.COM

Each turn, you can move up (W), left (A), down (S), or right (D). If you move onto a dot on the grid, that dot becomes collected. Your goal is to collect all the dots. Each turn the ghosts also move, and if you run into a ghost the game ends. CourseNana.COM

To get a feel for this game, try it out in a terminal: CourseNana.COM

dcc pacman_EOF.c -o pacman
./pacman

You should read through pacman.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. CourseNana.COM

pacman.s: The Assignment

Your task in this assignment is to implement pacman.s in MIPS assembly. CourseNana.COM

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

The functions get_seed and random_number has already been translated to MIPS assembly for you. CourseNana.COM

You have to implement the following functions in MIPS assembly: CourseNana.COM

  • print_welcome
  • main
  • get_direction
  • play_trick
  • copy_map
  • get_valid_directions
  • print_map
  • try_move
  • check_ghost_collision
  • collect_dot_and_check_win
  • do_ghost_logic.

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 other function which is called. CourseNana.COM

Subsets

This assignment is split into four subsets. Later subsets will involve more complex translation. CourseNana.COM

SubsetFunctionsPerformance Weight
Subset 0
  • print_welcome
5%
Subset 1
  • main
  • get_direction
  • play_tick
45%
Subset 2
  • copy_map
  • get_valid_directions
  • print_map
  • try_move
30%
Subset 3
  • check_ghost_collision
  • collect_dot_and_check_win
  • do_ghost_logic
20%

Note that in print_map, the loop which iterates over ghosts does not need to be implemented until you begin subset 3. CourseNana.COM

Running & Testing

To run your MIPS code, simply enter the following in your terminal: CourseNana.COM

1092 mipsy pacman.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. CourseNana.COM

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

You have been given a file called input.txt as an example. CourseNana.COM

dcc pacman.c -o pacman
cat input.txt | ./pacman | tee c.out
cat input.txt | 1092 mipsy pacman.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. CourseNana.COM

Hints

  • You should implement all the functions from one subset before moving onto the next. CourseNana.COM

  • You may find the provided get_seed and random_number function implementations to be useful guidance for your implementations including comments, label names, indentation and register usage. CourseNana.COM

Simplified C code

You are encouraged to simplify your C code to remove any loop constructs and if-else statements, and testing that your simplified code works correctly before translating it to MIPS, in a separate file pacman.simple.c. CourseNana.COM

This file will not be marked - you do not need to submit it. CourseNana.COM

In order to allow you to ensure that your simplified code works correctly, we have provided a series of automated tests. CourseNana.COM

You can run these tests by running the following command: CourseNana.COM

1092 autotest pacman.simple

Assumptions, Clarifications, and Restrictions

  • Like all good programmers, you should make as few assumptions as possible. CourseNana.COM

  • 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. CourseNana.COM

  • You may not copy a solution from an online source. e.g. Github. CourseNana.COM

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

  • 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. CourseNana.COM

  • In the get_direction function, you may assume that all user input consists of either empty lines, or lines with exactly one ASCII character. You do not need to handle end-of-file. CourseNana.COM

  • There will be a correctness penalty for assignments that do not follow standard MIPS calling conventions including: CourseNana.COM

    • Function arguments are passed in registers $a0..$a3. CourseNana.COM

    • Function return values are passed in register $v0 CourseNana.COM

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

    • 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. CourseNana.COM

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

  • You are required to submit intermediate versions of your assignment. See below for details. CourseNana.COM

Change Log

Assessment

Testing

We have provided some automated tests to help you check the correctness of your translation. To run all the provided tests, execute the following command:
1092 autotest pacman
Some of these tests check only a specific function, and some test your whole program. To run run all the tests for a specific function, pass the name of the function to autotest. For example, to run all the tests for the print_welcome function, run the command:
1092 autotest pacman print_welcome
You can also run all the autotests for a particular subset. For example, to run all the autotests for subset 0, run the command:
1092 autotest pacman S0
To run the autotests which test your program as a whole, run the command:
1092 autotest pacman whole_prog
To run all the subset 2 autotests for print_map (not involving ghosts):
1092 autotest pacman print_map_S2

Submission

When you are finished working on the assignment, you must submit your work by running give: CourseNana.COM

give dp1092 ass1_pacman pacman.s

You must run give before Week 8 Monday 23:59:59 (midnight) 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. CourseNana.COM

You can run give multiple times.
Only your last submission will be marked. CourseNana.COM

If you are working at home, you may find it more convenient to upload your work via give's web interface. CourseNana.COM

You cannot obtain marks by emailing your code to tutors or lecturers. CourseNana.COM

You can check your latest submission on CSE servers with: CourseNana.COM

1092 classrun check ass1_pacman

You can check the files you have submitted here. CourseNana.COM

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 view your results here; The resulting mark will also be available via give's web interface. CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Australia代写,UNSW代写,Computer Systems Fundamentals代写,Pacman in MIPS代写,C代写,MIPS代写,DPST1092代写,Australia代编,UNSW代编,Computer Systems Fundamentals代编,Pacman in MIPS代编,C代编,MIPS代编,DPST1092代编,Australia代考,UNSW代考,Computer Systems Fundamentals代考,Pacman in MIPS代考,C代考,MIPS代考,DPST1092代考,Australiahelp,UNSWhelp,Computer Systems Fundamentalshelp,Pacman in MIPShelp,Chelp,MIPShelp,DPST1092help,Australia作业代写,UNSW作业代写,Computer Systems Fundamentals作业代写,Pacman in MIPS作业代写,C作业代写,MIPS作业代写,DPST1092作业代写,Australia编程代写,UNSW编程代写,Computer Systems Fundamentals编程代写,Pacman in MIPS编程代写,C编程代写,MIPS编程代写,DPST1092编程代写,Australiaprogramming help,UNSWprogramming help,Computer Systems Fundamentalsprogramming help,Pacman in MIPSprogramming help,Cprogramming help,MIPSprogramming help,DPST1092programming help,Australiaassignment help,UNSWassignment help,Computer Systems Fundamentalsassignment help,Pacman in MIPSassignment help,Cassignment help,MIPSassignment help,DPST1092assignment help,Australiasolution,UNSWsolution,Computer Systems Fundamentalssolution,Pacman in MIPSsolution,Csolution,MIPSsolution,DPST1092solution,