A deep dive into implementing LZ4 decompression in assembly language across four legacy CPUs: the Zilog Z80, Intel 8080, Intel 8086, and MOS Technology 6502. The author walks through how the LZ4 block format works, the custom null-termination trick used instead of frame data, and then shows side-by-side assembly implementations for each CPU. The Z80 serves as the baseline thanks to its LDIR block-copy instruction and convenient register layout. The 8080 is nearly identical but requires manual copy loops and extra 8-bit arithmetic. The 8086 benefits from string instructions (LODSB, STOSB, REP MOVSB) and extra registers, eliminating most stack juggling. The 6502 diverges most significantly due to its lack of pointer registers, requiring zero-page scratch space, a custom LDIR helper function, and a different loop structure to handle 16-bit counters correctly.

35m read timeFrom bumbershootsoft.wordpress.com
Post cover image
Table of contents
A Review of LZ4LZ4 On Our Various ChipsDesigning the APIImplementation on the Z80 and Intel ChipsImplementation on the 6502Catching Our Breath
100 Impressions