Take a look at this short snippet of PASM (Propeller ASseMbly) that I wrote while creating pong.
mins player1_position, #16 wc
if_b mov player1_speed, #0
maxs player1_position, #112 wz, wc
if_a mov player1_speed, #0
What we have here is bounds checking on player1's paddle. The first line says, whichever value (player1's position or the number 16) is greater, take it and store it in the first location. So effectively, the mins instruction (min for signed numbers) will do a lower bounds cap on player1_position, with 16 being that lower bound.
The wc is one of two special flags that each instruction can use to affect further operations (the other is wz). In this case, specifying wc tells the instruction that when it performs the check, if value1 (player1_position) was less than value2 (16), write a '1' into the C register. Otherwise, write a '0'. So, in this case, if the value was less, it means that the position got capped (aka, we ran into a wall), so reset the speed back to 0.
The next two lines of course do the opposite, in that they cap the position on an upper bound, and if a collision occured, reset the speed. Note that we need wc AND wz here, since wc still gets written if the value is lower, and wz gets written if the values are the same. The if_a instruction checks if C isn't set and Z isn't set (ie. the value wasn't lower and the value wasn't the same), which is the same thing as saying the value was greater.
Now let's look at the equivalent C/C++/C# code:
if( player1_position < 16 )
player1_position = 16;
player1_speed = 0;
else if( player1_position > 112 )
player1_position = 112;
player1_speed = 0;
Ah. Much more readable. But almost much more verbose, and much more space-hungry. While I wouldn't want to go around programming in ASM all the time, it IS nice to try something new and get a taste for it. And in a small scale project like Pong, on a simple microchip instead of a very complex PC, I don't mind the lower level language.
That said, I still want to get some sort of scripting language set up that will let me compile down to this stuff. Hopefully that's on the horizon, but for now, I need to press onward and finish this Pong game. Once that's done, I'm not sure which project I should work on next. Any ideas or suggestions for cool old school games to make on it would be welcome. I'm thinking something like PacMan would be a next step. I thought of going with a Breakout clone, but that's practically the same thing as Pong.