BBC BASIC for Windows
« New FORTHLIB library »

Welcome Guest. Please Login or Register.
Nov 21st, 2009, 09:33am




Pages: 1  Reply Notify Send Topic Print
 thread  Author  Topic: New FORTHLIB library  (Read 59 times)
Richard Russell
Administrator
ImageImageImageImageImage

member is offline

Avatar




Homepage PM

Gender: Male
Posts: 276
xx New FORTHLIB library
« Thread started on: Oct 17th, 2009, 11:26am »
Quote

I have created a new library which allows you to incorporate Forth subroutines in a BASIC program:

http://groups.yahoo.com/group/bb4w/files/Libraries/FORTHLIB.BBC

Forth is much faster than BASIC, but is easier to learn (and more portable) than assembly language.

FORTHLIB contains three callable procedures:

Code:
PROC_forth_init(dictionary_size%) 

Initialise the Forth subsystem with a dictionary of the specified size (bytes).

Code:
PROC_forth_compile(forthfile$) 

Compile a Forth file. Usually, the first file you compile should be bb4wforth.f or an adaptation of it (perhaps with the 'welcome' message deleted).

Code:
PROC_forth_run(word$, par%) 

Run a compiled Forth subroutine, with a single integer parameter. You can pass multiple parameters by CALLing _forth_run instead:

Code:
CALL _forth_run, word$, par1%, par2%, .... 

Note: If any errors occur (for example the dictionary isn't big enough, or you attempt to divide-by-zero) you won't get any friendly messages, BB4W will just crash catastrophically! Forth code is best tested in BB4Wforth first.

Here's a sample program using the library:

Code:
INSTALL @lib$+"forthlib"
PROC_forth_init(100000)
PROC_forth_compile(@dir$+"bb4wforth.f")
PROC_forth_compile(@dir$+"hanoix.f")
PROC_forth_run("TOWERS",12) 

Richard.
User IP Logged

Pages: 1  Reply Notify Send Topic Print
« Previous Topic | Next Topic »


New Monthly Ad-Free Plan!

$6.99 Gets 50,000 Ad-Free Pageviews!
| Free Shoutboxes | Hookah |

This Board Hosted For FREE By Conforums ©
Get Your Own Free Message Board!