GitXplorerGitXplorer
l

4th

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
1951d6eea318b17f2ce71c1a71f1c40cbf9b9dd1

english translation

committed 12 years ago
Unverified
a40c25f364c19545c0d2146a49b42812b2e8dfa2

working on embedding repl to a forth kernel

committed 12 years ago
Unverified
e5154aca123009f1c15ba4851cb603e03f77360f

readme file

committed 12 years ago
Unverified
b8e8931a3b2242927b31165733a31bb301699bad

64 bit compilation script for windows

committed 12 years ago
Unverified
12b5a1dd8be7fc5daf8274b1fe030d3b4960daa9

64 bit adaptation

committed 12 years ago
Unverified
3cc1065df56cf7ba8252519f0c72fec6d08e1ddf

ignored vim swap files

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.