6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 12:12 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Sep 08, 2004 4:10 pm 
Offline

Joined: Tue Nov 18, 2003 8:41 pm
Posts: 250
I've had a scheme for code compression rattling around in my head (which is
to say, I've never done anything but thought about it) for a while that has
been brought to mind by recent discussion here.

I've heard tell of VMs that use a stack oriented paradigm but actually get
compiled with the stack stuff mapped to register operations.

So now if you think of zero page as a big register set, the idea is a simple
language, something like an integer Basic, that gets compiled to a byte
code for a stack oriented VM (although, perhaps it would just be simpler to
do something Forth like) and then small or moderately sized blocks of byte
code would get compiled at run time to zero page and/or absolute
addressed ML.

I'm kind of curious if anybody's ever implimented such a scheme (or knows
of a of an implimentation)
Or just has any thoughts to offer.

The idea of course would be to get the size advantage of tokens with the
speed advantage of code compiled directly to ML (or at least to mitgate
some of the speed lost to the use of tokens)
Which seems to me might be possible if you can structure your code and
size your blocks so that you don't spend most of your time swapping
chunks of zero page to an actual stack or recompiling blocks of byte code.

So eg it might work well if you spent a lot of time in short enough loops,
but it would probably make a mess of recursion.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Sep 10, 2004 7:45 am 
Offline
User avatar

Joined: Thu Mar 11, 2004 7:42 am
Posts: 362
I haven't implemented anything like this either, but here are some thoughts.

1. You might be able to do without the register architecture. ZP,X addressing is just as fast as ABS addressing, so depending on how much stack space you need, it may be just as simple to use the ZP as a stack.

2. The fastest (untested) practical (only the accumulator is overwritten) token interpreter I've been able to think up takes only 22 cycles (23 on the 65C02), including the JMP to the "interpret next token" routine. (The fastest routine I could think up was 17 cycles on a 65C02, but X was overwritten and Y must be preserved). Normally, it is not necessary to have everything run at top speed, so it might be better if you don't compile everything into ML. For example, you could use special tokens to switch between interpreting tokens and compiling to ML.

3. My philosophy is: if recursion is ugly, so be it. Almost every recursive routine I have ever written was homework.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: