BBC BASIC for Windows
« New FORTHLIB library »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:32pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: New FORTHLIB library  (Read 853 times)
admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx New FORTHLIB library
« Thread started on: Oct 17th, 2009, 10:26am »

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  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls