Asep Suryana

Welcome All About News Blog
JellyMuffin.com - The place for profile layouts, flash generators, glitter graphics, backgrounds and codes

Tuesday, December 2, 2008

Example

Suppose a computer is being employed to drive a traffic light. A simple stored program might say:
Turn off all of the lights
Turn on the red light
Wait for sixty seconds
Turn off the red light
Turn on the green light
Wait for sixty seconds
Turn off the green light
Turn on the yellow light
Wait for two seconds
Turn off the yellow light
Jump to instruction number (2)
With this set of instructions, the computer would cycle the light continually through red, green, yellow and back to red again until told to stop running the program.
However, suppose there is a simple on/off switch connected to the computer that is intended to be used to make the light flash red while some maintenance operation is being performed. The program might then instruct the computer to:
Turn off all of the lights
Turn on the red light
Wait for sixty seconds
Turn off the red light
Turn on the green light
Wait for sixty seconds
Turn off the green light
Turn on the yellow light
Wait for two seconds
Turn off the yellow light
If the maintenance switch is NOT turned on then jump to instruction number 2
Turn on the red light
Wait for one second
Turn off the red light
Wait for one second
Jump to instruction number 11
In this manner, the computer is either running the instructions from number (2) to (11) over and over or its running the instructions from (11) down to (16) over and over, depending on the position of the switch.[15]

No comments: