The program that we have just written will display the values in the array, but it will do it so quickly that the user will not be able to see and remember them. We have already used delay loops in our previous programs and so we must now add another delay to slow things down a bit.

The actual size of the delay counter required at each point could be calculated by starting from the clock speed of the chip and working out how long each instruction takes to execute, but a simpler way is just to try some values until they look OK.

The simple delay loop on the right does nothing 10000 times using a for loop to control the action.

The nested delay loop puts one loop doing nothing inside another. This is useful if you can't make a program count far enough to get a useful delay with just a single loop.

Processor Speed

It is important to remember that f the program is executed on a faster processor this will affect the delays and could make the game unplayable (something which has happened to a number of IBM PC games in the past which relied on delay based timing).

Power Consumption

Another thing to consider is that during the delay the processor is actually running at full speed. This may not be a good idea if your program is designed to run on a battery powered device. Later in the course we will see how you can make the processor pause for a given time interval by sending it to "sleep" until a timer event occurs.