Get the latest tech news

Dissecting M8trix


published on 2024-07-31 by dzwdz m8trix by HellMood is one of my favorite demos. It packs a pretty cool Matrix-style effect in only 8 bytes: The author even provided the source with some comments: org 100h S: les bx,[si] ; sets ES to the screen, assume si = 0x100 ; 0x101 is SBB AL,9F and changes the char ; without CR flag, there would be ; no animation ;) lahf ; gets 0x02 (green) in the first run ; afterwards, it is not called again ; because of alignment ;) stosw ; print the green char ...

This instruction will be run over and over again, with DI taking on every even value and overflowing every once in a while, overwriting everything in ES – including the text buffer – over and over again. The loop runs for 10000/2=8000 iterations before DI repeats, and 8000 is divisible by 100, so each pass would have the exact same AL values for each character. The character cycle is apparently different because the carry flag gets reused between odd and even columns, but the period still works out to be 85 – which I find interesting but I don’t really feel like researching why that is.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of M8trix

M8trix

Photo of Dissecting M8trix

Dissecting M8trix