Sun May 11 15:01:22 CEST 2008

purrr compile time expressions

One of the cool core features of Purrr is the ability to inline
compile time computation without extra annotation. (In Forth
traditionally the words '[' and ']L' are used.) This allows for a very
flexible macro composition mechanism.

However, the computations are performed in infinite precision, and do
not give the same results as would do the same code without these
compile-time computations. I.e. in Purrr18:

             1000 30 /

makes no sense on target due to 8-bit limitation (and possibly
non-availability of the / operator), but makes sense in Purrr18
because the endresult will be truncated only in the end. What is
compile is
             [DUP] [MOVLW (1000 30 /)]

because the target is only 8-bit, this sort of computations is very
useful, and really should be the default (over annotated

Now the question is: i'd like to build a simulator that can execute
the generated PIC18 code. is it possible to generate intermediate code
that's easier to simulate than PIC18 code, but produces the same

This looks like a very hairy problem: PURRR18 is a 'dirty low level'
language where constructs are defined as-is, and you should be aware
of bit-depth limitations and flag effects etc.

The stay-out-of-trouble part of me says i should stick to a genuine
PIC18 simulator. It can simulate code generated by other means.
Following that approach probably also makes it easier to plugin
external simulators.