<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 10 Jun 1993 10:40:38 +0100 (BST)
From   : "I Stephenson" <ian@...>
Subject: Re: m/c optimisations 

>There is a radically different technique where you implement a
>byte code interpreter in machine code, then use the interpreter
>to run your program. Loses time, but often saves LOTS of space,
>especially on old fashioned architectures.

I though about this a while ago, and I'm not conviced that on a processor like  
the 6502 the performace will be that much worse than real machine code  (at  
least for compiler generated stuff, with little optimisation)!

Consider the code that Small C can produce - absolutly everything has to be a  
subroutine right down to add and subtract, hence the code becomes 

JSR push
JSR push
JSR add
JSR store
etc..

particularly as the 6502 stack is inadaquate for this sort of stuff.

With byte codes we can write
push;push;add;store;
where each is only a single byte - a three fold improvement in memory usage
(OK I've neglected operands, but the idea holds).

Performance isn't so bad as we can write the interpretter as
.loop
LDX pc
INC pc
JSR (table,x) \I think this is a bad instruction!
JMP loop

OK in practise its much worse than this, but can still be pretty efficient,  
after all most of the work is done by the instruction subroutines, and these  
are still the same for both methods.

Just some thoughts
Ian
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>