home .. forth .. misc mail list archive ..

Re: support, T-shirts, etc. (composite reply)



-----Original Message-----
From: M. Simon <msimon@tefbbs.com>
To: MISC@pisa.rockefeller.edu <MISC@pisa.rockefeller.edu>
Date: Thursday, March 18, 1999 6:04 AM
Subject: Re: support, T-shirts, etc. (composite reply)


>What is nanoFORTH?
>
>Simon


nanoFORTH is a core set of 15 stack instructions. The 16th instruction needs
to be nop for instruction alignment in a packed instruction implementation.
I am planning a 32-bit design which fetches an octet of 4-bit instructions.
The attachment summarizes a few of the details.

Myron Plichota

( nForth instruction set: 32-bit cells, 28-bit address implementation)
( Eight 4-bit instructions are packed into each cell.)
( Instruction slots are numbered 0..7 from left to right.)
( Execution progresses from left to right.)
( Most opcodes may occur in any slot, except JZ and CALL must occur in)
( slot 0 with the absolute address in slots 1..7.)
( LIT may occur in multiple slots with inline data in following cells.)
( There are only 2 machine registers, T and PC.)

( NOP)          ( --)                           ( no operation, alignment pad)
( JZ)           ( n --) ( "label")              ( jump if T = 0)
( CALL)         ( --) ( R: -- PC) ( "label")    ( call subroutine)
( RET)          ( --) ( R: addr --)             ( return from subroutine)
( +)            ( n1 n2 -- n1+n2)               ( ADD T with NOS)
( NAND)         ( n1 n2 -- n1NANDn2)            ( NAND T with NOS)
( XOR)          ( n1 n2 -- n1^n2)               ( XOR T with NOS)
( 2/)           ( n -- n/2)                     ( shift T right, msb = msb)
( DUP)          ( n -- n n)                     ( duplicate T)
( DROP)         ( n --)                         ( discard T)
( SWAP)         ( n1 n2 -- n2 n1)               ( exchange T with NOS)
( >R)           ( n --) ( R: -- n)              ( pop parameter stack to return stack)
( R>)           ( -- n) ( R: n --)              ( pop return stack to parameter stack)
( @)            ( addr -- n)                    ( T = memory[T])
( !)            ( n addr --)                    ( memory[T] = NOS)
( LIT)          ( -- n) ( "value")              ( push inline cell, PC++)

: OVER          ( n1 n2 -- n1 n2 n1)
    >R DUP R> SWAP ;

: ROT           ( n1 n2 n3 -- n2 n3 n1)
    >R SWAP R> SWAP ;

: R@            ( -- n) ( R: n -- n)
    R> DUP >R ;

: EXECUTE       ( addr --)
    >R ;

: INVERT        ( n -- ~n)
    DUP NAND ;

: NEGATE        ( n -- -n)
    DUP NAND 1 + ;

: -             ( n1 n2 -- n1-n2)
    DUP NAND 1 + + ;

: AND           ( n1 n2 -- n1&n2)
    NAND DUP NAND ;

: OR            ( n1 n2 -- n1|n2)
    DUP NAND SWAP DUP NAND NAND ;

: +!            ( n addr --)
    DUP >R @ + R> ! ;

: 2*            ( n -- 2*n)
    DUP + ;

( A simple constant defined via colon definition.)
HEX
: MOST-NEGATIVE ( -- k)
    80000000 ;

( Compiler stack security checking must be sacrificed for the following )
( examples to work.)

( A calculated constant defined via colon definition.)
DECIMAL MOST-NEGATIVE 65536 /
: LEAST-Q15     ( -- k)
    LITERAL ;

( An uninitialized variable defined via colon definition.)
HERE 1 ALLOT
: MY-VAR        ( -- @)
    LITERAL ;

( An initialized variable defined via colon definition.)
HERE HEX 12345678 ,
: MY-IVAR       ( -- @)
    LITERAL ;

( An array defined via colon definition.)
HERE 10 ALLOT
: MY-ARRAY      ( +n -- @)
    LITERAL + ;