[colorforth] about colorforth
- Subject: [colorforth] about colorforth
- From: Mark Slicker <maslicke@xxxxxxxxxxx>
- Date: Thu, 9 May 2002 22:56:56 -0400 (EDT)
On Thu, 9 May 2002, CrowKiller wrote:
> (This post was originally posted on usenet on comp.lang.forth)
>
> Hi!
>
> colorForth is the Forth implementation that inspire me the most
> among all the others, and I want to be able to work with it on
> my own and to implemement it myself. But I dont quite
> understand how it works perfectly, so here's my questions,
> or let me start by sprutting what I understood so far,
> feel urged (ys, urged!) to correct me if I'm lost:
>
> >From what I understand, there's aside from stacks and all,
> a "Red word table", a compiled operational dictionary and
> tokenized source code.
>
> -A red word table entry is defined as two 32 bits cells
> arranged like: (Red word, address) The words are searched
> in even cell, and the address of the start of that word in the
> dictionary is the odd cell of the couple. It's searched
> backwards and is different each time you change the order
> of the loaded blocks.
>
Actually these are seperate tables, they are not interleaved See
in color.asm, the macro dictionary (macro0,macro2), and
the forth dictionary (forth0,forth2).
> -The dictionary is made of compiled x18 virtual machine
> instructions with simple optimizations included, like "drop dup"
> removed, tail recursion, litterals implemented, etc. Each entry
> look like this: (undefined length machine code, ret) where
> the initial "call r/m32" calls the very first opcode of this
> sequence. the ret get us to the previous word. In the machine
> code part of the word, there can be calls made to other words.
> call/ret is the thing here, so this forth is subroutine threaded.
>
This sounds about right. Also 'word ;' compiles to a jump intruction which
jumps to the definition of 'word', so a definition might not conclude with
a ret instruction. Also definitions may have multiple entry points. Here
is one example from COLOR.COM:
: abs dup negate
: max less if swap then drop ;
Definions may also have multiple exit points. So really there is no
pattern to a definition, it is just a machine language sequence.
> -The source is tokenized with meaning on how to construct
> those two prime components. The web page is pretty clear on
> that matter. Only the yellow-green transistion puzzles me:
> the source code isnt changed to "green", only at the end
> of the yellow word the number on stack is compiled as a
> green number (litteral instruction). is this it?
>
Right. This is a method of documenting how constants are computed.
> What I want to know is:
> - First, am I right? lol
>
> - Why does Chuck used the "143o shl 7" type
> of instruction encoding in his source?? I have
> NASM and I'm screwed lol ;p (dont want to
> resort looking at color.com in hex viewer)
>
These are assembler expressions, they construct the huffman
representation, character by character, of the word part of a dictionary
entry. See http://www.colorforth.com/chars.html .
> - How do I implement in macros the instruction "*+"
> (multiply step) and the others that are not defined at
> http://www.colorforth.com/forth.html??? (btw I wrote
> some NASM macros and the whole x18 primitive set
> compiled end to end into a .bin file only takes 171 bytes,
> but some instructions are only approximations and *+ is
> totally missing.)
>
In colorForth (based on the description at
http://www.colorforth.com/X18.html):
: +* 1 ? if over + then ;
But this is just forth not machine code. The machine code would be similar
but probably more efficient.
> I want to implement this system in a (boot)sector or 2, using
> standard 80x25 colored text framebuffer and STANDARD
> QWERTY keyboard layout (!!!, at least to start lol) with the
> keyboard i/o entirely coded in asm, like in colorForth. What
> I need to get going is a proper understanding (or explanation)
> of this system.I also looked upon the AHA system by Jeff Fox,
> wich seemed great, but I'm also not sure at 100% of how its
> working, although the explicative flowcharts on
> www.ultratechnology.com are really great.
>
Feel free to ask questions, I've managed to figure out pretty much the
whole system, except for multitasking which I vaguely understand. It
is really quite simple to understand compared to something like linux.
There is a small amount of source to read and pretty much every piece of
code is used. I'm not too familar with AHA, but Jeff sometimes visits this
list.
Mark
------------------------
To Unsubscribe from this list, send mail to Mdaemon@xxxxxxxxxxxxxxxxxx with:
unsubscribe ColorForth
as the first and only line within the message body
Problems - List-Admin@xxxxxxxxxxxxxxxxxx
Main ColorForth site - http://www.colorforth.com