[HN Gopher] SymbOS Z80 multitasking operating system
___________________________________________________________________
SymbOS Z80 multitasking operating system
Author : jbverschoor
Score : 123 points
Date : 2023-12-22 16:57 UTC (6 hours ago)
(HTM) web link (www.symbos.de)
(TXT) w3m dump (www.symbos.de)
| jbverschoor wrote:
| I recently played around with this at MSXGOTO40. Crazy to see an
| MSX do all of this. Videos at https://www.youtube.com/@Prodatron
| FullyFunctional wrote:
| Thanks, that gave a good impression of SymbOS which is boggling
| my mind a bit.
| jbverschoor wrote:
| Yeah, I was totally flabbergasted.. Seeing an old rusty MSX
| of almost 40 years old pulling off multitasking. They had
| quite a few apps and games (even the z80 doom haha).
|
| 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.
| jbverschoor wrote:
| Notable videos:
|
| 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
| PaulHoule wrote:
| I've looked at a lot of the old architectures from the 1980s and
| gradually came to the conclusion that I liked the Z80 the best,
| particularly because it has a follow on
|
| https://en.wikipedia.org/wiki/Zilog_eZ80
|
| which has a 24 bit address space without the horrible compromises
| of this guy
|
| https://en.wikipedia.org/wiki/WDC_65C816
| wslh wrote:
| Is this guy the WDC 65C816? Just want to know if I understood
| your comment correctly ir if I missed something.
|
| 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.
| PaulHoule wrote:
| Yes I did mean the WDC 65C816. It had a 24 bit physical
| address space but it didn't widen the registers enough that
| you could easily take advantage of it.
| epcoa wrote:
| I would guess in terms of raw compute efficiency the ARM will
| beat the eZ80 due to the older Z80 architecture (3x faster
| than slow is still slow, and the HPs used ARM9 IIRC, while
| the eZ80 is more similar to an ARM7 and only a 24 bit ALU,
| etc). However for a hand held calculator it's unlikely to
| make much difference where hardware process, power
| management/clock domains and peripherals are going to be much
| bigger issues.
| shrubble wrote:
| I believe this is the CPU used in the Agon series of retro /
| hobbyist single board computers.
| PaulHoule wrote:
| Yep
|
| https://www.olimex.com/Products/Retro-
| Computers/AgonLight2/o...
|
| for a while I thought this was pretty cool
|
| https://www.commanderx16.com/
|
| but then I saw the Agon stuff which I think is miles better
| not to mention more affordable.
| cmrdporcupine wrote:
| I was a 6502 guy back in the 80s, before I went 68k, and never
| had a machine with the Z80, so have no nostalgia for it. But
| when I look on paper, the Z80 really does look like it stood
| the test of time better.
|
| 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.
| alexisread wrote:
| I'd imagine the ez80 uses an extended register fusion setup
| ie. You can use 3 8bit registers as a 24bit register. I think
| that would take 3 cycles to use the full address space, but
| for the first 8bit space I guess it would work like utf8 in
| that you just use 1 register (byte).
| andyjohnson0 wrote:
| I'd be very interested to know how preemptive (rather than
| cooperative) multi-tasking is implemented. It's been a while but
| I don't remember the Z80 having any suitable primitives upon
| which to implement preemption.
|
| 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.
| actionfromafar wrote:
| Timer interrupt
| actionfromafar wrote:
| Z80 has two sets of all registers:
|
| https://retrocomputing.stackexchange.com/questions/7794/did-.
| ..
| sedatk wrote:
| Z80 has a mirror register set that can be swapped immediately.
| That makes task switching faster.
| CodeWriter23 wrote:
| For up to two tasks
| sedatk wrote:
| No, for kernel code that handles the switching.
| CodeWriter23 wrote:
| EXX doesn't transfer to RAM, only to the ' register set.
| Great for ISRs (as long as you can single-thread the
| interrupts) but you're not going to track task state
| using it.
| cornholio wrote:
| Z80 has a non-maskable (NMI) interrupt line that will break
| whatever code is currently executing without allowing the
| software to opt out (EI/DI instructions), and then jump to a
| hardcoded page zero location, I believe it is address 0x66.
|
| 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.
| baz00 wrote:
| As other people have said, there's an NMI line. But that's not
| usually how it's implemented because you tend to want to mask
| it if the thing is doing a real time or time critical task. The
| Z80 CTC was the canonical solution.
|
| 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.
| andyjohnson0 wrote:
| Thanks. Back when I last wrote an z80 asm I didn't have
| access to an environment with anything like an os.
|
| > 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.
| epcoa wrote:
| > Z80 having any suitable primitives upon which to implement
| preemption.
|
| 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.
| stephc_int13 wrote:
| I once implemented a pre-emptive kernel and OS on a very crude
| hardware, the Hewlett-Packard Graphing Calculator HP48GX,
| running a Saturn CPU (4Bits with 64bits registers, a weird
| beast).
|
| 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.
| GlenTheMachine wrote:
| I did something similar on the C64 (6502). Programmatically
| user code could mask interrupts, but as long as it didn't it
| worked fine. It saved all the registers and restored them
| prior to switching execution threads. The unified memory
| space required that each thread ask for an absolute memory
| offset to be allocated and then voluntarily stay in that
| space.
| CodeWriter23 wrote:
| They're not claiming protected mode multitasking.
| jbverschoor wrote:
| Yeah they don't have protected mode. They are working on a
| language+toolkit to create windowed applications. I guess
| something like Visual Basic.
| dfawcus wrote:
| Even DRI's MP/M from 1979 had preemptive multi-tasking, as long
| as the platform supported an clock interrupt.
|
| You can find the documents on bitsavers, the binaries may well
| be there and/or on Gaby's site.
| tempodox wrote:
| Amstrad CPC! I can remember when you could buy one at the
| department store. Computing was adventurous exploration then.
| sixothree wrote:
| The thing I miss the most is every device having an answer for
| "what makes this thing interesting or unique". No longer is
| that true or as relevant really.
| notorandit wrote:
| When I see this type of marvels I stare at my mobile phone and
| think about the amount of wasted power. Such powerful hardware
| should be able to let me do a lot of things and instead it
| doesn't.
| rogerkirkness wrote:
| Battery life. Compute has overshot battery life.
| nxobject wrote:
| In line with that, it's crazy to think how portable 8-bits
| could once be powered off standard AA batteries...
| Affric wrote:
| Is it battery life and thermals?
| rogerkirkness wrote:
| That too!
| jbverschoor wrote:
| Maximum power dissipation 0.79 Watt
| dang wrote:
| Related:
|
| _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)
| _joel wrote:
| > Preemptive multitasking - 1024 Kb dynamic memory - 2 terabyte
| filesystem
|
| For those occasions you need 2TB attached to a z80...
| GeorgeTirebiter wrote:
| Congrats on taking this concept far beyond 'proof of concept';
| well done.
|
| 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.
___________________________________________________________________
(page generated 2023-12-22 23:00 UTC)