r/programming
•
u/double-happiness
•
Oct 04 '26
•
1
"8-pinski" - EIGHT(!) bytes intro for MSDOS
https://www.youtube.com/watch?v=9A-XJjnU5Oo
147
Upvotes
77
u/vytah Oct 04 '26 •
So the code is this:
and the binary code will be C5 30 04 AD E6 61 EB F9 (loaded at 0100h in the code segment)
This is a COM file, they are loaded into a new code segment at address 0100h (preceding 256 bytes are used for various DOS API stuff that is not relevant here), and have their data segment set equal to their code segment for semi-compatibility with CP/M.
Initial values of CPU registers on most versions of DOS are AX=0000h BX=0000h SI=0100h (and CS=DS), so after the first 2 instructions they'll be AX=00ADh, SI=30C5h, DS = AD04h. (The
ldsreads the first 4 bytes of the program into SI and DS registers respectively.) From now on, the data segment (i.e. the area where most memory read and write instructions operate) starts at AD040h, which is within EGA/VGA video memory. The exact range of the segment is from AD040h to BD03Fh, which overlaps with the text mode, which starts at B8000h. Each of the 2000 entries of the text mode buffer is a 2-byte value, containing a character and its attributes, for a total of 4000 bytes – even bytes contain characters, odd bytes contain attributes.The final short jump is misaligned, so after the first jump the following instructions will execute:
The
xorwill toggle the byte the SI points to. Theloadswinstruction will load two bytes into AX pointed to by SI and increment SI by two – so SI will stay odd. So this code will repeatedly read an byte from the video memory and xor it into the byte two addresses over. This kind of process often results in cellular automaton-like behaviour. Of course it will loop across the entire 64K segment, not just the text screen area, but across the text area, it'll skip from one attribute byte to the next, producing colours.And finally,
out 61h, alwill keep writing various values to the IO port 61h, which is wired to multiple things (and differently in different PC types), but most importantly for this demo, to the builtin PC speaker.17
u/JuanPabloVassermiler Oct 04 '26 •
Fun fact: the name is a reference to the Sierpiński triangle, which is a basic fractal featured in this intro.
10
u/abraxasnl Oct 04 '26 •
It even has audio??
8
u/Celos Oct 05 '26
My cat, who loves lounging on my closed/docked laptop, is now highly disturbed.
5
u/ShinyHappyREM Oct 04 '26
https://www.pouet.net/prod.php?which=107055
9
u/stgiga Oct 05 '26
This is ingenious, as someone who made a 3045-byte JS demo. I certainly couldn't do 8 bytes of DOS code, but I can say from experience that the demoscene is talented and that it's challenging work.
3
u/killerstorm Oct 05 '26
Farbrausch made a 5-byte intro "fuenf", but it outputs just some "random" memory contents. So more like performance art than art, but still kinda cool. The code is:
1
u/Ok_Conference_5875 Oct 21 '26
sounds like salinewin.exe