On Mon, 19 Nov 2007 23:09:19 +0000, Flash Gordon wrote:
>Juha Nieminen wrote, On 19/11/07 22:59:
>> Flash Gordon wrote:
>>> On another project:
>>>
>>> for (;;) suspend_processor();
>>>
>>> In each case, suspend_processor() stops the processor from executing
>>> code until it receives an interrupt.
>
> It does the interrupt processing then returns and executes
> do_something (in the first case). Also note that the second
> example does *nothing* in the main loop apart from suspend
> the processor.
> The most common processor I've done this kind of loop on is the
> Z80, but I've also used it on the TMS320C25 and maybe other processors.
As an interesting part of trivia, the main loop of Super Mario Bros. on
the 8-bit Nintendo is exactly of this kind. The main loop does literally
nothing else but wait for the next interrupt. (Except that the NES does
not have a suspend/wait opcode, so it was a for(;;); loop instead.)
Most other NES games defaulted to the busyloop once they had
done processing the game logic of that particular display frame;
some constantly updating the random number generator seed in that loop.
Follow-ups set.
--
Joel Yliluoma - http://iki.fi/bisqwit/