GitXplorerGitXplorer
l

4th

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
5081cdeee31f00896a9f7cf5d0f0bc18057e8cd9

readme

committed 12 years ago
Unverified
fb9520c033c290a1ca489bbf898434a63269a9d9

included ffi

committed 12 years ago
Unverified
39c633c19d1e6531a6fa9db4b0fba33ce3c04142

now you can generate a forth repl with all the kernel inside

committed 12 years ago
Unverified
3b10821ce39fc8ef8000c5035aecfbdde72eeea7

moved repl to kernel

committed 12 years ago
Unverified
4ab621e9e1f2b1f7d6145c54d84442f1e7dbbe58

compiler warnings

committed 12 years ago
Unverified
fff398666d9afe195dd5e71969d7e0d0fe88c06d

fixes for turnkey application

committed 12 years ago

README

The README file for this repository.

4th Forth System

This is a forth system based on a VM-architecture. The bytecode interpreter can be compiled in Windows and in Linux with a simple ANSI C compiler. The system in designed to be simple and solid. The system can be compiled under 32 or 64 bit systems.

The system has primitives to call external code, which must be located in a external shared library. You can also add additional primitives.

You can save the system state in a "dump" which can be translated to a C file and then linked to the runtime to generate a turnkey application.

How to compile

Under Linux use the shell script compile.sh and under Windows you can use compile.bat. If you want to compile a 64 bit Forth you should use the compile_64.bat or compile_64.sh script.

You will find a forthconsole executable which is a Forth REPL that you can use to develop in a interactive way.

With the script do_images.bat you can generate a Forth REPL that includes the full kernel.

Examples

Under the examples directory you can find some example of what you can do with this Forth system.

Editor support

There is a minimal editor support for editing Forth files under Emacs under the emacs directory.

How to generate turnkey applications

To generate turnkey applications you must:

Load your application in the interactive environment and create a main word that will be called by the application.

C> forth
4Forth 0.1 (06/2009)
Code Space: 2434
Data Space: 23489
----
 
kernel full.4th
 
 
4> : main ." turnkey application example!" cr ;
 ok

Generate a forth image (forth.image) with the word saveimage:

4> saveimage
 ok
4>  

Execute forthc that will embed your image in a C file and will compile that file with the forth runtime:

C> forthc forth.image myexample
genero: myexample.c
eseguo: gcc -o myexample -DOS_WINDOWS myexample.c -L. -l4th
eseguo: strip -s myexample.exe

C> dir myexample.exe
23/08/12  15.29           128.014 myexample.exe

You are ready to run:

C> myexample.exe
turnkey application example!

As you see a turnkey application with all the forth libraries and the VM is something like 128K, which is not terribly big in this days.

License

Copyright (c) 2012, Leonardo Cecchi All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.