Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Packer vs Code VM vs Code Generator
2016-08-13 16:38
oziphantom

Registered: Oct 2014
Posts: 478
Packer vs Code VM vs Code Generator

Has anybody experimented with/know of code VMs or Generators.
Just thinking to get code size down they might perform better than exomiser et al.

I know of Sweet16 by Woz any others?
 
... 80 posts hidden. Click here to view all posts....
 
2016-08-16 13:42
ChristopherJam

Registered: Aug 2004
Posts: 1378
I wonder if IO register setting code is common enough to benefit from a pseudo-op that moves an eight bit immediate into $Dxxx, where xxx has a number of implicit zeros - or possibly even a series of N such operations…
2016-08-16 14:58
oziphantom

Registered: Oct 2014
Posts: 478
Well you can get
STA SSRRRRRR Value

where SS is
00 VIC
01 SID
10 CIA 1
11 CIA 2

And R is the register

allowing you to pack any IO address into a byte. In a game context I don't think that will save you much. Typically the screen mode and charset registers are set and forget. The multiplexer will deal with the sprites usually in one function and then you have a few D012,9,A for the IRQs.
2016-08-16 15:51
oziphantom

Registered: Oct 2014
Posts: 478
I've been working under the impression that packing all the data near each other and the code together would help with compression.
so
CODE
DATA

is this misguided do you think?
2016-08-16 16:44
ChristopherJam

Registered: Aug 2004
Posts: 1378
Grouping is generally good.

Most crunchers encode "copy recent substring" with fewer bits the more recent the substring, so grouping all your code seperate to your data means the cruncher doesn't have to look as far to find prior examples, hence can use fewer bits for the copy offset.
2016-08-16 17:15
Krill

Registered: Apr 2002
Posts: 2847
Quoting oziphantom
it would actually consume more memory than taking the whole lot as a custom stream
The two separate streams take exactly the same amount of memory as the conventional 6502 counterpart. Your example would translate to
$a9,$8d,$a9,$8d,$a9,$8d
$7f,$15,$d0,$00,$84,$27,$d0,$84,$e7,$43
and it's plain to see that the op-codes would compress well, and data arguments too at some later point when using the same literals and addresses many times.
Of course, these two chunks will have to be re-combined after decompression, which adds an initial cost of about $0180 or so bytes (which in my case amortised for the 4K, so overall i saved a few pages).

But please, do look at the Artefacts source code at some point to see what i did.
2016-08-16 22:25
soci

Registered: Sep 2003
Posts: 473
Storing opcode lengths in a 64 byte bit-array, what a waste of space ;) But the use of (,x) to switch streams is smart.
2016-08-17 05:32
Krill

Registered: Apr 2002
Posts: 2847
:D One of the few occasions where (ZP,X) actually comes in handy. Which is mostly whenever you have a number of "buckets" to select from AND need to push or pull stuff to and fro.

As for op-code lengths, there didn't seem to be a nice enough pattern to store that more efficiently. Speak about non-orthogonal instruction set. So i went for a solution that somehow suited exomizer best. :)
2016-08-17 06:28
soci

Registered: Sep 2003
Posts: 473
From the processor's viewpoint the least significant 5 bits of opcode fully determines the length of the addressing mode.

Still it seems that BRK/JSR/RTI/RTS are exceptions. But that's only because the modification of PC is covering up that they're actually 2 bytes long.

I think if you reduce the table size the result will be shorter even with the special handling added in for these opcodes.
2016-08-17 07:23
JackAsser

Registered: Jun 2002
Posts: 1989
Quote: From the processor's viewpoint the least significant 5 bits of opcode fully determines the length of the addressing mode.

Still it seems that BRK/JSR/RTI/RTS are exceptions. But that's only because the modification of PC is covering up that they're actually 2 bytes long.

I think if you reduce the table size the result will be shorter even with the special handling added in for these opcodes.


It would be very slow, but couldn't you depack that stream without a table! :) Imagine placing a BRK after the opcode in the stream then use the IRQ to determine the opcode length by checking the pushed PC on the stack! Sneaky!
2016-08-17 07:53
oziphantom

Registered: Oct 2014
Posts: 478
Quoting Krill
Quoting oziphantom
it would actually consume more memory than taking the whole lot as a custom stream
The two separate streams take exactly the same amount of memory as the conventional 6502 counterpart. Your example would translate to
$a9,$8d,$a9,$8d,$a9,$8d
$7f,$15,$d0,$00,$84,$27,$d0,$84,$e7,$43
and it's plain to see that the op-codes would compress well, and data arguments too at some later point when using the same literals and addresses many times.
Of course, these two chunks will have to be re-combined after decompression, which adds an initial cost of about $0180 or so bytes (which in my case amortised for the 4K, so overall i saved a few pages).

But please, do look at the Artefacts source code at some point to see what i did.


My line is referencing a normal packer like exo, not your split system.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Dymo/G★P
zscs
Mike
eryngi
X-Raffi/X-Rated
Apollyon/ALD
Clayboy
hedning/G★P
Guests online: 138
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.3)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Webmasters
1 Slaygon  (9.7)
2 Perff  (9.6)
3 Morpheus  (9.5)
4 Sabbi  (9.5)
5 CreaMD  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.041 sec.