Page 6 of 6

Re: Compressing during the compilation process

Posted: Sat May 21, 2016 10:08 pm
by barrym95838
Bregalad wrote:
... Now everything is pretty much completed BUT my instruction jump stable still needs to be 2 bytes wide because the critical part (between .block "interpreter_critical" and .endb in the source code) is still 277 bytes long. It needs to reach 255 bytes or less ...
Could you pick one or two instructions, and just put a three-byte "spring-board" jump for each of their handlers inside the critical section, with the handlers themselves placed elsewhere? Getting that table shrunk down should easily pay for that tiny penalty.

Mike B.

Re: Compressing during the compilation process

Posted: Sun May 22, 2016 12:27 pm
by Bregalad
Yeah, pretty much what I had in mind, but it's hard to describe (in english). Also, if I take the longest instructions out, and replace them with JMP instructions, it'll pay off better as it'll reduce the size of the "critical" section down more, so I'll have to waste less JMP instructions on that. (Hopefully just 2-3).

Re: Compressing during the compilation process

Posted: Mon May 23, 2016 10:01 pm
by Bregalad
So I updated the thing again (links are the same). Now the instruction set is considered definite, there is two extra instructions added in at last minute, which prove to be EXTREMELY useful. They are equivalent to LDA and STA zero page, but are called LDZP and STZP. So finally it's possible to use zero-page fixed locations without reserving a register for this purpose and waste instructions to load this register to point to the desired operation, which was the main cause of code size bloat for this bytecode.

The interpreter is changed a lot. Code stored in VROM is implemented and confirmed to work (a few fixes were rerquired). I'm back to the old way of NOT doing a "jsr Dispatch", because I counted that this saved barely more bytes than it wasted.

The jump table is finally made one byte, the critical section's size is reduced to 254 (!) bytes, and only one instruction stays outside of this section and is replaced with a "JMP" instruction to it, to compensate the jump table not being able to jump outside the critical section.

Not only that, but the critical section just happens to start exactly 257 bytes ahead the start of the interpreter, so everything is pretty much set in stone... add or remove any single byte and the whole thing could fail.

The documentation is updated as well.

Re: Compressing during the compilation process

Posted: Tue Jan 19, 2021 7:38 am
by barrym95838
[bump] I stumbled across this while I was poking around. I must say that I thoroughly enjoyed revisiting this thread from start to finish, and I wanted to ask Bregalad if any progress or updates can be offered regarding the custom VM or the game that inspired its conception. [/bump]