Question
A one-dimensional ping-pong table is simulated by the variable Ptable where only 4 MSB's (most signi cant bits), b7, b6, b5 and b4, are used
A one-dimensional ping-pong table is simulated by the variable Ptable where only 4 MSB's (most signi cant bits), b7, b6, b5 and b4, are used and each of the 4 bits represents a position of the (ping-pong) ball on the table. b7 and b4 represent the two (left and right) ends of the table. At any time, only one of the 4 bits is \1" (which indicates the position of the ball) and the other three bits are \0." The ball starts at the right end, i.e., (b7; b6; b5; b4)=(0001), initially moving to the left, one position per step. In each step, the ball moves one position and then the corresponding byte in change is checked. The rst byte in change is checked in the rst step, the second byte in the second step, and so on. If the change byte is 1 when the ball arrives at the right end from the left or at the left end from the right, the ball is to be bounced back (in the following step). If the change byte is 0 in such a case, the ball continues to move in the same direction, i.e., being wrapped around. In all other cases, the direction of the ball should not be a ected by the change byte.
Write a program which implements the above operation of the ping-pong table using the set-up below, i.e., 14 steps are to be executed in total. RAMStart=$0800 and ROMStart=$4000.
Ptable DS.B 1 change
DC.B 0,0,1,0,0,1,0,1,0,1,1,0,1,0
Assemble the program and execute it in the single-step mode with the contents of the variable and array displayed in the memory window. The variable Ptable should be displayed also in the data window (in binary, i.e., individual bits are to be shown). Do screen-captures (the source, data, register and memory windows) right before the rst instruction is executed, right after each of the 4th, 8th, 11th and the last steps.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started