This assignment will exercise your ability to program in x64 assembly language. The task will be to implement the “Animal Guessing Game” in assembly. The attached file “Animal Game.pdf” contains a...


This assignment will exercise your ability to program in x64 assembly language. The task will be to implement the “Animal Guessing Game” in assembly. The attached file “Animal Game.pdf” contains a brief explanation of the game. I have provided a fair amount C code and the skeleton of the assembly code. Your job is to provide the missing assembly.


This is a time-consuming assignment, soplease get started right away.
Here are the steps to perform:



  1. Download a compressed file appropriate for your computer, by downloading one of the following attached files

    • assignment3_macos.tgzfor macOS.

    • assignment3_cygwin.tgzfor Windows/Cygwin.

    • assignment3_linux.tgzfor Linux.



    As with previous assignments, save and uncompress the downloaded file in the directory where you want to work on and compile your program. To uncompress the file, in a shell, type
    tar -xzvffilename

    wherefilenameis the name of the file that you downloaded.


  2. The nine files that are extracted from the compressed file are:

    • animals.s, the file where you will be putting your assembly code.Important: This is the only file you will be turning in.

    • animals.h, the header file for animals.s.

    • main.c, the file containing the main function and other related functions.

    • c_animals.c, the file containing C versions of the assembly functions you will be writing.

    • c_animals.h, the header file for c_animals.c.

    • node_utils.c, a C file I wrote, containing auxiliary procedures to use.

    • node_utils.h, the header file for node_utils.c.

    • makefile, to allow you to type “make” to compile.

    • An executable file, eitherben_animals(on Mac OS X or Linux) orben_animals.exe(Cygwin), which was compiled from my version of the assignment. You can use this to see how your code should behave (although you won't really need it).





  3. You can immediately compile and run the program before you have made any changes. In the shell, type “make”. This should generate the executable fileanimals(on macOS/Linux) oranimals.exe(Cygwin). To run the program, type “./animals” and have fun playing. The state of the game will be saved in a file calleddata.dat(backed up by a filedata.data.bak), which you can ignore. It just means that you'll resume playing the game where you left off. If you want to start over with no animals, just deletedata.dat.


  4. In thec_animals.cfile, the first function you'll see is calledyes_response_c(). This function is responsible for reading in a yes/no response from the user (as one of “yes”, “y”, “no”, or “n”), and will keep prompting until it gets such a response. I have translated it myself into assembly, in theanimals.sfile.Do not modify this assembly code, but read it closely to make sure you understand what is going on.


  5. The next function inc_animals.cis callednew_node_c(), which allocates and populates a node of typeNODE(seenode_utils.h). Your first programming task is to implement the corresponding functionnew_node()in assembly language inanimals.s. You will see that I have created a skeleton of thenew_node()function, soplease read the instructions in the file carefully and fill in assembly code where indicated.
    When you have finished entering the assembly code fornew_node()and are ready to test and debug it, change the three calls tonew_node_c()inc_animals.cso thatnew_node()is called instead (that is, just remove the “_c” from the name of the function being called). Be surenotto change thedefinitionofnew_node_c()inc_animals.c, though.
    Once you get the code working, proceed to the next step, which is far more extensive.


  6. The largest function inc_animals.cis calledguess_animal_c()which actually constructs a tree of animals and questions, and carries out the process of playing the game. Your task, of course, is to implement the corresponding functionguess_animal()in assembly language inanimals.s. As with the previous step, I have created a skeleton of theguess_animal()assembly function, soplease read the instructions carefully and fill in assembly code where indicated.
    When you have finished entering the assembly code forguess_animal()and are ready to test and debug it, change the one call toguess_animal_c()inmain.cso thatguess_animal()is called instead (again, just remove the “_c” from the name of the function being called).

Apr 09, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here