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: 490
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-17 08:17
Krill

Registered: Apr 2002
Posts: 2980
Ah, sorry, didn't read thoroughly enough.

But i guess the compressor itself should be oblivious to the semantic details of the blob you serve it. It should not know about op-codes/arguments/data separation and just crunch everything as well as it can.

It should be served data it can compress well, and this is where any special coding takes place before final compression and after initial decompression.

In principle this is akin to Burrows-Wheeler transform/move-to-front, which makes it much better compressible.
2016-08-17 08:19
Krill

Registered: Apr 2002
Posts: 2980
Quoting JackAsser
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!
Excellent idea! However, i have a hunch that the code for all that would, in the end, still consume more compressed data than the rather straightforward approach with a table, which is probably better to compress. Not to speak of execution hazards with funny op-codes in an environment that doesn't really allow for sandboxing. :)
2016-08-17 11:32
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Quoting JackAsser
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!
Excellent idea! However, i have a hunch that the code for all that would, in the end, still consume more compressed data than the rather straightforward approach with a table, which is probably better to compress. Not to speak of execution hazards with funny op-codes in an environment that doesn't really allow for sandboxing. :)


Indeed, it's a bit tricky, but possible. For instance RTI/RTS handles the return address a bit different (+1 vs -1). But I guess having argument $02,$02 and then prefill the stack return address properly should be able to handle most degenerate cases. But yeah, it's a big chance it will compress worse in total tbh.
2016-08-17 11:38
Oswald

Registered: Apr 2002
Posts: 5094
"RTI/RTS handles the return address a bit different "

wot ? didnt knew this. why ?
2016-08-17 11:39
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: "RTI/RTS handles the return address a bit different "

wot ? didnt knew this. why ?


Dunno, but it does.
2016-08-17 11:48
chatGPZ

Registered: Dec 2001
Posts: 11386
iirc there was a longish thread explaining it on 6502.org
2016-08-17 12:19
Krill

Registered: Apr 2002
Posts: 2980
Quoting Oswald
"RTI/RTS handles the return address a bit different "

wot ? didnt knew this. why ?
Why, because JSR pushes the return address MINUS 1 on stack while an interrupt simply pushes the return address, of course. :D

But seriously, as groepaz implied, the reason for that is likely due to some 6502 design intricacies. Something like JSR pushing next op-code minus 1 because PC at that stage isn't incremented yet to the next op-code, while interrupts are handled exactly between op-codes (after increasing PC).
2016-08-17 12:21
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: iirc there was a longish thread explaining it on 6502.org

Ahh ok, didn't know. I was painfully aware of it when I implemented my preemtive multitasking to support yeild (i.e. give up CPU to another thread). Normally the task-switch is performed by some interrupt (i.e. the return / continuation point for the thread is placed on the stack and resumable with an RTI). However, when I want to yield in "userspace", i.e. not wait until the next task switch, the task switch is performed by a subroutine and thus resumable with an RTS. So I need to keep that in mind so that I don't accidentally mix up those to types of resume possibilities. Basically the yield-call manipulates the stack to convert it from RTS-compatible to RTI-compatible by adding to the return address and push the status also. Hairy, but it works... :) (And it's useless, but fun!)
2016-08-17 12:43
Krill

Registered: Apr 2002
Posts: 2980
Why didn't you use BRK, which was basically invented for things like this? :) (It's the 6502 equivalent of TRAP.)
2016-08-17 12:47
chatGPZ

Registered: Dec 2001
Posts: 11386
brk is more useful for systemcall type of things, not "yield" imho
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
Doc Snyder/ONS
slimeysmine
Magic/Nah-Kolor
iAN CooG/HVSC
Martinland
Freeze/Blazon
WVL/Xenon
Mason/Unicess
Steffan/BOOM!
ΛΛdZ
astaroth/TRSI
Copyfault/Extend^tsn..
A3/AFL
E$G/HF ⭐ 7
The Syndrom/TIA/Pret..
Walt/Bonzai
Guests online: 106
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 No Listen  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

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