'ax,cx are bytes for counting 'tmp_a,tmp_b,value,value2 are bytes for storage 'RANK and SCORE are constants that index locations in the scratch pad 'NOP is a constant for the number of players 'rank = 0 'score = 16 'NOP = 16 'the scratch pad ' 0-15 rank of player1 -> player16 ' 16-31 score of player 1 -> plater16 BUBBLE: FOR ax = 0 TO NOP - 2 'outer loop counts iterations of the inner loop FOR cx = 0 TO NOP - 2 - ax 'inner loop counts through array and tests for swaps GET RANK + cx, tmp_a 'gets the index of the cx'th ranked player GET RANK + cx + 1, tmp_b 'gets the index of the next ranked player GET SCORE + tmp_a, value 'gets the score the the cx'th ranked player GET SCORE + tmp_b, value2 'gets the score of the next player IF value < value2 THEN 'if the cx'th player's score is less than the next player's score PUT RANK + cx, tmp_b 'swap the index in the ranking PUT RANK + cx + 1, tmp_a ENDIF 'otherwise leave them alone NEXT NEXT RETURN