13 ms·
Simulating protected mode in the Z80 [video]
- justinlloyd 4y agoQuite 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.
- tux1968 4y agoDidn'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.
- deleted 4y ago[deleted]
- codetrotter 4y agoIn 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 https://news.ycombinator.com/newsguidelines.html
- sixstringtheory 4y agoKind 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??)
- sumtechguy 4y agoThe 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 4y ago>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 4y agoI 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.
- brucehoult 4y ago6502 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.
- rep_lodsb 4y agoIt 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.
- scaramanga 4y agoYep, and the presenter is great, and loads of interesting tidbits in there for those interested in 8bit computer architecture.
- mzs 4y agoWhat a click-bait vid, here's a PDF: http://www.z80.info/zip/z80-documented.pdf http://www.z80.info/zip/z80-documented.pdf
- the_arcadian 4y agoThanks!
- nottorp 4y agoOh ty, I knew why I didn't click on the video and just skipped to the comments.
- INTPenis 4y agoHe mentions this in the vid, a few minutes in.
- musicale 4y ago> He mentions this in the vid, a few minutes in. transcript >>> video
- Quequau 4y agoSo 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.
- audunw 4y ago> What a click-bait vid, here's a PDF: http://www.z80.info/zip/z80-documented.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.
- japanuspus 4y agoHave 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.
- mfuzzey 4y agoI 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)
- kazinator 4y ago> 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 4y agoThough 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.
- KingOfCoders 4y agoMe too, my first real assembler program was a hex editor with RSX |hex on a CPC464.
- zimpenfish 4y ago
- djmips 4y agoInteresting ideas but presented in such a 2020s style haha. Oh well it was still a fun watch.
- mdp2021 4y agoAgain 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 4y agoDid the video presenter say that? It is a verbatim quote attributable to Sean Young. p7 http://www.z80.info/zip/z80-documented.pdf http://www.z80.info/zip/z80-documented.pdf
- Aissen 4y agoIf 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/ 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 4y ago> There are even more secrets that were discovered in recent years that aren't in the talk. Could you give details?
- Aissen 4y agoDespite 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 https://github.com/redcode/Z80/blob/master/THANKS (has many links to the various reverse engineered parts).
- flohofwoe 4y agoOk... 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
- mid-kid 4y agoTurns out it worked well. This video got 1000x the views his channel usually gets.
- ChrisRR 4y agoIt'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 4y agoIt 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.
- hvdijk 4y agoAnd 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.
- idonotknowwhy 4y agoFirefox with Ublock Origin and SponsorBlock
- Jolter 4y ago
- visarga 4y agoThose were the days when hardware was still "understandable" for mere humans.
- jbverschoor 4y agoNice to see an msx :)
- nuc1e0n 4y agoQuite a misleading clickbaity video. There was additional hardware added that provides memory protection. It's been done before. Nice description though.
- ddevault 4y agoCorrection: 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 4y agoIndeed. There's also UZI - a v7 UNIX for Z80.
- blueflow 4y agoTitle 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 4y agoYeah, 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 4y agoPeople 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.
- authpor 4y agoimagine how long it'll take to dig out whatever any modern intel has?
- sixstringtheory 4y agoCan’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 4y agoIt 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.
- gpvos 4y agoIf 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.
- elesbao 4y agoIt'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.
- richardfey 4y agoTitle 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.
- deltasepsilon 4y agoThe 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.
- gumby 4y agoBTW 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.
- m0d0nne11 4y ago
- sedatk 4y ago"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 4y agoI foolishly came here thinking there were undocumented instructions to be found. Not so! Off with their heads all those who write click bait articles.