An invalid 68030 instruction accidentally allowed the Mac Classic II to boot
The Macintosh Classic II boot issue was caused by an invalid ROM instruction, allowing the Motorola MC68030 CPU to boot despite a bus error linked to the BoxFlag variable misalignment.
Read original articleThe Macintosh Classic II experienced an unexpected booting issue due to an invalid instruction in its ROM. This problem arose from a bug in the ROM that should have prevented the machine from booting, but instead, the Motorola MC68030 CPU executed an undefined instruction, allowing it to boot successfully. The author, Doug Brown, explored this anomaly while using MAME, an emulator for 68000-based Mac models. He discovered that the Classic II failed to boot in 32-bit addressing mode, resulting in a "Sad Mac" error. Through debugging, he traced the issue to a bus error caused by an attempt to access an invalid memory address. The root of the problem was linked to the handling of the BoxFlag variable, which incorrectly pointed to an invalid instruction due to a jump in the code that was not intended for the Classic II. This misalignment in the code execution led to the CPU attempting to write to an invalid address, ultimately causing the boot failure. The investigation highlighted the complexities of the Classic II's architecture and the quirks of its ROM, revealing how a mistake in the design inadvertently allowed the machine to boot under certain conditions.
- The Macintosh Classic II boot issue stemmed from an invalid instruction in its ROM.
- The Motorola MC68030 CPU executed an undefined instruction, allowing the machine to boot.
- The failure to boot in 32-bit mode resulted in a "Sad Mac" error.
- The problem was traced to a bus error caused by accessing an invalid memory address.
- The misalignment in code execution was due to an incorrect handling of the BoxFlag variable.
Related
That Time Apple Told Apple III Customers to Drop Their Computers
Apple faced design flaws with the Apple III in the 1980s, causing overheating and chip dislodgment. Support engineers advised dropping the computer to reset circuits. Despite modifications, the reputation damage led to discontinuation in 1984.
The Apple IIGS Megahertz Myth – Userlandia
The Apple IIGS, launched in 1986 with a 2.8MHz CPU, faced development challenges and limitations due to technical issues, not intentional speed restrictions to protect the Macintosh.
The capacitor that Apple soldered incorrectly at the factory
Doug Brown's analysis reveals a manufacturing error in Apple's Macintosh LC III involving capacitor C22, which was incorrectly installed, posing risks for future repairs and emphasizing the need for proper documentation.
The upside-down capacitor in mid-'90s Macs, proven and documented by hobbyists
A backward installation of a capacitor on mid-‘90s Macintosh LC III models due to a printing error may cause restoration issues. Hobbyists are advised to follow reverse-engineered schematics for repairs.
Emulating 6502
The author discusses a shift to retrocomputing, focusing on the MOS 6502 CPU, its architecture, and building gaming hardware, while developing an emulator tested with the Apple I computer.
- There is speculation about the nature of the undocumented MC68030 instruction, with some suggesting it may be an illegal instruction rather than a hidden feature.
- Users share experiences with the challenges of emulating the CAS instruction and other undocumented behaviors in various systems.
- Several commenters express nostalgia for the 68000 series processors and their significance in computing history.
- Concerns are raised about whether the undocumented instruction was a form of copy protection or a flaw in the system.
- There is a general consensus that undocumented instructions are common in CPUs, and the need for accurate emulation is emphasized.
Rather than a "real" instruction that CPU designers consciously created and which was meant to do something useful but wasn't documented, it could just be that this is an illegal instruction and the logic in the CPU is doing whatever it happens to do when given don't-care inputs. (Maybe this is what the author meant, and I'm just catching up.)
Normally the CPU would detect illegal instructions and cause an exception. This would mean there are certain situations where it doesn't.
I found a manual at https://www.nxp.com/docs/en/reference-manual/MC68030UM.pdf. On page 8-9 of the manual (which is page 276 in the PDF file), it says:
> An illegal instruction is an instruction that contains any bit pattern in its first word that does not correspond to the bit pattern of the first word of a valid MC68030 instruction or is a MOVEC instruction with an undefined register specification field in the first extension word.
Note "in its first word". According to the write-up, the instruction is 3 words long. The first word is normal, and the weird bits occur in the second word. So quite possibly the 68030 doesn't validate this second word, just plows forward with the logic that implements the CAS instruction, and lets whatever happens happen.
(Great write-up and amazing dedication, by the way!)
Incidentally, I remember another old "bug" in King of Fighters that "incorrectly" checked the carry flag of the SBCD instruction, which it used to decrement the round timer and end the current round. Completely undocumented of course, but if you don't emulate the arithmetic status flags when doing binary coded decimal operations, the round timer in KOF will just keep on going forever, cycling from 00 to 99 :P
SNK were really the gods of the 68000 chip.
http://ref.x86asm.net/geek.html
https://gist.github.com/seanjensengrey/f971c20d05d4d0efc0781...
We don’t really know the exact details of what this instruction does. With some limited testing, I believe I’ve observed that the resulting value of A1 depends on the original A1 value, the value of A7, and the program counter. But I’m not sure. Maybe someone can make a program that tries out a bunch of different register values and memory contents, and attempt to deduce what exactly the instruction does so that it can be emulated accurately. Until someone decides that it’s worth trying to figure out, MAME is patching this bug out of the ROM in order to allow the Classic II to boot.
IMHO this is definitely worth figuring out for accurate emulation. I'm not familiar with 68k but the bits in the instruction offer a good clue - my theory is that bits 5:3 of the 2nd word seem like another mode field, and instead of selecting one of the Dn registers via mode 000, 101 is selecting (d16, An) again and the Dc field, containing 001, is being interpreted as A1.
Amazing work. Thanks for the exposition.
(I miss the 68000 line. Those were such great chips...)
I think that to be a perfect article, they should wrote :
By the magic of buying a Classic II and hacking the ROM...
Another possibility is that is a special institution in the chip specifically for Apple that again was used as a copy write detection or protection scheme.
The system booted in spite of that undocumented instruction. When things work, you don't go looking for undocumented things that are contributing to the working state.
Millions of C programs work accidentally, in spite of undefined behavior. Nothing gets investigated until a compiler change triggers something.
Related
That Time Apple Told Apple III Customers to Drop Their Computers
Apple faced design flaws with the Apple III in the 1980s, causing overheating and chip dislodgment. Support engineers advised dropping the computer to reset circuits. Despite modifications, the reputation damage led to discontinuation in 1984.
The Apple IIGS Megahertz Myth – Userlandia
The Apple IIGS, launched in 1986 with a 2.8MHz CPU, faced development challenges and limitations due to technical issues, not intentional speed restrictions to protect the Macintosh.
The capacitor that Apple soldered incorrectly at the factory
Doug Brown's analysis reveals a manufacturing error in Apple's Macintosh LC III involving capacitor C22, which was incorrectly installed, posing risks for future repairs and emphasizing the need for proper documentation.
The upside-down capacitor in mid-'90s Macs, proven and documented by hobbyists
A backward installation of a capacitor on mid-‘90s Macintosh LC III models due to a printing error may cause restoration issues. Hobbyists are advised to follow reverse-engineered schematics for repairs.
Emulating 6502
The author discusses a shift to retrocomputing, focusing on the MOS 6502 CPU, its architecture, and building gaming hardware, while developing an emulator tested with the Apple I computer.