News for hackers. Stuff that matters.
Re:Show HN: Game of Life in 32 bytes of assembler by jnurmine on Thursday April 30, 2020 @06:39PM (#23037065)
The modbyte trick is clever.

The writeup sure brought back memories.

Over 20 years ago I made a 2-player graphical worm game for DOS. I still have it in a zip. It is 123 bytes long and back then I couldn't squeeze more out of it.

After reading that writeup I feel like there's so much bloat in that 123 bytes!

Re:Show HN: Game of Life in 32 bytes of assembler by adhoc32 on Thursday April 30, 2020 @08:08PM (#23037756)
I did the same thing! The year was 1997. There was some kind of online coding competition back then if I recall correctly. Mine is larger (256 bytes) but it has a nice background image (a mandelbrot fractal). Here is the binary:

    M8CO4LATzRC7JABmZP83ZMcHvwFkjE8CaACgB7AI+jPJSfOqv0ABscaqUL3C/jPAM9tXvxAAZg+/
    8w+v2GaYZvfoZovQZg+v9mYrxmbB+AcrxS0AAcH7BivZg8NkZgPWZsHqEHUDT3XNi8cEEF+qRXW8
    WKris/u/6Hu+2HyL6rv///7EsQK62gPsqAh1++yoCHT74vGwCSaAPQ+qdoBP/sAmgDwPJogED4Zy
    /wP9A/P+zHXOZmSPBiQAsAPNEMPkYIrgPC11A71AATwRdQO9wP48HnUDvf//PCB1A70BADxQdQO7
    QAE8SHUDu8D+PEt1A7v//zxNdQO7AQCwIOYgzw==
Re:Show HN: Game of Life in 32 bytes of assembler by gregschlom on Thursday April 30, 2020 @08:17PM (#23037822)
Running on twt86.com:

http://twt86.co/?c=M8CO4LATzRC7JABmZP83ZMcHvwFkjE8CaACgB7AI%...

I see the mandelbrot background but then it exits

Re:Show HN: Game of Life in 32 bytes of assembler by adhoc32 on Thursday April 30, 2020 @08:25PM (#23037876)
Not sure why, just tested it in native dosbox and it works.

edit: try pressing any arrow key when the fractal is drawing.

    ~controls :

    Player 1        Player 2 (or arrows)

       W               8
     A + D           4 + 6
       X               2
Re:Show HN: Game of Life in 32 bytes of assembler by mycall on Thursday April 30, 2020 @10:35PM (#23038550)
This is so interesting, VM using a URL for the code.
Re:Show HN: Game of Life in 32 bytes of assembler by gregschlom on Friday May 01, 2020 @12:49AM (#23039235)
A bit of hair splitting, but technically it's an emulator, not a VM, since it's just simulating the CPU using javascript in your browser.
Re:Show HN: Game of Life in 32 bytes of assembler by mycall on Friday May 01, 2020 @01:12AM (#23039320)
It is a base64 encoded highly optimized x86 assembly in DOSBox emulator inside a Javascript VM Chrome browser inside my Windows 10 Sandbox Nested Hyper-V VM inside VMware Workstation inside my Windows 10 machine.
Re:Show HN: Game of Life in 32 bytes of assembler by SomeoneFromCA on Friday May 01, 2020 @08:28AM (#23041316)
Yeah, and then CPU which translates x86 code into uOPs.
Re:Show HN: Game of Life in 32 bytes of assembler by scubbo on Sunday May 03, 2020 @01:29AM (#23057057)
There's always a relevant xkcd: https://xkcd.com/676/
Re:Show HN: Game of Life in 32 bytes of assembler by anonexpat on Friday May 01, 2020 @01:32AM (#23039394)
It’s turtles all the way down.
Re:Show HN: Game of Life in 32 bytes of assembler by monocasa on Friday May 01, 2020 @01:50AM (#23039456)
Emulators are VMs too.
Re:Show HN: Game of Life in 32 bytes of assembler by eru on Friday May 01, 2020 @04:39AM (#23040207)
Well, depends a bit on what definitions you use.

For example there's VM in the sense of JVM. But there's also in VM in the sense of Xen (VM) vs Docker (not a VM).

And probably a few more slightly different usages.

Re:Show HN: Game of Life in 32 bytes of assembler by monocasa on Friday May 01, 2020 @09:44AM (#23041903)
Those are both VMs in the same sense. A VM creates an abstract, indirect implementation of a computing system. Sometimes that's with a lot of hardware offload as in Xen or picojava. Sometimes that's with a JIT as in HotSpot, orginal VMWare, or Transmeta. Sometimes that's just with an interpreter like the original JVM or Dosbox.

They're all virtual machines whether they're running code originally meant for execution on hardware or not.

Re:Show HN: Game of Life in 32 bytes of assembler by eru on Monday May 04, 2020 @03:51AM (#23065523)
That's a pretty wide definition. One that also encompasses any 'bare metal' OS, because they use microcode these days.
Re:Show HN: Game of Life in 32 bytes of assembler by mfabbri77 on Friday May 01, 2020 @02:05AM (#23039498)
10 years later, I wrote a fractal zoomer in asm, it was 399bytes, with a nice color palette.

https://www.pouet.net/prod.php?which=24447

Re:Show HN: Game of Life in 32 bytes of assembler by Frondo on Friday May 01, 2020 @12:23AM (#23039108)
I remember that! it was on rec.games.programmer, wasn't it?
Re:Show HN: Game of Life in 32 bytes of assembler by adhoc32 on Friday May 01, 2020 @01:07PM (#23044183)
It was usenet for sure, probably the rec.games.programmer.
Re:Show HN: Game of Life in 32 bytes of assembler by zorbash on Thursday April 30, 2020 @06:45PM (#23037112)
Please make it available online!
Re:Show HN: Game of Life in 32 bytes of assembler by jnurmine on Thursday April 30, 2020 @06:49PM (#23037153)
I can make it available here :)

Here's the binary:

  uBMAzRC6AKCOwovyM/+xAYvp+rraA+yoCHX77KgIdPsmgDWRdDCQkORgityyBDqHawF0C5CQ/sP+
  ynXy6wmQKtzQ44uPcwED+YD0BIf+h+k793W/tAyA9ATA7AKK1IDCQbgDAM0QtALNIcMeIBEfJCYX
  Jf//AQDA/kAB
Copy that to a file and then: "base64 -d blah.txt > worms.com"

Make sure there are no spaces in the beginning of the lines.

This is from the original document:

  "This is a version of the worm game for two players.
  Game objective is to stay alive longer than the other worm!
  You die if you eat yourself, ie. you are going RIGHT and you press LEFT.
  
  Move the worm with the following keys:
     PLAYER A:  (topmost worm)
        W
      A   D
        S
  
     PLAYER B:  (lower worm)
        I
      J   L
        K
  
  Winner is indicated by player letter, "A" or "B".
  An even game is indicated by a "C". An even game means that the worms
  ate each others heads, and nobody won."
Edit: correct base64 formatting
Re:Show HN: Game of Life in 32 bytes of assembler by gregschlom on Thursday April 30, 2020 @08:18PM (#23037828)
Re:Show HN: Game of Life in 32 bytes of assembler by anthk on Thursday April 30, 2020 @10:48PM (#23038605)
cool. For OpenBSD:

     cat worms.uue
begin-base64 644 worms.com uBMAzRC6AKCOwovyM/+xAYvp+rraA+yoCHX77KgIdPsmgDWRdDCQkORgityyBDqHawF0C5CQ/sP+ ynXy6wmQKtzQ44uPcwED+YD0BIf+h+k793W/tAyA9ATA7AKK1IDCQbgDAM0QtALNIcMeIBEfJCYX Jf//AQDA/kAB

        b64decode -o worms.com worms.uue