News for hackers. Stuff that matters.
Re:The art of creating very tiny programs for the 80x86 fami... by kragen on Friday September 14, 2018 @07:54PM (#17992028)
My only real effort in this direction was a 64-byte MS-DOS .COM file that draws colored circles on the screen:

http://canonical.org/~kragen/sw/dev3/morecircles.s

    00000000: b013 cd10 c42f 89e8 f72e 0000 89c5 31c6  ...../........1.
    00000010: 31d2 89c1 31db 88f7 89df c1fb 0201 df89  1...1...........
    00000020: c3c1 fb08 01df 01f7 5b26 883d 4353 89c3  ........[&.=CS..
    00000030: c1fb 0401 da89 d3c1 fb04 29d8 e2d6 ebc6  ..........).....
There's a lot to learn from tiny demos like the ones (I didn't write) dissected in http://canonical.org/~kragen/demo.

Oh, I also wrote a Linux HTTP server in assembly with an executable under 2000 bytes: http://canonical.org/~kragen/sw/dev3/server.s with some explanation in http://canonical.org/~kragen/sw/dev3/httpdito-readme. I use it occasionally for testing stuff, since it's slightly less hassle than using python -m SimpleHTTPServer. Previous HN discussion at https://news.ycombinator.com/item?id=6908064

The demoscene diskmag "hugi" did a series of sizecoding competitions in 1998–2009, with truly astounding results. http://www.hugi.scene.org/compo/hcompo.htm Highlights include a working textmode Pong game in 142 bytes, a Brainfuck interpreter in 98 bytes, a Snake game in 48 bytes, and a perfect Tic-Tac-Toe player in 213 bytes.

The 8086 is a reasonable design for this kind of nonsense, since it's full of shortcuts and special cases that you can take advantage of. IBNIZ is an architecture really optimized for it, though: http://pelulamu.net/ibniz/ and in practice I often find that I can get things smaller with ARM Thumb-2 code than with the 8086. For example, https://github.com/kragen/dumpulse is about 350 bytes of code on most architectures, but just over 200 bytes on a big-endian ARM.

There are no comments on this comment yet.