This assembly project included two boards and was programmed in AVR assembly. The goal was to
play a game of rock paper scissors between the two devices, one for each user but with a little
twist. The twist was you shoot two hands at once, show your opponent and see their two hands, then
together pick which hand you wanted to throw. For example, if I threw rock and paper
and the opponent also chose paper and rock
, I would throw paper that way I win if they
throw rock
, or we tie if they throw paper
.
This was accomplished by installing jumper wires between the respective transmit and receive pins of each board and setting up the same USART format. This includes the same baud rate, same number of stop bits and data bits, what parity mode to use and for extra usability we enabled the interrupt when a receive was complete. Upon successful transmit and receive we needed to encode the two hands from each player to the other. To do this we declared rock = 0, paper = 1 and scissors = 2. For transmitting, we bit shifted the left hand by two effectively storing the left hand in bits 3 and 2 while the right hand was added to the total resulting in right hand being stored in bits 1 and 0. Once the other board received this data they could andi bits 1 and 0 for the right hand and bit shift right by two then andi bits 1 and 0 to get the left hand. This resulted in efficient USART communication. To transmit the hand choice a simple 1 or 0 would determine left or right hand.
This project provided hands-on experience with USART protocol and a bigger multi-board assembly project. Being a fairly large project for our scale it came with some challenges such as register overlap and needed to ensure registers were pushed and popped to the stack in all functions possible. Futhermore, we initially took a polling approach for button presses however, we realized we could not poll for both buttons and the timer/counter flag which served as a countdown on user input. Therefore an easier future approach includes starting with a interrupt system for the push buttons. If I did this project again I would try to keep the project more contained as I would be better planned and create better naming systems and build more modular code blocks.