 |
 |
Here's a native FORTH for MacOS X
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2000
Status:
Offline
|
|
I've been writing a FORTH-compiler called D. FORTH is a stack-based, interactively compiling language.
I'd be glad if you would have a look at it and tell me what you think.
D is a work in progress, if I get enough feedback I'll continue to document it.
Thank you,
Daniel
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jan 2001
Location: Sacramento, CA, US
Status:
Offline
|
|
I love (and miss) Forth...this looks like fun. Guess that makes me a geek!  Thanks.
Mark
|
|
TiBook 667MHz/512Mb/30Gb/DVD
Macs for work and play; Windows for...work and play. Oh. Never mind. Whatever.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2000
Status:
Offline
|
|
mrtaber, how do you came to FORTH? Could you tell about your experience with FORTH? I'm interested because most people never heard about FORTH -- to bad.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Cupertino, CA
Status:
Offline
|
|
Originally posted by danengel:
<STRONG>I've been writing a FORTH-compiler called D. FORTH is a stack-based, interactively compiling language.
I'd be glad if you would have a look at it and tell me what you think.
D is a work in progress, if I get enough feedback I'll continue to document it.
Thank you,
Daniel</STRONG>
I actually was just playing with it last night, it seems work quite nicely.
I wanted to add a primitive (roll) that is part of the IEEE1275 spec, but not ANSI forth. I implemented what I thought was correct on kernel.s, but I think I might have malformed the function header. I assume the first entry is a chain to other primtive words, and the scf (? I don't have the source near me) refers to the cache states. Roll moves a lot of the stack, so for the time being I had planed on just implementing the assembly to deal with the actual stack, and not the cache values. I assume I would use scf00 and the first function subroutine pointer, is that correct? I could probably also use scf10 since the first value is destroyed (the stack count drops by one), but the semantics are implicit and I did not really feel like digging through the dispatch code when I was doing this at 3 AM ;-)
Louis
Louis
|
|
Louis Gerbarg
Darwin Developer
These are my views, and not the views of my employer.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2000
Status:
Offline
|
|
Igerbarg,
The header would look like this (freehand composition, not tested):
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
.data
roll_l: .long <word before roll>_l
.byte explained | leaf, <font color = blue>0</font>, <font color = blue>0</font>, scf10
.long <font color = blue>0</font>, roll_1, <font color = blue>0</font>, <font color = blue>0</font>
.asciz <font color = red>"roll"</font>
.align <font color = blue>2</font>
.asciz <font color = red>"( xu xu-<font color = blue>1</font> ... x0 u -- xu-<font color = blue>1</font> ... x0 xu )"</font>
.align <font color = blue>2</font>
.text
roll_1: ; code starts here
; ...
blr
</font>[/code]
It's a good idea not to include the cache because that would be horribly complicated.
I didn't include 'roll' in the first place because 1) it looked shuffles a lot of memory cells around and 2) I have no use for it. Can you tell me where it's necessary? Anyway, it's a good exercise to implement it
-- Daniel
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Cupertino, CA
Status:
Offline
|
|
Originally posted by danengel:
<STRONG>Igerbarg,
The header would look like this (freehand composition, not tested):
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre>& amp;lt;font size=1 face=courier>
.data
roll_l: .long <word before roll>_l
.byte explained | leaf, <font color = blue>0</font>, <font color = blue>0</font>, scf10
.long <font color = blue>0</font>, roll_1, <font color = blue>0</font>, <font color = blue>0</font>
.asciz <font color = red>"roll"</font>
.align <font color = blue>2</font>
.asciz <font color = red>"( xu xu-<font color = blue>1</font> ... x0 u -- xu-<font color = blue>1</font> ... x0 xu )"</font>
.align <font color = blue>2</font>
.text
roll_1: ; code starts here
; ...
blr
</font></pre><HR></BLOCKQUOTE>
It's a good idea not to include the cache because that would be horribly complicated.
I didn't include 'roll' in the first place because 1) it looked shuffles a lot of memory cells around and 2) I have no use for it. Can you tell me where it's necessary? Anyway, it's a good exercise to implement it
-- Daniel</STRONG>
Yeah, the cached versions are hideous, since you have to in essence special case for whether or not the are of affect is entirely within the cache or not. You can probably implement it through a small common subroutine you share amoune all version that basicly does the noncached version on a given range of the stack, and then have the cached version call that once they pass outside their area of effect (with a special case subroutine for when the roll is entirely cached, you can actually have it jump into swap and rot's code with some slight refactoring, but it is almost certainly not worth it).
I actually have what I think is a complete implementation, there was an error with my header based on what you did. I'll take a look at it when I am back at my machine.
As to why one would want it... well you can make the argument that it is the only convenient stack mangling function thats range of effect is more than 6 or so away from top, and even at 6 their effectiveness is significantly impaired. I don't really buy into that two much though, because in practice I have never needed for those reasons.
The reason I want it is that I have some code that uses it.. It almost certainly simpler to implement the word than to refactor the code.
Louis
|
|
Louis Gerbarg
Darwin Developer
These are my views, and not the views of my employer.
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Oct 2000
Status:
Offline
|
|
Louis,
I'd like to see your version of 'roll'. Although I don't think it's a frequently used word, building it into D doesn't hurt.
-- Daniel
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|