Department of Electrical and Computer Engineering
University of Texas at Austin
EE 306
Fall 2004
Y. N. Patt, Instructor
Siddharth Balwani, Linda Bigelow, Tommy Buell, Jeremy Carrillo, Aamir Hasan,
Danny Lynch, Rustam Miftakhutdinov, Veynu Narasiman, Vishal Parikh, Basit Sheikh, TAs

Programming Assignment 5 (Assembly Language)
Due: Friday, December 3, 5:00pm

You must do the programming assignment by yourself. You are permitted to get help ONLY from the TAs and the instructor. The file you submit should be an assembly language file called dots.asm. This is the only file you need to submit. Your program should start at memory location x3000. Submission instructions are posted on the class website in the Software and Documentation section. If you are having trouble submitting (or have forgotten your password), please email Danny (lynch@ece.utexas.edu) or Linda (bigelow@ece.utexas.edu).

1. Introduction
Ever had a couple of minutes to spare? We all have. Chances are, during many such moments as a child, you decided to play a game. Perhaps one of the games you played was a two-player game in which the players connect adjacent dots in a grid to form boxes.

In this assignment, you will use the principles of subroutine call and return. Using the high-level flow chart given in section 4, you will implement an ASCII Dots and Boxes (also called Squares) game for the LC-3. In section 5 we provide you with some assembly code to help you get started. NOTE: You MUST use this starter code. DO NOT MODIFY THE SUBROUTINES AND VALUES THAT WE HAVE GIVEN YOU IN THE STARTER CODE.

2. Rules
Dots and Boxes is a two-player game played on a variable-size grid of dots. For this assignment, the playing board is a 4x4 grid of dots, and the two players are denoted by two symbols: 1 and 2.

The rules are as follows:

  • Player 1 always goes first.
  • Each player takes a turn drawing a horizontal or vertical line between two adjacent dots.
  • A player cannot draw a line between two dots that are already connected by a line.
  • If a player completes a box (or boxes) by drawing the fourth side of it, the player writes his number (1 or 2) in the box and gets to draw another line.
  • The game ends when all the adjacent dots have been connected with horizontal or vertical lines.
  • The player with the most boxes at the end of the game wins.

    3. Game Board
    The game board is a 4x4 grid of dots, which are represented by the ASCII character '*' (asterisk, ASCII code x002A). Vertical lines are represented by the ASCII character '|' (pipe, ASCII code x007C), and horizontal lines are represented by the ASCII character '-' (hyphen, ASCII code x002D). The rows of the grid are labeled with numbers 0 to 6, and the columns of the grid are labeled with letters A to G. When the game starts, the board looks as follows:

        ABCDEFG
      0 * * * *
      1        
      2 * * * *
      3        
      4 * * * *
      5        
      6 * * * *
    
    A move is specified by a two-character input pair designating the space between two adjacent dots. The first character should be a capital letter (A-G) specifying the desired column, and the second character should be a number (0-6) specifying the desired row. For example, an input move of A1 would result in the following board:
        ABCDEFG
      0 * * * *
      1 |      
      2 * * * *
      3        
      4 * * * *
      5        
      6 * * * *
    
    If the next move was D4, the board would now look as follows:
        ABCDEFG
      0 * * * *
      1 |      
      2 * * * *
      3        
      4 * *-* *
      5        
      6 * * * *
    
    The initial data structure of the game board is stored in memory using 7 .STRINGZ pseudo-ops, one for each row. During the execution of the program, we will modify the contents of these memory locations to reflect each player's move.

    4. Algorithm
    In order to design a Dots and Boxes game, or any other software project, we must break the problem into small pieces. To this effect, we have created the following flow chart for Dots and Boxes.



    You will use this flowchart as the basis for designing the program. The blocks that you must implement are in bold.

    5. What to do
    An example of the input/output for a game being played can be found here and here. The following starter code provides a general framework for the Dots and Boxes game, plus a few subroutines that we have provided for you.
    Your job is to complete the Dots and Boxes game by writing the following subroutines:

    We have provided the following subroutines for you: