HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
The Z80's secret feature discovered after 40 years!

Andy Hu · Youtube · 316 HN points · 0 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Andy Hu's video "The Z80's secret feature discovered after 40 years!".
Youtube Summary
For years, it's generally accepted that 8 bit microcomputer CPUs does not have hardware support for protected mode. However, my recent discovery shows otherwise. In this video, I will show you how to implement memory and I/O protection on a z80 with minimal external circuit.

Links:
General Introduction to the Z80: https://www.youtube.com/watch?v=P9mIXXlxceM
The history of Zilog and Z80: https://www.youtube.com/watch?v=P1aqtfXUCEk
Z80 assemnly tutorial: https://www.youtube.com/watch?v=_J4ahkWtNYw&list=PLPSrOWYluVLJyKIIDxlBtwkFC5lCE3xnY

Edit: this video is the third release! I managed to iron out all problems in the second one, which includes:
1, CRT noise everywhere
2, intro video footages are not muted (you can hear computer noise over the music)
3, 0:55 the (absolutely terrible) B-roll is not muted (You can hear me watching a video about the Mindset computer in the background... I thought it was fine since I could just mute that, obviously I did not...)
4, 1:56 my voice is strangely 'doubled' making me sound like the Borg Queen (this does not happen at all when I'm editing the video! In my editing software the two vioces just overlap entirely and become louder)
5, 2:13 that B-roll (and the horrible CRT noise) is not muted
6, 2:45 a weird 'ding' caused by speeding up the video to hide a long blank
7, music is still too loud, but my editing machine probably have a voice enhance feature enabled somewhere too. This problem is much less pronounced on it (and maybe some other computers but probably not all).

Chapters:
0:00 The Z80 has a protected mode
0:32 Literally the worst intro video ever
0:52 What is Z80
1:52 Why is protected mode important?
3:10 Undocumented? Really?
4:10 How to implement protected mode
10:34 Final Conclusion
12:10 Clickbait?
12:54 Applications of the protected mode
14:27 An interesting story
HN Theater Rankings
  • Ranked #27 this year (2024) · view

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Oct 17, 2022 · 316 points, 138 comments · submitted by tux1968
flohofwoe
Ok... not a hidden feature of the Z80 that hadn't been discovered until now, just a creative way to use existing features and a special address decoding hardware, still clever though.

At 12:10: "Nonetheless, I have made a clickbait video, the type of video that I hate to see" the meta goes deep :D

ChrisRR
It's a shame but a necessary evil. I have seen multiple electronics/retro gaming channels messing about with titles and thumbnails to test what attracts the most views.

The general consensus seems to be they wish they didn't have to, but you've got to earn a living somehow

gmiller123456
It goes both ways, I gotta avoid clicking on anything that looks like it might be clickbait, dislike anything that fools me. My time is more valuable than the penny they get from the ad view.
idonotknowwhy
Firefox with Ublock Origin and SponsorBlock
hvdijk
And flagged this for it. No tolerance for this kind of crap, the guidelines are clear, the original title being false or misleading is when you shouldn't use the original title. The author took a calculated risk. Without the clickbait, some would never have seen it. With the clickbait, others such as myself will resent them for it. I hope for his sake he made the right choice.
mzs
What it is is a sure-fire way to guarantee I go out of my way to never watch another video from anyone that pulls a stunt like this.
tbrake
Lighten up, Francis. You'll forget all about this video and the channel you've added to your (non-existent) grudge list by next week.

What could you even possibly mean by "go _out of my way_ to never watch another video from..."? Sheesh.

mwcampbell
> you've got to earn a living somehow

That's one reason why I will likely never become a parent. I don't want to inflict on anyone the need to somehow earn a living in a world of too many other people trying to do the same.

mastersummoner
Alternately, you could make enough money that you are able to bequeath upon your ilk sufficient money to not need to worry about it too much.

Though if you're doing this, highly recommend not letting them realize you're fairly well-off until they're old enough to know the value of a buck/peso/ruble/euro.

Jolter
You gotta earn a living somehow, but you don’t gotta do it by making retro computing content with misleading titles.
mid-kid
Turns out it worked well. This video got 1000x the views his channel usually gets.
Aissen
If you're interested in secrets for the Z80, shameless plug ! I gave a talk at FOSDEM this year on secrets that were discovered 30-36 years after its release (MEMPTR and some of SCF/CCF behavior): https://archive.fosdem.org/2022/schedule/event/z80/

There are even more secrets that were discovered in recent years that aren't in the talk.

q-big
> There are even more secrets that were discovered in recent years that aren't in the talk.

Could you give details?

Aissen
Despite giving a talk, I'm not an expert on the subject, but if you look at ZX Spectrum forums and the ZX Spectrum discord, you'll find more information: the block instruction flags, the NMI preservation during reset, SCF/CCF flag instability.

I haven't researched any of those yet, but many have and did publish those results ! redcode's Z80 emulator seems to be the most up-to-date on those subjects: https://github.com/redcode/Z80/blob/master/THANKS (has many links to the various reverse engineered parts).

mdp2021
Again Federico Faggin:

> In 1975 Federico Faggin who had had worked at Intel on the 4004 and its successors left the company and joined forces with Masatoshi Shima [] from Zilog. At their new company Faggin and Shima designed a microprocessor that was compatible with Intel’s 8080 (it ran all 78 instructions of the 8080 in almost the same way that Intel’s chip did)1 but had many more abilities (an extra 120 instructions, many more registers, simplified connection to hardware). Thus was born the mighty Z80! and thus was the empire forged

mzs
Did the video presenter say that? It is a verbatim quote attributable to Sean Young. p7 http://www.z80.info/zip/z80-documented.pdf
richardfey
Title is misleading (he even admits it later on in the video), nothing hidden was discovered, it explains how to add extra circuitry to simulate protected mode. Jump to 04:11 if you want to see what this is about.
ddevault
Correction: you can do pre-emptive multi-tasking on z80. I wrote an OS to take advantage of this back in the day. It has interrupts, after all. User programs (as it were) can disable interrupts, but the z80 has NMIs as well if your hardware configuration is suitable for it.
CakeEngine
Indeed. There's also UZI - a v7 UNIX for Z80.
nuc1e0n
Quite a misleading clickbaity video. There was additional hardware added that provides memory protection. It's been done before. Nice description though.
gpvos
If he had named the video "Implementing protected mode for Z80 with minimal extra circuitry", I think it would have gained just as many views - maybe not as fast though.
blueflow
Title is clickbait... the Z80 does not have "protected mode" (x86-specific term), in the video protection of the I/O space is implemented using additional hardware.
matja
Yeah, he built an MMU, which is possible for any 8-bit CPU with similar features - nice work but I don't see any previously unknown features.
tyingq
People talk about the Z80 supporting bank switched RAM, which also requires a small amount of external logic gates but depends on CPU features that didn't exist in every 8 bit CPU of the time. This feels similar.
djmips
Interesting ideas but presented in such a 2020s style haha. Oh well it was still a fun watch.
elesbao
It's a z80 upvote for emotional reasons and also for the ingenuity ! The very story of how z80 came to be is amazingly descriptive of how Intel was shortsighted with its designer.
deltasepsilon
The kid did a marvellous job of presenting information. The excellent technical work is one thing, however the organization and delivery of the material was beyond exemplary.
visarga
Those were the days when hardware was still "understandable" for mere humans.
justinlloyd
Quite apart from what others have pointed out regarding the "hidden" feature that isn't, I had homebrew development systems for both Acorn Atom, C64, ZX Spectrum and a few other machines that effectively banked the RAM. There was the main 48KB of RAM on the Speccy, and a further 128KB in banks that stored the assembly program, the editor, and other tools in a protected space. The 16KB ROM was swapped out for a custom blown 16KB EEPROM that performed the copy from banked RAM to the Spectrum's main RAM, and then the custom EEPROM swapped back with the regular Spectrum ROM, and the machine performed a reset/jmp to execute the actual code I needed. This was most definitely not an MMU in the true sense of the word, but it did give access to a "protected" memory space, a dedicated kernel mode effectively, that the regular Spectrum could not access.
gumby
BTW back back through the mid 70s it was not extraordinary to add protected mode and pagers to some mainframes and minis yourself. I used several machines that had had locally designed memory management added. So I find this especially nice.
sedatk
"Step 1) Add a new circuit."

Not to discredit author's huge effort on this, but that part alone lowers the value of this video orders of magnitude solely because of how the video was titled.

I wish they titled it "Make Z80 protected mode capable with a simple hardware change". Setting expectations right is important.

And yes, it's clickbait.

mrlonglong
I foolishly came here thinking there were undocumented instructions to be found. Not so! Off with their heads all those who write click bait articles.
sixstringtheory
Can’t watch the video right now, but intrigued to know how this could be used, if at all, on my trusty old TI-85. It’d be amazing to be able to hook up a breadboard over the data port to do this kind of thing.
duskwuff
It cannot. This hack depends on being able to insert new logic between the CPU and memory. In the TI-85, the CPU and memory are both part of a single ASIC.
jbverschoor
Nice to see an msx :)
tux1968
Didn't want to editorialize the Video title, but it's a bit of acknowledged clickbait. It's still a clever protected mode, implemented in simple external hardware that leverages Z80 features. Well worth a watch, if you're into that kinda thing.
sumtechguy
The vid even shows what set of instructions this 'mode' would break. Very nicely done.

Sounds like he is a good EE but was a bit frustrated with the growth of his channel numbers. Think his audience will give him a freebee this one time but do it again and they will nope out.

rep_lodsb
>The vid even shows what set of instructions this 'mode' would break.

It would be possible to add more hardware to detect these instructions, so it could then trap and emulate them.

CakeEngine
I don't think it would be. You'd have to detect them on the data bus and also differentiate between data and instruction accesses which I don't /think/ the Z80 does, at least not easily.
rep_lodsb
It does have a pin for that (#M1, "machine cycle 1").

Zilog actually designed their peripheral chips to handle the RETI (return from interrupt) opcode specially. On the Z80 itself it does the same thing as a normal RET, but other chips can detect it on the bus and treat it as the signal that their interrupt handler is finished.

I also recall reading about some hobby project to add a PC-relative addressing mode to the 8080 or Z80. A redundant opcode like "MOV A,A" would be used as a prefix, which caused the external hardware to add the program counter to the immediate operand of the following instruction. Can't find it right now.

becurious
Using M1 plus the address lines was used to trap on certain addresses on expansion devices for the Spectrum such as Interface 1 or the +D. Then they’d use a line on the expansion bus to disable the standard ROM and substitute their own ROM / static RAM until some other trigger such as an OUT to a port would page the ROM back in.

I guess it’s a short step to looking up memory addresses against a bitmap for validation. I couldn’t tell from the video if this is what he did. Cutting the addresses into pages would let you save or add more levels and I guess you could implement a TLB similarly.

brucehoult
6502 has output pins that let you distinguish between instruction fetch, data read/write, and interrupt/reset vector fetch. So you can bank switch based on all that stuff.

6502 doesn't have a pin for "IO space" but you just pick your MMIO range e.g. 0xCnnn on the Apple ][ and a NAND gate on the 2 MSBs and a 3-input OR/NOR on the output and the next two bits gives you effectively the same signal. (or an OR gate on bits 12&13 plus a 3-input AND/NAND on bits 14&15 and the output).

It was common to use 6522 VIA 8 bit output ports to bank switch one or two 4k ranges to allow each such 4k range to access 256*4k = 1 MB of RAM. You could use a 16x8 bit SRAM to do the same thing for the whole address space.

sixstringtheory
Kind of ridiculous how many other top-level comments there are complaining about the clickbait title when you called it out right here in a level headed way.

It’s like the tweet- and video-ification of online discourse have destroyed peoples’ reading comprehension. (On reflection, though, the average person was never good at it. At least it’s mostly confined to annoyances on the Internet instead of, like, political elections or mob violence, right? Right??)

scaramanga
Yep, and the presenter is great, and loads of interesting tidbits in there for those interested in 8bit computer architecture.
downvotetruth
The nonclickbait would be a shim boot or gate z80 on z80 emulator layer?
codetrotter
In the case of misleading or clickbait titles, my reading of the HN guidelines for submissions [0] is that it’s ok to change the title. And my opinion is that in such cases a more accurate title written by the submitter is better than the original title.

[0]: https://news.ycombinator.com/newsguidelines.html

mzs
What a click-bait vid, here's a PDF: http://www.z80.info/zip/z80-documented.pdf
Quequau
So I'm scrolling through this and wonder just how useful this info would have been back in the day when we were working with Z80s and came across this:

This section might also relevant even if you don’t do anything with hardware; it might give some insight into how the Z80 operates. Besides, it took me hours to draw this.

I feel so validated because I myself have included content in user manuals for the pretty much the same reason.

INTPenis
He mentions this in the vid, a few minutes in.
musicale
> He mentions this in the vid, a few minutes in.

transcript >>> video

nottorp
Oh ty, I knew why I didn't click on the video and just skipped to the comments.
the_arcadian
Thanks!
None
None
audunw
> What a click-bait vid, here's a PDF: http://www.z80.info/zip/z80-documented.pdf

That PDF isn't what the video is about though.

It's not really that much click-bait either. "Method to implement Z80 protected mode discovered after 40 years" would be more correct, but that's too convoluted for YouTube's algorithm.

mzs
That PDF is about undocumented Z80 features discovered over the years. That video is not about "The Z80's protected mode discovered after 40 years…" That video instead should have been titled "My janky hack to isolate Z80 IO space" hence its click-bait title. If it had been titled appropriately I would not have wasted time seeking about looking for the recent discovery. Since there have been pretty astounding discoveries over the years I was pretty upset by the video hoping for a new one. I hope he doesn't pull a stunt like this again.
authpor
imagine how long it'll take to dig out whatever any modern intel has?
m0d0nne11
Click-bait. C'mon HN, we're better than this...
japanuspus
Have to upvote - just because Z80: I spend my youth programming this thing literally in hex: To program my Amstrad CPC646, I wrote down opcodes on a piece of paper and then manually translated to hex according to a copy of the Z80 spec sheet I found in the back of some book. Relative jumps were especially fun...

If only I had had the internet, maybe I would have stumbled on the concept of an "assembler". Not sure if it had been more fun? In any case, I did not find the protected mode.

Starwatcher2001
I did a lot of that on my CPC464 and TRS-80 too. Thanks for rekindling the memory. Relative jumps were the easiest way to make code relocatable, but you were limited to +/- 128 for an offset.

I used the "Programming the Z-80" book by Rodney Zaks, which is still on my bookshelf. Some manuals just can't be disposed of!

From memory I recall my favourite instruction - LDIR (Z80 block memory move) is EDB0, and JMP is CA.

Slightly more on topic, I piggybacked a 2716 EPROM onto the back of the TRS-80 ROM so I could get to the previous hard-coded RST locations and interrupt vector of the Z80 processor. In a nutshell, that allowed me to stop/debug/hack running programs without software being able to prevent me.

Fun times.

jgrahamc
I used the "Programming the Z-80" book by Rodney Zaks

I have that and the 6502 book by Zaks also. I read those books when I was a teenager as if they were tomes filled with wisdom of the ancients. I protected them with plastic book covers and wrote my own notes in the margins in pencil. I worked a Saturday job when I was 16 and spent the money on them. At the time they were so expensive!

davidgerard
same, protective plastic cover and all
GeorgeTirebiter
Thanks you guys, now the eBay price for those chestnuts has likely doubled! ;-)
abraae
Ditto, I've been purging my old tech books but I just couldn't let the Zaks book go.
pmontra
Same plastic cover on Zaks' book (it's still there) and excellent paper quality.
JoeAltmaier
Curious note: the opcode space of the Z80 was best viewed in octal, not hex. The first 2 bit decoded the instruction class e.g. 01 was the MOV set of instructions. The next 3 bits were register destination; the last three were register source?

Registers were numbered [0-7] b,c,d,e,h,l,m,a if I remember right. h and l were 'high' and 'low' part of the 16-bit indirect 'm' memory address.

So in octal, 134 was "mov e,h".

You now know 1/4 of the entire Z80 instruction set!

mdp2021
> If only I had had

I never understood how the English, and sometimes the Dutch, seemed in general (looking at their results) to be able to learn many times faster than amateurs in other territories. Sometimes with borrowed machines! "They gave me this, and after some weeks I had my first videogame working". I guess/ed it may have been a matter of human network - of being able to find knowledgeable people in the neighborhood to learn and exchange -, but it seems to have been often a solitary effort. It seems in a way like a talent, like that of the Scots for inventions, but there have to be keys that made kids talented coders through their own natural grit.

Others have had difficulties in finding documentation alone, not to mention competent peers.

Shorel
I think it is also because of the game publishing industry.

I made a Tetris clone in Pascal, running in a 286 machine with 1 MB of RAM. It took me about a week of coding, and it ran as a single segment program, so it was limited to 64Kb of memory.

For me, this was the moment I learn about for loops. The program was a big collection of for loops.

I could have made some original game, but being Colombian, living in Bogotá, no one would have bought it. Everything we had was pirated, so there was no incentive to actually publish anything.

benj111
Speaking as a Brit. I don't think we have the capacity to learn many times faster.

I suppose there is something in our culture. A lot of inventions and science has come out of the UK.

There's also an (I assume) cultural phenomenon of tinkering in the garden shed.

I suppose there's the Protestant work ethic, the ethic of self improvement, a general acceptance and perhaps celebration of odd balls and tinkerers.

It the field of computing, it probably helps that we speak the same language (ISH) as the us, where a lot of this tech came from, but didn't have the money to just buy solutions.

But I don't really have any experience of other cultures in this context to say whether these things are unique.

_0ffh
>It the field of computing, it probably helps that we speak the same language

Then again, I think working through untranslated English material for my computer hobby helped me gain language proficiency more quickly than many peers.

mdp2021
My first word in English had most probably been 'ready' ;)
benj111
True. But if I'm reading z80 documentation, I'm going to be able to read it more easily. Plus I don't have to be also willing to learn a second language.

Of course in the end you have computing skills and a second language.

Slightly off topic question though. Are programming constructs based around or influenced English making it easier to learn as an anglophone?

Would (true)if be more common, or do{}while(true) be more common if English weren't the Lingua Franca?

I know you could find examples of these in many languages, but they aren't 'standard'

Brian_K_White
I have wondered about that. Every time a new language or framework attempts or claims to be more natural, I think "for who?"
kolleykibber
For me, as a kid back then it was the magazines. I would wait all month and then devour the latest Felix Denis publication end to end. The editors of these magazines could be considered the orchestrators of the UK 8 bit scene. Manuals were out of my financial reach.
mdp2021
> a general acceptance and perhaps celebration of odd balls and tinkerers

Paradise! (No, really, that is respectful and intelligent - if in general people can perceive that "the guy has something", that is already a big social asset.)

> other cultures

Other cultures may be quite diffident and promoting different "values" - in the streets you will more often find "socialites". At the extreme, a Siberian once told me: "They would go and beat up the different. «You are different», they would say, and beat you up".

benj111
Well I don't want to over egg our acceptance of 'different', there are certainly differences that aren't accepted, and certainly weren't in the past.
ChuckNorris89
>I never understood how the English, and sometimes the Dutch, seemed in general to be able to learn many times faster than amateurs in other territories.

I don't think that's the case, I think it's that the achievements form the English and the Dutch are shared on the English speaking internet so it's more easily to run into them VS for example, the German speaking hackers who, at least in the past, only shared their work on the German speaking internet instead, so their achievements are less likely to get international visibility.

It's the same with other cultures that have a huge population/market share. If you'd venture on the Russian speaking part of the internet, you'll find a gold mine of hacks, cracks, reverse engineering, and crazy software that flies under the radar.

mdp2021
> internet

We are talking about the scene in the early '80s.

Products were sold in shops and via mail and were advertised on magazines. Remote networking was on Bulletin Board Systems - and with limited diffusion. The hacker coding his¹ product probably did not easily have those things around.

¹(A 'his' that calls for a pluralized 'her', out of respect to a group that created a closed-doors women-only community in Ireland and produced "women-only" themed adventure games: they were in a way similar to a sect but sold their own software as part of the funding - I cannot remember names right now. I believe there exists a photo of a group of coders with two ladies dressed in Victorian costumes (which apparently were the uniform in said community), after a social gathering. This gives an idea of what could contribute to the scene. Edit: found: it was the "Silver Sisterhood", in County Donegal - https://en.wikipedia.org/wiki/Silver_Sisterhood )

ChuckNorris89
Replace the word internet with various paper based publications and my argument still stands.
mdp2021
Sure, but check the distribution of actual products and you go back to the image I drew.
porlw
I think it was because in the 80's the US was wealthier and systems with disk drives were a lot more common.

People would swap games on disk, and there was less pressure to learn how the underlying system works.

Having a disk drive also enables more complex, larger games, which would be harder to produce as a lone programmer.

Contrast this with the UK - we had much less money, it was common to type games in from magazines, which is how a lot of us learned programming.

We mostly had to make do with tapes, which limits the size of a game and its sound and graphics to physical RAM. It was entirely possible as a lone programmer to create a commercial level game with a few weeks of late night hacking.

mjw1007
Here's one example of a network effect that happened without actually meeting other people: I certainly wouldn't have considered spending my pocket money as a thirteen year old on a new copy of the Zaks Z80 book, but I stumbled on a second-hand copy in a charity shop for a few pence.
josh2600
I’ve found that there are oddballs in just about every culture who make new things. Some cultures celebrate them, others don’t. The most tolerant cultures tend to get the most interesting new art.

Edit: corollary, some of the best new art happens in the most restrictive environments. Maybe it’s a case of living at the extremes?

Someone
I guess it may help achieving Goethes “In der Beschränkung zeigt such erst der Meister” (“the master shows himself through restriction” / Antoine de Saint Exupery’s “la perfection soit atteinte non quand il n'y a plus rien à ajouter, mais quand il n'y a plus rien à retrancher” (“perfection is not achieved when there is nothing left to add, but when there is nothing left to take away”)

If you have little to work with, adding stuff often forces you to remove or shrink something else.

mdp2021
I think that some environments raised kids to be grittier, more focused on getting results (and less e.g. prone to consume time in entertainment).

> some of the best new art happens in the most restrictive environments

You reminded me of Paul Buchanan, frontman of The Blue Nile, revealing that they would compose and rehearse standing shoulders to a wall in a narrow corridor in a house in Glasgow - that was the room they had.

josh2600
So real.

I grew up real poor and it made me hungry. I think that's where a lot of the hacker mentality comes from, one form of poverty or another.

I am hoping to raise children soon and I am wondering how to help them to feel a hunger for the world without suffering in the same way I was raised. It's hard for me to imagine how they'll learn to thirst for the experience of the world if they don't have the same socioeconomic pressures, but I think that will be one of my most profound growing experiences in this life. I intend to accept them for who they are and to try to give them as much opportunity as they can stomach.

japanuspus
Just for context: I grew up in a small village in Denmark. My window to the world was one-hour bus trips to the nearest town which had a decent library, including some computer magazines.

None of my peers did any programming, and since Denmark does not have flat-rate local calls, calling up via modem to connect to a BBS was never really an option -- so there was really no-one to share with. That is certainly somewhere were the internet would have been a plus.

FearNotDaniel
I'm sure media coverage helped. Back in the 8-bit days in the UK there was a regular BBC TV show for computer buffs that introduced a lot of the concepts, and each platform had a minimum of one glossy magazine per month full of tips and info - I remember reading about assemblers for both ZX Spectrum (Z80) and Atari (6502) in these kind of publications, that were widely available at regular newsagents.
Lio
I wonder if the presence of other machines in the market made things like assemblers more well known in the UK.

i.e. BBC Micros came with an assembler so it's the kind of thing BBC users would tell CPC464 users about and they would then buy third party.

Why did the BBC Micro have an assembler? Well the people made it started out in a university setting with access to all sorts of things that they wanted on their small computers.

E.g. BBC Micros had networking before most other 8-bit machines simply because the original developers had used it in a research lab.

In other markets you might just be working on your own and so wouldn't know about things like networking because you wouldn't have an immediate need for it.

To quote William Gibson, the future is here already it's just poorly diffused.

mkr-hn
It was a short hop from picking up Castle of the Winds II at a dollar store to finding out about resource editors and win32 when I wanted to edit the images. The game itself was from 1993, but this was in the late 90s/early 2000s when you could Google stuff like this and land on programming forums. And likely a post from someone else who wanted to do the same thing.

I still had to know about it. If I'd never found Rick Saada's experiment in win32 packaged as a game for a dollar, would I know about any of this? I wonder if the growing availability of the internet has closed the gap any.

rep_lodsb
Not technically "win32", Saada wrote it to experiment with the new-at-the-time Windows 3.0 API (still 16 bit) while at Microsoft.

It's now in the public domain and should run under Wine on Linux, as well as 32 bit versions of Windows:

http://lkbm.ecritters.biz/cotw/download.html

mkr-hn
I don't know why I remembered it as win32 from when he wrote about it. Anyway. I remember downloading a save editor from AOL's software center, so the stuff on that page brings back memories. I had a broken 10+ MB save from trying to get every item and explore every block in every dungeon. I'd pile stuff up by category in the middle of town.
mananaysiempre
There’s an Russian-language memoir[1] by Kronrod (of the ITEP programming school that also includes Adelson-Velskij and Landis of AVL fame and served as the birthplace of ABBYY some decades later) that mentions that for some time, they did things exactly that way, and that it was a small breakthrough to be able to talk about symbolic variables and draw jumps graphically once they had explained to the secretarial staff how to translate that into addresses. So, taking into account the lack of accessible reference material, you are in good company :)

(The book also includes a discussion on VLIW-style microcoding, a plea for more registers, and a note how a population count instruction may be worth including despite its situational utility because of how easy it is to do in hardware compared to a software emulation. That team did one of the first chess programs, though, so it’s not surprising popcount came to minds easily.)

[1] https://www.goodreads.com/book/show/58582645

Gordonjcp
The ZX81 and ZX Spectrum manuals had the character code table (ASCII-ish on the Spectrum, something totally different on the ZX81) alongside all the Z80 mnemonics and their hex and decimal values in the back.

I think the Jupiter Ace manual might have had that too, but it's been a long time since I've even seen my copy of that.

tluyben2
Yep, I still know all the hex opcodes of the z80 (MSX) now so many years later. It was nice; just type them in basic, poke and go. I never, at that age, knew the assembler equivalents and didn’t know it was a think until many years later. I learnt c and pascal before having an actually z80 assembler. After that I moved on to Amiga where I did learn 68000 instructions to make demos and games.
ikari_pl
Nice, you had a spec.

I had Discology, it had built-in disassembler. So I wrote a binary file like 00 00 01 00 00 02 00 00 03... and disassembled, and put in a notebook what code produced what command (then adding different arguments than all zeros, then finding longer opcodes and generating a new file for them...)

wazoox
I knew what an assembler was (because my friend who had a C64 had one), but it was too darn expensive, so I wrote one myself in MSX BASIC :) Though it was very primitive, and didn't implement much more than an opcode table and a load and save to tape feature.
actionfromafar
I bought one from a classified in a computer magazine. The guy who sold it had written it himself, in hand assembled machine code. I knew there existed other assemblers, but I couldn't find any to pirate or buy.

I didn't have a disk drive, only the standard cassette deck, so before selling it to me he had to slightly rewrite the assembler to support loading and saving programs to cassette.

In the end, the syntax was not exactly like in the Rodney books. Some examples worked, some not, so I resorted quite a bit to hand assembling myself.

wazoox
As I had the Rodney book (and no disk drive: it was twice as expensive as my computer!) at least I implemented my assembler as the one from the book :)
bch
My “paper programming” experience was about the same, but on the Vic-20 and Commodore-64. Only later did I realize the mnemonics could be coded directly, rather than me getting the decimal opcodes from a table and POKE-ing them into memory.
craig_livpl
I did the same, but with an Oric Atmos (6502). It came with an amazing manual, which I've recently had another look at. It taught BASIC, character graphics, machine code, binary and how negative numbers are represented, memory addressing, addressing modes, registers, and the instruction set, explaining each instruction, the machine's memory map, ASCII, lists of binary, hex and decimal conversions and tables of op-codes, ROM routines with call and return parameter registers, circuitry of the machine, and a decent index. I think I learnt more about computers from that book than from any other.
chx
C9 club members unite!

(I forgot it all. It's been 35 years ago last I did this and high school mostly crowded it out of my memory. But C9 was RET, that I still remember. ZX Spectrum, for me. But Z80 manual (dis)assembly nonetheless.)

markx2
CPC6128 with among others a MAXAM 1.5 ROM hanging off the back. (Along with PROTEXT).

Couldn't write BASIC to save my life, but Z80 Assembler using MAXAM and the 6128 detailed manual and I flew along happily.

https://www.cpcwiki.eu/imgs/e/e2/Maxam_Manual.pdf

Edit to add: Found the Firmware Manual

https://archive.org/details/SOFT968TheAmstrad6128FirmwareMan...

kazinator
> If only I had had the internet ...

I joined the fray later, in the early 1980's. I had access to public libraries, computer magazines like Byte and Creative Computing, computer stores with software, books and magazines, dial-up BBSes, computer expo events, enthusiast meet ups and swap meets, ...

kazinator
Though knowing what an assembler is didn't translate to easily getting one.

I used an interactive instruction-at-a-time assembler inside the Apple II+ ROM. This was a small level above entering hex. MS-DOS had a similar facility in DEBUG.COM.

Eventually I got my hands on a copy of Randy Hyde's LISA (Laser-Systems Interactive Symbolic Assembler), and was able to make larger, more complex programs.

mfuzzey
I did that too, on a ZX80 back. Well after a week of doing it using a book and caclulating relative jumps (the backawards ones were worse) by hand I thought "there has to be a better way" and wrote my own assembler in BASIC (but I didn't know it was called an assembler at the time)
shever73
Did exactly the same on a ZX Spectrum. Fun times! Sprites drawn on graph paper and every byte was precious.
pjmlp
I feel you pain, using DATA statements in BASIC, or monitors, as I could not yet afford buying a nice Assembly editor at the time, and there wasn't none I could find on local shops, importing it from some UK store would have been the option.
KingOfCoders
Me too, my first real assembler program was a hex editor with RSX |hex on a CPC464.
Tepix
Having to do the opcode translation to hex manually sounds like torture!

I started with the 6502 on the C64, the Z80 came much later when i wrote some trainer patches for Gameboy ROMs.

rwmj
The ZX81 & Spectrum manuals had a big table of opcodes in the back so it wasn't too bad. Most of them you memorized after a while. See page 94 here: http://www.retro8bitcomputers.co.uk/Content/downloads/manual...

Other Z80 computers did have pretty capable assemblers, even with simple macros as I recall.

mrspuratic
This was the tersest possible listing of opcode mnemonics :/

I cobbled together a basic understanding from various machine code listings (Toni Baker, Your Sinclair IIRC), and my "assembler" was paper, pencil and a FOR/INPUT/POKE loop...

My uncle loaned me a Sharp MZ700 one summer, its manual had a detailed breakdown of Z80 opcodes (in mere 4 pages) which was a revelation to me, and an annotated monitor in assembler. https://archive.org/details/sharpmz700ownersmanual (p160-)

flohofwoe
After a little while you know the most common opcodes without having to look them up, I still have some burned into my brain forever:

LD HL,nnnn: 21 nn nn

LDIR: ED B0

JMP nnnn: C3 nn nn

CALL nnnn: CD nn nn

RET: C9

...etc..., and probably dozens more after getting back into the groove :)

0xf00ff00f
Wow, I've just remembered C3, CD and C9. What a blast from the past!
Tepix
I only remember NOP from x86 assembler: $90
moosedev
> To program my Amstrad CPC646

Now I wonder if you meant CPC464 or CPC664 :)

(Probably the former, as the 664 was relatively rare, at least in my experience. I’m not sure I ever saw one.)

xattt
What would you say would be a contemporary equivalent for kids to poke around on to the same experience you had back then with the Z80?
le-mark
This code and go type of environment was indeed the differentiator of those machines. I miss this too. Toward this end, I recently made a JavaScript plus html page with a textbox and canvas element with a simple gfx api. It uses eval to run the code from textbox and draw on the canvas.

I pointed my kids at it to do some coding, they seem to enjoy it.

bbojan
Haha, did the same thing also on a CPC464.

I did know about the concept of "assembler", I just wasn't able to obtain one.

davidgerard
did the same with the Rodnay Zaks book to hand. Definitely my favourite tech manual in my early teenage years.
natas
the 464 was a ton of fun, I spent more time with it than my own family.
mattl
464 or 664?
zimpenfish
> In any case, I did not find the protected mode.

Because, unless I'm misunderstanding the video, it doesn't exist until you add a whole bunch of external hardware (which is why the video is clickbait - a fact he acknowledges later.)

korfuri
I mean, true, but "a whole bunch" is kind of misleading. It's a really clever hack using really a tiny amount of extra gates. It's still a very cool and innovative hack that nobody really had thought about before.
rep_lodsb
It certainly has been thought of before. Using external circuitry to remap the address space was common with lots of different processors, and once you have that (and a way to jump to a controlled address from hardware) it's a logical next step.

That it wasn't something usual with microcomputers of the time wasn't because it would have required some uniquely clever design. Rather it had to do with them being single-user/single-task, with simple operating systems where programs were expected to have full access to the machine.

kragen
Yes, there were lots of 8-bitters that used bank switching. But I think you have the causality somewhat backwards. 8-bitters didn't lack memory protection because they didn't have operating systems that could use it; rather, their operating systems couldn't use it because it wasn't there. Multitasking was of course useful, then as now, and sometimes people did do multitasking on them despite the generally limited memory; it was just less reliable because programs could crash each other. Multitasking was common in real-time control, which is how THERAC-25 happened (on a non-8-bit machine, but due to a race condition between threads).

A common use for multitasking in the 8-bitter era was print spooling; it was very inconvenient to have to wait for your document to finish printing before you could continue editing! People frequently bought external hardware printer spooler boxes to connect between their computer and printer because of this. Similarly, duplicating floppies was pretty inconvenient because you couldn't do anything else while it was happening, even if you had four floppy drives like I did, with literal megabytes of storage space available to read porn or play video games while the floppies were copying.

Historically on larger machines it was also common to use multitasking to overlap very slow disk I/O with useful computation. (The alternative is to use asynchronous I/O and write your program as an event loop, like a game or Node.js, or to do your I/O from interrupts, which is close to multitasking.) In theory this could have been useful on 8-bit micros as well but I don't think I saw any cases of it actually happening.

kazinator
Using external signals for some sort of protection isn't innovative. This is a documented feature of the Intel 8086: the S3 and S4 pins expose which memory segment is being accessed: code, data, stack or extra segment.
waynecochran
Yeah, but as the author says, it renders the whole maskable interrupt system useless… so it is not something you would do since it would undermine too many useful parts of the chip.
vintermann
Reminds me of the printer interrupt hack Darklite/Offence used for their Tiki-100 demos.

The Tiki-100 is an obscure Norwegian 8-bit computer from 1984, also Z80-based. It had nice graphics for its time, with 16 colours from a 256-colour palette. However, it was very hard to use productively, since the machine had no video sync interrupts.

What the guys in the demogroups figured out, was that it did have parallel port interrupts, and with a tiny hardware mod (just a wire from the expansion port to the parallel port), they could "steal" those for Commodore 64-style raster interrupts.

actionfromafar
Heck, one could connect a Commodore 64 to the Tiki and get synced frames.
moron4hire
It's not uncommon for chips to support configuring different features by wiring in external components. Though usually they are passive components, this isn't completely absurd.
visarga
Just a flip flop and an OR gate.
qwerty456127
> until you add a whole bunch of external hardware

Why mind this if the hardware to add is the same level of technology like Z80 itself? I would be glad to build a computer as advanced as possible combining some Z80s and additional HW.

zimpenfish
> Why mind this if the hardware to add is the same level of technology like Z80 itself?

But it's not "the Z80's protected mode" - it's "the Z80 + an extra circuit to emulate protected mode". It's a super clever hack, yes! But filthy clickbait also.

mannykannot
There’s a small irony in your clickbait complaint containing a misrepresentation of the content.
II2II
Sure, but if memory serves me correctly, many early workstations used a microprocessor with an external MMU. It is misleading in the sense that it is not part of the Z80, but it is in the character of the times. (And MMUs are not the only CPU feature that was originally external. The FPU is an example that more people will be familiar with since it was an upgrade path available on many personal computers.)
jandrese
I don't think MMUs were common on machines that ran on a Z80 however.
300bps
The Commodore 128 had an 8502 CPU, a Z-80 CPU and an 8722 MMU.

Was a pretty popular machine - sold 5.7 units worldwide. But probably only a tiny fraction actually used the CP/M mode that used the Z80.

jandrese
Wow, I had no idea there was basically a second computer hiding inside of the C128. No wonder it cost so much.
anticensor
Did you mean 5.7M?
philistine
I don't know what's more concerning. The fact they only sold 5.7 units, or the fact someone managed to only buy .7 of a Commodore 128.
otto2
The sixth unit had CP/M disabled, so accountants wrote it down as 0.7 units.
NegativeLatency
For example a Programmable MMU was an optional add on for the Macintosh II (which wasn’t a z80 but serves to illustrate the time when they began to become available to home computers)
DonHopkins
The home-brew pager (MMU) of the MIT-MC PDP-10 KL10 was appropriately called "KL-UDGE". (KL was the prefix of the PDP-10 model).

https://en.wikipedia.org/wiki/Kludge

It's on display at the Paul G. Allen Living Computer Museum.

https://sites.google.com/site/mthompsonorg/Home/pdp-10/pdp-1...

https://donhopkins.com/home/catalog/images/mc-console.jpg

Lars Brinkhoff has taken photos of the KL-UDGE blinken lights panel and naked wire wrap boards:

https://twitter.com/larsbrinkhoff/status/1128601896619524097

>Photo 6/7: KL-UDGE lights panel

>Photo 7/7: KL-UDGE boards. Real-time time of day clock?

wk_end
Was on display. The LCM closed due to COVID and there's no indication that it's coming back, sadly.
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.