How to shorten the Z80 emulator code on PC

ZXNet echo conference «zxnet.pc»

From Vladimir Kladov To All 14 January 2006

Hello, Vladimir Kladov The first stage is completed: there is a bytecode emulator, P-code generation and compilation P-code to bytecode is there. Reduced the size of the exe file by 100K (compressed decreased by 21K in total. Not much, but also the source code for which the P-code is generated automatic, also not very much). The bytecode turned out to be 2 times more compact the same machine. The slowdown in speed is indistinguishable by eye (especially since dialog initialization code is replaced). Next move I'll try compiler Pascal->P-code, and then it will be possible to compress all the Pascal code that does not require high speed.

From Alexander Makeev To All 1 February 2006

Hello, Vladimir Kladov Vla> The first stage is completed: there is a bytecode emulator, P-code generation and Vla> compilation of P-code into bytecode exists. Reduced the file size by 100K Vla> (compressed decreased by 21K in total. Not much, but also the source code for Vla> of which the P-code is generated automatically is also not very much). Vla> The byte code turned out to be 2 times more compact than the same machine code. Vla> The slowdown in speed is indistinguishable by eye (especially since the code is replaced Vla> dialog initialization). Next step I'll try to make a compiler Vla> Pascal->P-code, and then it will be possible to compress all the Pascal code that Vla> does not require high performance. The idea is certainly interesting, if I understand correctly you want to do JIT a pseudo-language compiler that describes the logic for processing Z80 instructions, right? True, I have already fallen in love with .net, where the approach with JIT compilation is not so simple and may result in even more code... :) however, pure code for a complete Z80 emulator, including the IL disassembler, it takes me 73 kb (13.5 kb in the archive), which is my opinion is not so much... but I still want to rewrite it in some formmicrocode, where basic operations are based on Z80 machine cycles... maybe something will happen...

From Vladimir Kladov To All 1 February 2006

Hello, Alexander Makeev no, I gave up on this idea. Instead I made a bytecode emulator "in general". More useful for reducing the size of not only this one program emulator, but also a bunch of others. .net is when the software already (almost) exists, but the hardware that can accept it is still still expensive. So I'm in no rush. In addition, the user must set this runtime libraries from .net, but does he need it?

From Vladimir Kladov To All 1 February 2006

Hello, Vladimir Kladov and about JIT: as I understand it, this is not at all the same, because my bytecode emulated rather than translated before execution. I made my JIT even earlier in the emulator, and just to increase speed, and this is just built into emulator macro-compiler PC-Asm, which compiles into memory depending on options, and I get the fastest code to emulate the Z80 in all combinations of modes and for graphics output. And without any (almost if-s inside, because the ifs are processed by the compiler. This just increased somewhat size, but it made it possible to support many more modes.