White Flame wrote:
PLASMA is a VM, so if the point is to get high speed, which is usually why C is chosen over other HLLs, I don't think that's the direction to take. VMs are great for code density, though.
PLASMA currently targets the VM, but it didn't always. The first version:
(
http://vm02.cvs.sourceforge.net/viewvc/ ... 02/plasma/)
could generate three different outputs: byte code, threaded code, and in-line native. The in-line code was quite fast, but as noted earlier, the 6502 isn't the most efficient compiler target, so it was a great deal larger. So later versions targeted just the byte code with an eye towards an efficient interpreter and the ability to execute byte code out of auxiliary/extended memory.
As for high speed, that can be subjective. PLASMA is certainly faster than BASIC, and is roughly equivalent to Forth (I used many concepts from Forth's interpreter when designing PLASMA's VM). The cc65 C compiler implements much of its functionality through library calls to keep the code size reasonable. Each call takes 12 cycles just for JSR/RTS and I have the inner loop for the VM down to 16 cycles. Not insignificant, but the code density and ability to have byte code in auxiliary memory was a good tradeoff, IMHO.
My eventual goal is to create a JIT to target 6502/65C02 which may or may not happen in my lifetime. However, whichever HLL compiler to implement on a 6502, it seems to me that an intermediate representation that satisfies the requirements of implementing the HLL constructs while still fitting into the constraints of the 6502 is crucial. I just went through a re-write of the compiler to extract out the optimizer into an optional back-end operation. This greatly simplified the main code generator and allowed for much better optimizations to occur (with great help from SteveF:
http://stardot.org.uk/forums/viewtopic. ... 88#p163288)
Although I've programmed professionally in C for 33 years, I find PLASMA to be much more productive on the 6502 than any other language (Ok, so I'm a little biased). I will still write a number of performance critical routines in 6502 assembly (easy to write assembly routines inside PLASMA) but quite honestly, 100% of the code I write doesn't have to be the fastest possible.
Dave...