Live data from Hacker News

Pre-emptive Z80 multitasking explainer

github.com

31–33 of 33 posts

Re: Pre-emptive Z80 multitasking explainer

#31
post #21
post #5

So now we can do timeshare Nintendo Gameboy? /s

I actually wrote my first toy multitasker on a Gameboy Advance, although that's ARM7... Great little project. It's a joy to develop on an emulator with good debugging tools.

I was thinking more about the sharp sm83 chip. Gameboy Advanced is just too modern by comparison...

Re: Pre-emptive Z80 multitasking explainer

#32

Earlier quoted context omitted.

Forgot this is HN where everything is taken literally. Humour is [Flagged]. I myself made a Coin-Operated Telephone server, but in 1978 the processor was already cheaper and faster 8085.

Low effort humour is discouraged, it's in the site guidelines and since it wasn't amusing, just confusing, perhaps you should skip the humour and consult them.

Uh. I seem to be suffering from the Mandela effect; it is not in the site guidelines. It's definitely the overall policy officially or otherwise though (one which I'm entirely happy with despite having a juvenile sense of humour myself).

I think this essay is where it originated: https://paulgraham.com/hackernews.html

Re: Pre-emptive Z80 multitasking explainer

#33

Writing my own pre-emptive multitasker in Turbo Pascal on our x86 as a self-taught teenager was a core memory thing. I recall spending a few days mulling over the exact sequence of instructions to save the state of the previous task without clobbering the flags or any registers. The result was that I could register functions (procedures) as tasks with their own little stack, and it would switch preemptively between t…

I did something similar as a teenager using DOS Microsoft C to implement the Amiga's exec.library and other bits and pieces on the x86. I managed to get preemptive multitasking working in 8086 real mode, along with a serial and tty device. Later on I implemented bits and pieces of dos.library in an emulator that let me run some m68k Amiga shell binaries (like the Aztec C compiler) from a Linux command line. That was invaluable practice for learning about different execution contexts, interrupts, locking and such for Linux kernel programming. I had even written a very simple C compiler with a friend that I used to mangle C code into endian swapping code that ran natively on my 486 so that the Amiga code could call into native code to do Linux syscalls and such.

The experience of figuring these things out was tonnes of fun! There's nothing like following threads of assembly with a debugger or disassembler in the Amiga's ROM to get a better idea of how the code worked. And since systems were so much smaller in the 1980s, a single person really could understand virtually everything about the system with enough time and effort.

The biggest challenge for me was that the ROM Kernel Manuals were very expensive back then, so I wasn't able to get copies until far too late in my Amiga years (with Commodore being in its death throes).

Motorola and Intel were great back then as they would ship out printed copies of all the documentation for various CPUs and support chips for free upon request!

Good times!

Post reply on HN