Intel 8080 Emulation on an ATtiny85: A Retro-Computing Feat

les the state of the CS pin. This transition alerts the Teensy 4.0 that a new 16-bit address is being loaded, saving valuable clock cycles.

(306 words)

*Trimmed Section 4:*

Software Extreme: Inline C and a 128-Byte Cache

Even with an optimized physical bus, squeezing a complete Intel 8080 instruction decoder and register file into the ATtiny85’s 8KB of flash required masterful coding. The emulator’s C codebase is a masterclass in modern bare-metal embedded programming. To minimize both execution time and compiled binary size, Fried avoided standard C programming practices in favor of extreme optimization.

Standard C compilers generate structured assembly code that relies heavily on function calls. Every time a function is called, the microcontroller must push the current program counter, register states, and local variables onto the stack, perform a branch, execute the function, and then pop the stack to return. This overhead consumes precious CPU clock cycles and wastes valuable RAM. To circumvent this, Fried wrote the emulation code using extensive inline code structures and minimized nested calls and returns. By keeping the execution path linear and compiling operations inline, the emulator bypasses stack-frame creation entirely, keeping the ATtiny85’s stack minuscule and saving precious execution cycles

This entry was posted in Internet Curiosities, Resources & Culture and tagged , , , . Bookmark the permalink.