Multitasking On The Humble Z80 CPU

Editorial Team
2 Min Read


Multitasking is one thing we take without any consideration lately. Nearly each laptop we use, from our desktops to our telephones, is able to multitasking. It would sound foolish to implement multitasking on lower-spec machines from many a long time in the past, given their restricted assets, however it may be carried out, as [bchiha] demonstrates on a Z80-based machine.

[bchiha] has achieved pre-emptive multitasking on the TEC-1G Z80 laptop, a contemporary reimagining of the basic Speaking Electronics TEC-1 from the Nineteen Eighties.  The proof of idea code permits working as much as eight separate duties without delay. Process switching runs on interrupts, triggered at roughly 50 Hz. When an interrupt fires, the CPU registers are transferred onto that activity’s stack, and the subsequent activity’s stack is swapped to the stack pointer to permit execution of the brand new activity to proceed. There may be an overhead, after all, with [bchiha] noting that the duty swapping routine itself takes about 430 clock cycles to run in between duties.

Multitasking took a while to look on dwelling computer systems for good cause—it’s not very helpful except you may have a machine with sufficient energy to virtually run a number of duties without delay. Whereas a Z80 machine like this can do multitasking, you’d higher hope every activity is fairly tiny to keep away from every particular person activity taking ceaselessly to run.

[bchiha] has made the straightforward multitasking code out there on Github for the curious. We’ve featured multitasking work on different unconventional platforms earlier than, too, just like the Arduino Uno. Video after the break.

[Thanks to Stephen Walters for the tip!]

Share This Article