How to start? - Download and prepare a Forth system

SP-FORTH
SP-Forth is a very fast ANS Forth by Rufig, Russian Forth Interest Group. For Windows only 32 bit Forth is available by now, but since it's possible to compile machine code it's faster than Forth coded 64 bit systems. The big drawback is the lost of 64 bit single integers. There is a preliminary 64 bit version for Unix.

To download 32 bit Windows system:

http://sourceforge.net/projects/spf/files/latest/download

Then open Notebook and paste the code below:


\ Preparation for MathForth words
\ -------------------------------------------

REQUIRE case-ins lib/ext/caseins.f
REQUIRE LOCALS| ~af/lib/locals-ans.f
REQUIRE { lib/ext/locals.f
REQUIRE M*/ lib/include/double.f
REQUIRE F. lib/include/float2.f
REQUIRE /STRING lib/include/string.f

CASE-INS ON

WINAPI: GetTickCount KERNEL32.DLL
WINAPI: SetConsoleCursorPosition KERNEL32.DLL
WINAPI: GetConsoleScreenBufferInfo KERNEL32.DLL
WINAPI: FillConsoleOutputCharacterA KERNEL32.DLL

 0 2 -- off_x
   2 -- off_y
   CONSTANT /coord

 0 2 -- Left
   2 -- Top
   2 -- Right
   2 -- Bottom
   CONSTANT /rect

 0 /coord -- Size
   /coord -- Position
        2 -- Attrib
   /rect  -- Window
   /coord -- Dimensions
   CONSTANT /buffer

CREATE buffer /buffer ALLOT

: xy@ \ addr -- x y
  DUP off_x W@ SWAP off_y W@ ;

: GETXY \ -- x y 
  buffer H-STDOUT GetConsoleScreenBufferInfo DROP
  buffer Position xy@ ;

: SETXY \ x y --
  16 LSHIFT OR H-STDOUT SetConsoleCursorPosition DROP ;

: ~chars \ char # --
  SP@ GETXY 16 LSHIFT OR 2SWAP SWAP H-STDOUT
  FillConsoleOutputCharacterA DROP ;

: PAGE  0 0 SETXY BL 
  buffer H-STDOUT GetConsoleScreenBufferInfo DROP
  buffer Size ~chars ;

\ : fround 1.e 2.e f/ f+ fint ;
: utime  GetTickCount 1000 um* ;
: under+  rot + swap ;

: .r \ n i --
  >r dup 0< swap abs
  0 <# #S rot sign #>
  R> OVER - SPACES TYPE ;

\ CASE-OF STRUCTURE

: CASE  \ -- 0 
  0 ; IMMEDIATE \ initial count of ofs 

: OF \ c: #of -- orig #of+1 
     \ x --  
  1+ >R 
  POSTPONE OVER 
  POSTPONE = 
  [COMPILE] IF 
  POSTPONE DROP 
  R> ; IMMEDIATE 

: ENDOF \ c: orig1 #of -- orig2 #of  
  >R [COMPILE] ELSE R> ; IMMEDIATE 

: ENDCASE \ c: orig1..orign #of --  
  POSTPONE drop \ discard case value 
  0 ?DO [COMPILE] THEN LOOP ; IMMEDIATE \ generate targets 

: f>s f>d drop ;
: s>f 0 d>f ;

: OK2 ( -- ) STATE @ IF EXIT THEN ."  ok" CR ; 
' OK2 TO OK


\ -------------------------------------------

Name the file SPForthmath.f and save it in an optional map. When double clicking on the filename the system is started.

GFORTH

GForth (GNU) is a somewhat optimized ANS Forth for a lot of operating systems as Unix, Windows and Android. GForth for Androids is loaded through Google Play and is ready to be used for ForthMath code.

To load 64 bit GForth for Windows systems:

64 bit GForth executable file

and to load 32 bit GForth for Windows:

32 bit GForth executable file

No preparation needed. There is also a GForth for Android that works fine without preparation.

Win32Forth
Sometimes difficult to load because of AV-systems, but 

Win32Forth6.15.03

works on my laptop win10. No preparation needed.


No comments:

Post a Comment