News for hackers. Stuff that matters.
Re:1K ZX Chess by antirez on Tuesday September 04, 2018 @11:50AM (#17909865)
> It was the smallest implementation of chess on any computer until its record was broken in January 2015 by the PC-compatible BootChess.[4]

It would be interesting to compare x86 and Z80 code density, that is, how much you can do per bit of machine code.

Re:1K ZX Chess by flohofwoe on Tuesday September 04, 2018 @01:07PM (#17910679)
Not a 'scientific' comparison, but handwritten 8-bit machine code compresses much less than x86/64 machine code (using gzip --best):

- a compiled C executable for x86/64 compresses to about 38% of its original size (199 KB down to 77 KB)

- a WASM blob of the same code compresses to about 32% (171 KB down to 56 KByte)

In comparison some 8-bit ROMs:

- ZX Spectrum 128 ROM (Z80): 16384 bytes compresses to 12189 (74.3%)

- C64 Kernel ROM (6502): 8192 bytes compresses to 6735 (82.2%)

So 8-bit code seems to be a lot 'denser' than today's machine code, and 6502 is denser than Z80 :)

Re:1K ZX Chess by schoen on Tuesday September 04, 2018 @05:54PM (#17913153)
That's interesting! Do you think this is because 64-bit code simply doesn't use a lot of its instruction set space (where more opcodes and instruction modes and variants are undefined and therefore not routinely used in executables), or because some of the people hand-writing 8-bit assembly actively use more opcodes than a typical compiler would, or some other factors?

Or are there are a lot of pointers in 64-bit code that contain a huge number of zeroes? :-)

Re:1K ZX Chess by flohofwoe on Wednesday September 05, 2018 @01:21PM (#17920056)
I guess it's a combination of compiled vs handwritten code (maybe certain patterns show up more often in compiled code, while handwritten 8-bit code tries hard to remove any redundancies because of the limited available space), and bigger data types (especially 64-bit pointers).
Re:1K ZX Chess by antirez on Tuesday September 04, 2018 @07:35PM (#17913800)
Very interesting! Another thing to consider however is how much work each instruction can do. In that regard x86 may have a big edge.
Re:1K ZX Chess by kayamon on Tuesday September 04, 2018 @03:39PM (#17912138)
x86 was originally based on Z80 so it should be extremely similar (for 16-bit code at least).