flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > FreeForth |
Author |
|
Christophe Lavarenne 25 Aug 2009, 12:16
FreeForth is a public domain, small and fast, extendable interactive incremental compiler generating compact i386 native code, including floating-point instructions, with more than 100K of online help and a Primer documentation.
It has been developped and used for everyday work since 2006, as interactive development basis for real-time industrial applications embedded into microcontrollers, such as the TI-MSP430 and the STM32, and for PC-controlled manufacturing test benches. Fasm (thanks Grysztar!) is used to assemble the compiler seed (less than 3K of binary code and 1K of symbols table, for Linux or Windows), and embed in the compiler executable the compiler core source (less than 8K of text, documented in the online help) that the compiler seed compiles on startup; then the compiler core compiles an user-editable startup file, then the shell command line, and finally enters its top loop prompting the user to edit/enter lines to compile. Unlike other Forth dialects (which either compile, or interpret i.e. execute each source word in turn and therefore are unable to manage control structures forward references in interpret mode), FreeForth has no interpreter, it simply always compiles, i.e. looks for each word in its symbol table, and compiles a call assembly instruction to the code pointed to by the symbol; but words defined by a symbol with a final backquote (aka "macros"), when used without their final backquote, are instead executed: macros are the compiler components (they are the equivalent of "immediate" words in other Forth dialects), they are used mainly to inline i386 binary code. You can easily extend the compiler by defining new macros. The macro ;` (semicolon) is the heart of FreeForth interactivity; it terminates a "definition" (i.e. subroutine) by compiling a subroutine return assembly instruction; then if the definition is anonymous (i.e. its entry point was not explicitely declared with a symbol by the macro :` but instead implicitely declared by the previous ;), as ; can't reference the adef (anonymous definition) later by a symbol, it recovers its memory space by bringing back the compilation pointer to the adef entry point, and issues a call to it; i.e. anonymous definitions are executed by their terminating ; More sweeties and implementation details are described on the FreeForth home page. Christophe Lavarenne http://christophe.lavarenne.free.fr |
|||
25 Aug 2009, 12:16 |
|
shoorick 26 Aug 2009, 04:50
amazing listing!
|
|||
26 Aug 2009, 04:50 |
|
rugxulo 29 Aug 2009, 04:31
Looks very cool, but it's (still) a bit over my head even though I've briefly looked at Forth before. I personally wonder how much work it would be to port to FreeDOS (probably not much from what I can tell by looking).
|
|||
29 Aug 2009, 04:31 |
|
Christophe Lavarenne 29 Aug 2009, 08:45
Saluton Rugxulo, FreeForth is designed for a 32-bits flat model, whereas DOS is designed for a 16-bits segmented model. Kind of problem: the ff.help file is more than 100K, it couldn't fit into a single segment.
|
|||
29 Aug 2009, 08:45 |
|
rugxulo 29 Aug 2009, 22:16
Christophe, ever heard of "flat real" mode? (Hint: FASM uses it or DPMI.) So I'm sure it's possible. Now, I'm probably not skilled enough to do it myself, and honestly I almost consider it wrong to bring it up here. But I also felt you should have some feedback for your excellent work, so I risked it anyways.
P.S. Technically, I have enough (old) DOS Forths lying around to play with. And like I said, I don't know Forth much (that's an understatement!). I just hate the idea that *nix and Win32 are all that's left in the world. |
|||
29 Aug 2009, 22:16 |
|
shoorick 31 Aug 2009, 05:54
agree with rugxulo
in my view, forth application area is mostly autonomic systems, as with forth it is possible to make complex and flexible system in strict conditions for the size of memory etc., diskless systems and so. usual modern systems give us an "ocean" of ram and disks space, so profit of using forth become unsignificant, while it gives more strict requirements for the programmer. |
|||
31 Aug 2009, 05:54 |
|
rugxulo 31 Aug 2009, 07:41
I'll be honest, though, messing with the recent Befunge interpreter (written in FASM) makes me more curious about Forth again.
|
|||
31 Aug 2009, 07:41 |
|
Christophe Lavarenne 02 Sep 2009, 19:30
FreeForth has been designed with multi-OS support in mind.
As described on FF home page, most source files are OS-independent, and 3 are OS-dependent (in the following filenames, substitue "lin" for Linux by "win" for Windows, say "dos" for DOS, and say "osx" when fasm supports OS-X): + fflinio.asm for file-io (and DLL, although maybe not for DOS) assembly interface (around 9K bytes) + fflin.boot for environment-variable dependent location of FF home directory (around 300 bytes) + fflin.asm defining 3 small OS-dependent macros before including the OS-independent source ff.asm If any fasm artist wants to port FF under DOS in "flat real" mode, his questions for help on FF will be welcome. |
|||
02 Sep 2009, 19:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.