[<<][staapl][>>][..]
Sun Aug 24 19:25:38 CEST 2008

machine model


Now, pragmatically, it would probably be easier to market Staapl as a
machine model instead of a programming language.  This model should be
a stripped down version of ANS Forth, with reflective words removed.
Let's have a look at Moore's "core set" and his processor primitives.
Staapl needs more: Harvard architecture can't be abstracted.

Two possible complementary usage scenarios:

  * individual embedded developers using the macro forth or the static
    combinator language directly to write applications and provide new
    target chips.

  * using the language model as a target language for higher order
    description compilation in a model-based design approach.

Now, compared to other machine models, the one in Staapl is a 'mid
point': you write the standard primitives in terms of appropriate
machine primitives in the same system.  There is no intermediate "byte
code" representation that requires an explicit byte code interpreter
with optional jit: the idea is to use just code transformers.

Let's see

All arguments are data cell size, or arbitrary compile time
identifiers that can be optimized away.  This exposes 3 stacks.  One
stack is partially evaluated (the D stack) which means it is present
at run time and at compile time (containing quoted, opaque machine
instructions or hibrid immediate instructions).  The R stack is only
present at run time and the M stack only at macro execution time.

Note that the machine model does not specify machine flags: macros for
flags should be hidden in the lower layers.  When these primitives
require runtime support, they should redirect to the same name
prefixed with a tilde "~" character.  Conditions "?" are probably
compile-time constructs to ensure optimal encoding of branch and skip
instructions.  If they survive to runtime, they are encoded as 0=false
and true otherwise.

(primitives

;; WORD             D          R      M

;; Data

(@                  (a -- x)   (--)   (--) "Fetch data")
(!                  (x a --)   (--)   (--) "Store data")
(+ - * / and or xor (x y -- z) (--)   (--) "Binary operator")
(<< >> 2/           (x -- y)   (--)   (--) "Unary operator")


;; Aux stack
(>r                 (x --)     (-- x)   (--) "To r stack")
(r>                 (-- x)     (x --)   (--) "From r stack")
(r@                 (-- x)     (x -- x) (--) "Fetch from r stack")

;; Control

(call               (--)       (-- a) (l --) "Call label")
(jump               (--)       (--)   (l --) "Tail call label")
(exit               (--)       (a --) (--)   "Return to caller.")
(or-jump            (? -- )    (--)   (l --) "Conditional jump to label")

;; Indirect memory access

(@a                 (-- x)     (--) (--) "Fetch RAM.")
(@a+                (-- x)     (--) (--) "Fetch RAM, increment a")

(@p                 (-- x)     (--) (--) "Fetch RAM.")
(@p+                (-- x)     (--) (--) "Fetch ROM, increment p")

)





[Reply][About]
[<<][staapl][>>][..]