SymbOS Z80 multitasking operating system
symbos.de
symbos.de
SymbOS: Graphical Z80 Multitasking Operating System - https://news.ycombinator.com/item?id=16078915 - Jan 2018 (98 comments)
SymbOS: preemptive multitasking OS that can play mp3s, video on 8-bit Z80 PCs - https://news.ycombinator.com/item?id=10749206 - Dec 2015 (36 comments)
Z80 Symbos OS now has networking support on MSX - https://news.ycombinator.com/item?id=9634634 - May 2015 (25 comments)
SymbOS: preemptive multitasking OS that can play mp3s, video on 8-bit Z80 PCs - https://news.ycombinator.com/item?id=4653232 - Oct 2012 (1 comment)
Done many years ago now, there is a preemptive multitasking OS for the Z80 for the "kiss TNC" used in ham radio: https://github.com/cheponis/KISS-TNC2/blob/master/KISS-TNC.a... This only used the interrupts to permit the modem (receive) side to generate interrupts, but the concepts are the same as if the interrupt would have come from a timer source. Yes, it uses the EXX and EX AF,AF' instructions.
The best Z80 book, which describes the little-known W and Z registers is http://www.z80.info/zip/zaks_book.pdf start on page 86 for their description.
I poked around the website but it seems light on implementation details. Super-impressive piece of work though.
Edit to say: thank you to the responders who've backfilled the gaps in my memory. Interesting what you forget given enough time.
https://retrocomputing.stackexchange.com/questions/7794/did-...
Sure you'll need to save the registers, but you could do that using the stack as well. The second register set just makes it quicker.
Your original statement is sufficiently ambiguous that non-mind reading people might interpret it to mean “all tasks”.
This line is typically tied in popular Z80 machines to the vertical blanking generator (frame refresh - 50/60Hz). Presumably, the OS would then schedule the tasks in a round robin fashion and most tasks will cooperate and yield control quicker to allow a not too choppy experience.
Back in the dark ages had an "OS" which had a simple "task table". This was a circular linked list with enough space after each pointer to store the CPU state for a task and some stack. There was one element per task. The task interrupt would fire every 100ms, the registers/stack pointer/PC would be dumped to that, the list followed and the next task picked up and loaded into the CPU, then it'd return from interrupt and off it'd go again. You could call YIELD at any point if you didn't want the rest of your time slice. If you had something that needed to handle an interrupt from the CTC or an NMI, it would disable interrupts until it was done.
Notably you didn't tend to create new tasks. They were hard coded in at assembly time!
Edit: we also had an 8031 version as well.
> Notably you didn't tend to create new tasks. They were hard coded in at assembly time!
Reminiscent of the "executive" in the Apollo lunar module computer.
In general the only thing needed is an external interrupt (which the Z80 has). All but the cheapest deeply embedded 8 bit micros will have one and therefore can support preemption.
It can still be downloaded here : https://www.hpcalc.org/hp48/apps/shell/
You don't need MMU or anything of the sort.
The only thing you need is programmable interrupts.
My implementation was using a 64Hz timer, that was also synchronized on the LCD screen "vsync" as it had to be serviced for kernel-level double buffering and different modes of simulated multiple grey levels.
It is much less difficult than it seems, save registers, save context, load context, load registers, return to the current process.
Optimizing the code is just a good knowledge of the CPU constraints and bit of juggling with registers. It was a simpler time, you could benchmark code by counting cycles, instruction by instruction. No cache, no branch predictors, no throttling.
Those were good days writing demos and crack intros.
Bank switching requires part of the address space to be common amongst all banks (never switchable) so code to manage the switching can execute. In that part of the address space you can do things like monkey patch the OS and driver entry points, or switch banks and collect or patch all the RAM.
You can find the documents on bitsavers, the binaries may well be there and/or on Gaby's site.
¹ https://ia903206.us.archive.org/19/items/Your_Sinclair_003/Y...
Of course with something like a MGT +D with the 8K ROM and 8K SRAM it would have been possible to use the NMI button to switch between two 48K Spectrums on a 128K and have them run a game in one and BASIC in the other.
https://en.wikipedia.org/wiki/Zilog_eZ80
which has a 24 bit address space without the horrible compromises of this guy
Interesting that the eZ80 is used in the TI calculators. I wonder how energy efficient it is comparing to the ARM used in some HP calculators.
It is obvious that nowadays you can do the same in your computer but touching physical buttons makes also a different experience.
[1] https://magnetseven.substack.com/p/merging-craft-and-functio...
https://www.olimex.com/Products/Retro-Computers/AgonLight2/o...
for a while I thought this was pretty cool
but then I saw the Agon stuff which I think is miles better not to mention more affordable.
How does the eZ80 extend out into 24 bits without having an awkward banking system like the '816? (EDIT: I see, it actually adds a 24-bit register mode.)
The biggest problem I found with the 816 was that having no registers larger than 16-bits meant, well, there's no way to store a pointer in a register, or work with data larger than 64k. Well, that and the awful 8/16 mode switching. Oh, and the fact that the stack and direct page are stuck in the first 64k bank. Damn, I really wish Mensch had designed and built a 65xx with a proper 16bit (or higher) architecture instead of the meh that is the 816.
http://www.zilog.com/docs/um0077.pdf
I made it through (most of) the 1980s with a 6809-based TRS-80 Color Computer but I think the 6502 was the most popular CPU in the US then, as the 6502 based PET, Apple ][, C64, Atari 400, Atari 2600 and NES used them. I think it was rare to see Z-80 computers with color graphics, framebuffers, sprites, etc. but it was used in arcade boards and they had this
https://en.wikipedia.org/wiki/MSX
in some other countries.
I wonder if you could build a OS for eZ80 that could run CP/M software, that would get you a pretty large base of software to run.
In an alternate timeline, Apple comes out with the iiGS a few years earlier than it did instead of the Mac but no the ‘816 was not that chip and they would have been looking for a replacement around the time they got looking for a 68k replacement.
a) there just wasn't room in the 8-bit instruction encoding in the '02 to cleanly add 16-bit (or 24-bit etc) versions of each instruction. So instead of moving out into multibyte instructions, he introduced the mode switch and
b) he seems to have done this by doing very minimal surgery to the 6502 core itself, basically adding some 16-bit shunts (depending on mode) in front of the decoder to just change the register sizes and behaviors really. (apart from the improvements like adding relocatable direct page and movable stack, like the 6809 got)
c) apple wanted something that fit in a 40-pin DIP, to fit into existing motherboard design constraints presumably... and for it to support full 6502 compatibility. so we got this awful address bus multiplexing thing, and even after moving up into other packaging, he never fixed that (oddly he later made a microcontroller, the 65C265, that has all 24 pins without multiplexing). If he'd just started with PDIP-64 like the MC68000, so much agony would have been saved.
I think it's a shame really. We could have had a 16/24 version of the 6502 with fewer compromises if the 816 had been a more "serious" project from Apple. But at the time the IIgs was in progress and WDC commissioned to work on the chip, I suspect there was already the politics within Apple about killing the Woz-line in favour of the 68k Mac. We had IIgs systems in my primary school, and they only ever got used as Apple II clones.
I had an Atari ST, and while the 68000 was a great chip, it was clearly targeted towards "VAX" class or workstation type applications originally. Its overall complexity is quite high, and interrupt responsiveness very slow, when compared to the 6502. It would have been interesting to see a Mensch-designed 16/[24/32]-bit processor that kept the same minimalist philosophy as the 6502. Paired with a chipset like what was in the Amiga, I think it would been really cool.
Though maybe the ARM line is that, in some ways.
That’s a long time to learn from other people’s mistakes, if they even were mistakes for the time. I can’t find numbers for either on the web but I guess that, being pipelined, the eZ80 uses more transistors than the 65C816 (also, a Z80 already has about twice the number of transistors as a 6502).
If that’s the case, a better ‘improved 6502’ might have been too expensive for its market in 1985.
Being a little late the eZ80 benefits from a lot of insight, it makes me think if the AVR-8 which is another architecture which ‘completes’ the 8 bit age.
I talked to one of the members for a while.
So basically they use none of the BIOS, so it's purely Z80, which makes it super portable.
They do have different drivers for different videocards. So some configurations work faster than others. I saw a stock MSX and one with some videocard, but I can't remember exactly. The stock one was slow with redrawing at times, but the other one was very smooth.
lymings (lemmings) with sound https://www.youtube.com/watch?v=PfkJLP45FWk
multitasking with pacman https://www.youtube.com/watch?v=Ish4ReOjdIw
networking with wget and IRC https://www.youtube.com/watch?v=bB6X7V6fVyE
The biggest use out of that system was once I typed up an Eliza chatbot BASIC program from a library book. Its quite simplistic but turned out very entertaining to young children like our close neighbors young kids and much later my young nephew/niece. They would always ask for the "Green monitor" anytime they visited and spend hours on it. Much later when we meet up they still recall that "Green monitor" they had fond memories of.
For those occasions you need 2TB attached to a z80...
512 byte blocks addressed by 32bit block number.