About this package. 4tH 4tH Forth compiler
Reklama
Reklama
Chapter 3
Installation Guide
3.1
About this package
4tH will compile ordinary text-files (MS-DOS and Unix) as well as block-files produced by the 4tH editor. The user-interface of this line-editor is highly compatible with conventional
Forth block-editors.
4tHs special architecture almost forces you to write "clean" code, so you will learn Forth the proper way. This does not mean that you can’t write portable code with 4tH. In fact, because Forth is so flexible you can usually write a small interface to your well-written
4tH-code in a matter of minutes.
You can use 4tH in virtually every environment, from Linux to MS-Windows. You don’t even have to recompile your applications since 4tH uses a special executable format, that is interpreted by the 4tH virtual machine.
3.1.1
Example code
There are a lot of example programs, written in 4tH. From line-editors and calculators to adventure-games. Not all have been especially written for 4tH. There are quite a few programs from the hand of people like Professor C.H. Ting and Leo Brodie that started their existence as Forth-programs.
Most are available in source. That means they have the extension ’.4th’. You can examine or edit them like any other source-file. Source-files written with the 4tH editor get the extension ’.scr’. They can only be edited with the 4tH editor or other Forth blockfile editors.
Executables have the extension ’.hx’ (Hcode eXecutable).
3.1.2
Main program
You will find a binary program within this package called 4tH. You can copy this binary to any directory. 4tH is a small development system by itself. When you start it, it will automatically enter interactive mode and show you a menu not unlike early versions of
Turbo Pascal. You can edit, compile, run and debug programs from the 4tH prompt. Please read chapter 4 for more details.
You can also use 4tH from the commandline:
29
CHAPTER 3. INSTALLATION GUIDE
4th <commands> <file> [file | argument .. argument]
30
It takes most combinations of these ten commands: m enter interactive mode e edit a 4tH screenfile c load a sourcefile (.4th) and compile it l load an objectfile (.hx) d decompile a 4tH program g generate a C sourcefile (default: out.c) s save a 4tH program (default: out.hx) x execute a 4tH program v enter verbose mode q suppress copyright message
A few examples:
• To compile a 4tH program and save the object code: 4th csv <source.4th>
[object.hx]
• To compile a 4tH program and execute it: 4th cx <source.4th>
• To decompile object code: 4th ld <object.hx>
• To convert object code to C source: 4th lg <object.hx> [source.c]
• To load and execute object code: 4th lx <object.hx> [arguments]
• To load and execute object code without arguments: 4th <object.hx>
• To edit a 4tH screenfile: 4th e <source.scr>
• To enter interactive mode: 4th m <source.scr>
• To enter interactive mode (without loading a screenfile): 4th
Note: don’t include the "[]" and "<>" in your commandline. They are just there to show whether an argument is optional ([arg]) or mandatory (<arg>).
3.1.3
Unix package
It is not possible for us to provide Unix binaries for all possible platforms, not now and not in the future, simply because we don’t have access to them all. Here is a list of the Unix
(like) platforms that are known to compile 4tH:
• Intel - FreeBSD
• Intel - Coherent
Stáhnout
Reklama