Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > SOD64 - a 64bit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3816 of 4160
Post > Topic >>

SOD64 - a 64bit Stack Oriented Design Processor

by mhx@[EMAIL PROTECTED] (Marcel Hendrix) Mar 8, 2008 at 05:46 PM

I have ****ted L.C. Benschop's Stack Oriented Design processor (1994)
to iForth, and extended it so that it can generate 64-bit Forths.

SOD is a very elegant design. Its opcodes are 5 bit long, so 
12 of them fit in a single 64 bit CELL. Three bits in the CELL
are used to signify RETURN, CALL, LITERAL or packed instructions.

SOD64 needs a virtual machine to run. I have written one in
32bit iForth. This means SOD64 executes on 32bit Linux and Windows.
The image files on both platforms are bit-for-bit the same 
(like 4th). You could write an LSE64 in it :-)

As you can see, doubles in SOD64 are 128 bits wide:

-1 -1 1 R****FT D. 170141183460469231731687303715884105727  OK

SOD64 can metacompile and extend itself. However, because it 
needs a virtual machine, you need a 32bit Forth to host it.

I may feel inspired to ****t Lennart's C engine over to Linux.
In that case SOD64 would become a standalone 64bit Forth that 
can can generate efficient and small (20 K) 64-bit executables.
Windows64 may be a problem though (I don't have that platform).

SOD64 is a quite complete ANS Forth with some good utilities, as
you can see below. There is no floating-point (yet), though.

-marcel

--- ------------------
FORTH> sod64 forth.img
20160 bytes image read
Welcome to Forth

SEE CR
$00000440  $CFE8EF7F  13 1 1 + 32 SPECIAL 10 1 1 + 32 SPECIAL ;  OK

SEE WORDS
$000042E8  $A09D3FFF  7192 7256 @[EMAIL PROTECTED]
 1 NEGATE + 1 1 + 1 + L****FT
$00004300  $000039D1  + @[EMAIL PROTECTED]
 @[EMAIL PROTECTED]
  $00000031  DUP
$00004310  $0000433A  JZ   $00004338
$00004318  $00000031  DUP
$00004320  $000042B0  CALL $000042B0
$00004328  $0387413D  8 NEGATE + @[EMAIL PROTECTED]
 0
$00004330  $0000430A  JZ   $00004308
$00004338  $00000029  DROP ;  OK

0 100 DUMP
00000000: 00 00 00 00 00 00 3A 88 00 00 00 00 00 00 39 B0 ......:.......9¦
00000010: 00 00 00 00 00 00 00 00 A4 4E 4F 4F 50 00 00 00 ........ñNOOP...
00000020: 80 00 00 00 00 00 00 01 00 00 00 00 00 00 00 18 ................
00000030: A4 53 57 41 50 00 00 00 80 00 00 00 00 00 00 03 ñSWAP...........
00000040: 00 00 00 00 00 00 00 30 A3 52 4F 54 00 00 00 00 .......0úROT....
00000050: 80 00 00 00 00 00 00 05 00 00 00 00 00 00 00 48 ...............H
00000060: A2 30 3D 00 00 00 00 00 80 00 00 00 00 00 00 07 ó0=.............
OK

-1 -1 1 R****FT D. 170141183460469231731687303715884105727  OK

CR WORDS 
SAVE-SYSTEM SEE IDIS DO_SEE seers SDO_SPECIAL SDO_LIT SDO_8 SDO_1 SDO_0
SDO_R> 
SDO_R@[EMAIL PROTECTED]
 SDO_OVER SDO_DUP SDO_!A SDO_C!A SDO_>R SDO_DROP SDO_SCAN1 SDO_+CY
SDO_UM/MOD
SDO_R****FT SDO_L****FT SDO_< SDO_U< SDO_XOR SDO_OR SDO_AND SDO_+ SDO_@[EMAIL PROTECTED]
 SD
O_UM* SDO_NEGATE SDO_0= SDO_ROT SDO_SWAP SDO_NOOP H. ir ip cellmask WORDS
ID. .S
DUMP DL VOCABULARY ONLY ROOT-WORDLIST FORTH DEFINITIONS WORDLIST PREVIOUS
ALSO 
SET-ORDER GET-ORDER PAGE CLS .ELAPSED TIMER-RESET NIP -TRAILING WITHIN
BOUNDS 0<= 
<= THROW M: COMPARE \G COLD WARM QUIT INCLUDED INCLUDE-FILE
INCLUDE-POINTER 
INCLUDE-BUFFER EVALUATE INTERPRET ?STACK DOES> (;CODE) >BODY \ ( IMMEDIATE

POSTPONE ABORT ABORT" S" ." RECURSE +LOOP LOOP RESOLVE-LEAVE LEAVE ?DO DO
[CHAR] 
CHAR ['] ' POCKET REPEAT WHILE ELSE THEN IF UNTIL BEGIN : (POSTPONE) ;
?CSP !CSP 
'LEAVE CSP COMPILE, EXPAND-MACRO LITERAL INSERT-OPCODE CODEFLUSH OP****FT
OPLOC [ ] 
STATE CONSTANT VARIABLE CREATE REVEAL HEADER NAME> >NAME ALIGN C, , ALLOT
(ABORT") 
NUMBER? CONVERT >NUMBER DIGIT? FIND SEARCH-WORDLIST NAME>BUF CURRENT
#ORDER CONTEXT
LAST FORTH-WORDLIST NAMEBUF WORD PLACE PARSE SKIP SCAN REFILL SOURCE-ID
SOURCE QUERY
EXPECT #SRC SRC SID >IN #TIB SPAN TIB ACCEPT FILE-SIZE SYSTEM
FILE-POSITION 
REPOSITION-FILE DELETE-FILE READ-FILE WRITE-FILE READ-LINE WRITE-LINE
CLOSE-FILE 
CREATE-FILE OPEN-FILE OSCALL BIN R/W W/O R/O 2SWAP 2OVER FILL MOVE ROLL
CMOVE> CMOVE
.. U. D. #> <# SIGN #S # HOLD MU/MOD PAD HERE SPACES SPACE HEX DECIMAL DPL
HLD DP 
BASE EXECUTE EXIT MOD / /MOD S>D */ */MOD * M* FM/MOD SM/REM DABS ABS
DNEGATE MAX 
MIN ?DUP 2DROP 2DUP 2! D+ 2@[EMAIL PROTECTED]
 +! CELL- CELLS CELL+ CHAR- CHARS CHAR+ 2/ 2*
INVERT 
1- 1+ ON OFF ! C! PICK BL TRUE FALSE (S") (.") ALIGNED TYPE COUNT -1
(+LOOP) (LOOP)
UNLOOP (LEAVE) J I (?DO) (DO) DEPTH RP! RP@[EMAIL PROTECTED]
 SP! SP@[EMAIL PROTECTED]
 R0 S0 CR BYE KEY EMIT
U> 0> > 
0< <> = - DOVAR LIT 8 1 0 R> R@[EMAIL PROTECTED]
 OVER DUP !A C!A >R DROP SPECIAL SCAN1 +CY
UM/MOD 
R****FT L****FT < U< XOR OR AND + @[EMAIL PROTECTED]
 C@[EMAIL PROTECTED]
 UM* NEGATE 0= ROT SWAP NOOP  OK

22 33 44 .S 22 33 44  OK
.. . . 44 33 22  OK

    1 CONSTANT #times  OK
#8192 CONSTANT size  OK
  OK
CREATE flags size ALLOT  OK
  OK
: DO-PRIME flags size 1 FILL
  0  size 0 DO I flags +
               C@[EMAIL PROTECTED]
 IF I 2*  3 +
                     DUP  I +
                        BEGIN  DUP size
                     U< WHILE  0 OVER flags + C!
                               OVER +
                        REPEAT
                     2DROP 1+
                THEN
           LOOP ;  OK
  OK
: PRIMES CR #times . ." iterations."  TIMER-RESET
  0 #times 0 DO
                DROP  DO-PRIME
           LOOP
  CR .  ." primes found, " .ELAPSED ;  OK
PRIMES
1 iterations.
1899 primes found, 0.035 seconds elapsed. OK
 




 2 Posts in Topic:
SOD64 - a 64bit Stack Oriented Design Processor
mhx@[EMAIL PROTECTED] (M  2008-03-08 17:46:11 
Re: SOD64 - a 64bit Stack Oriented Design Processor
mentifex@[EMAIL PROTECTED  2008-03-08 09:21:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 18 22:30:46 CDT 2008.