Exercise10

Exercise10 - 0306-250 Assembly Language Programming Fall...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0306-250 Assembly Language Programming Fall 2009 Laboratory Exercise Ten: Game This exercise develops a game for the Freescale HCS12 MCU Application Module. The objective of this exercise is to combine all of the assembly language programming concepts from this course into a single functional, creative program: serial I/O driver, timer driver, and A/D conversion. The game is written, and it is run on the HSC12 module. Game The game consists of four rounds of digital value matching. In each round, the game program prints a random number between 0 and 1023, and the user has to adjust the potentiometer on the project board to produce a digital value from the HCS12 ATD that matches the number within ±50. After adjusting the potentiometer, the user presses any keyboard key to initiate the A/D conversion, and the program checks for a match. Each round i, (i Î [1, 4]), of the game lasts for up to 25 - 5i s, ending when either the user has set the potentiometer to produce the printed digital number or when the maximum time has expired, whichever occurs first. There is no restriction on the number of times the user may adjust the potentiometer during a round. The game program relies on creativity in two aspects: random numbers and scoring. Any method for generating random numbers may be used as long as the same numbers are not used every time the game is played. Similarly, any scoring formula can be used as long as it rewards correct matches in the shorter later rounds with more points than slower matches in the earlier rounds. Prelab Work 1. Write code to generate a random number between 0 and 1023 (inclusive) to display for the user to match. 2. Write pseudocode to compute the score for each round of the game. Page 1 of 3 0306-250 20091 Lab Exercise 10: Game Page 2 of 3 Program Specification The game program must meet the specifications below. Suggestion—reuse code from the previous exercises (e.g., serial I/O driver [8], timer driver [9], and A/D conversion [7]). 1. The program must first display the instructions for your game on the screen. 2. The program must then prompt the user to start the game by pressing any key on the keyboard. 3. After a key is pressed, the program runs each game round i. a. The program displays a random number for the user to match by setting the potentiometer to produce that value from A/D conversion. b. The user has ti = 25 - 5i seconds to match the number within a tolerance of ±50. c. After setting the potentiometer, the user presses any key to have the program check the value. d. After any key is pressed, the program gives the user feedback (e.g., the digital value from A/D conversion or some indication of how the current value differs from the desired value). e. The program moves to the next round as soon as either the time for the current round has expired or the user matches the desired number within tolerance. 4. After the last round, the program displays the score on the screen. 5. At the end of one game, the program should prompt the user to press any key to play another game, and the program should repeat from specification 3. Lab Procedure 1. Create a new CodeWarrior directory (folder) and project on your X: drive for this exercise. 2. Write a properly commented and properly formatted HCS12 assembly language program to implement a game based on the preceding specification. 3. Assemble the program in CodeWarrior compiler to create a listing file. 4. Link the program in CodeWarrior to create a linker map file. 5. Test your program for proper operation, which must be demonstrated to the instructor. 6. Demonstrate your program for the lab instructor. Following demonstration, print the listing file, linker map file, and terminal screen output, and have your lab instructor sign your grading sheet and printed pages. 0306-250 20091 Lab Exercise 10: Game Page 3 of 3 Report Write a report consisting of the following sections. · Design Methodology F Your design methodology must explain your random and scoring algorithms. - Random algorithm: How does your program generate the random numbers? - Scoring algorithm: How does your program calculate the game score? · Results Your writing should follow the rules of professional technical writing and should meet the specifications in “Laboratory and Report Guidelines” on the course reference material web page. Staple your cover page, report, listing file, and grading sheet (in that order), and submit them as directed by your lab instructor. No late submissions will be accepted for this last lab exercise. ...
View Full Document

Ask a homework question - tutors are online