Running bif-c

Okay, now you've got bif-c compiled. So what do you do with it?

Weeellll, ...... yeah, that's a long story. Bif-C is not standard FORTH. It's not even a proper fig (Forth Interest Group) FORTH. And it's still pretty buggy.

(Some day, I want to write a 6800 emulator to run Dave Lion's 6800 model fig-FORTH. There is at least one emulator available, but I couldn't figure out the disk access.)

But you can write simple definitions and use it as a post-fix integer calculator.

First, you can run it in the directory you compiled it in with

./bif-c -h

to show the command-line options. At present, there are two sets of options, disk image and memory size.

Disk Image Options

The disk image options look something like this:

./bif-c -d0 -ro TOOLS.G00.disk -d1 example.disk

This specifies two of the disk images I've provided as the first two drives, the first one read-only. You can't do much with them yet, but I'm working on that.

(The tools directory contains some simple tools to generate or extend disk images, if you are interested in such things.)

(Oh. You'll see a lot of debugging information when it starts up. Don't worry about that.)

Memory Options

The default memory size is pretty limited. Eventually, I want to provide better control of stack size and such, but for now you can get a megabyte of memory space by doing something like this at the shell command line:

./bif-c -m 1M

Not that you will use a megabyte just yet. But you can check the startup debug information to see whether you actually got your megabyte. >8-*

You can combine the two sets of options, as well:

./bif-c -d0 -ro TOOLS.G00.disk -d1 example.disk -m 1M

Quitting Bif-C

Exit bif-c by typing

  1. BYE

at the bif-c command line.

Case Sensitivity in Bif-C

Parsing is case sensitive at present, and the pre-defined vocabulary is almost all upper-case. So, you can define, say, "TOTAL" and "total", and the definitions are separate. (I'm not sure if this is good or bad. It's a bit inconvenient.) And you can define "do" and it doesn't conflict with the FORTH counted loop initiator, "DO", except in your head. 8-<

At any rate, you probably want to use your caps-lock key to avoid headaches.

Loading Code in Bif-C

The most effective way of getting code into bif-c at present is to use the low-tech copy-and-paste approach. The file tools_stdio.text has some useful words defined, including DUMP (to dump the contents of memory) and LIST (to list the contents of a disk "screen"). You can open that file with a text editor, copy it, and paste the contents in at the bif-c command line.

Looking at the code might be enlightening, also. (Or maybe not. :/)

Bif-C Manual

I'm planning to convert the original BIF-6809 manual, but that is also a work in progress. It is probably more useful than not, at any rate. Find it in the BIF directory, in the file BIFDOC.TXT.

Simple Examples

Post-fix Integer Calculator

  1. 123 654 + .

777 OK

  1. 256 256 256 * * .

16777216 OK

  1. 31415927 3 * 10000000 / .

9 OK

  1. 31415927 3 * 10000000 MOD .
4247781 OK
  1. 31415927 3 10000000 */MOD . .
9 4247781 OK

Hello, World!

  1. : HELLO ." Hello, Waldo!" ;

OK

(Watch the spaces after the quotes carefully!) Execute it with

  1. HELLO

Hello, Waldo! OK

Counting to Ten

  1. : 10COUNTING 10 0 DO SPACE I . LOOP ;

OK

  1. 10COUNTING
0 1 2 3 4 5 6 7 8 9 OK

Mistakes

FORGET doesn't work yet, so if you make a mistake, exit ("BYE") and start over. Use copy-paste, and keep a text editor window open and handy.

Counting to a Specified Number

  1. : COUNTING 0 DO SPACE I . LOOP ;

OK

  1. 20 COUNTING
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 OK

Something More Advanced?

A lot of what you'll find elsewhere won't work. There's a lot that I still have to fix and a lot I just really don't intend to implement here.

If you want a usable FORTH, there are many available. You can search for them with your favorite search engine. (gforth is one that works pretty well for me, and it's pretty close to the standard, but there are plenty of others.)

But some of the source code you'll find elsewhere will work, maybe with a little bit of modification.

This should help you get started.

Thanks for checking bif-c out.