"Hugh Aguilar" <
hughag...@yahoo.com> wrote in message
news:98bd4be2-44ac-42d1...@l24g2000yqm.googlegroups.com...
> On Dec 3, 6:45 pm, "Rod Pemberton" <do_not_h...@noavailemail.cmm>
> wrote:
> > I don't have a problem with HLA as long as no one claims it's actually
> > an x86 assembler. It's not x86 assembly. It's not even assembly.
>
> HLA is an x86 assembler.
Argh! "Run to the hills ..."
> I'm implementing low-level Forth words
> such as DUP and SWAP in assembly language
I use C for my primitives. That's ANSI standard C. While C has changed,
ANSI C hasn't and is still compileable by the modern C compilers.
Roughly (I have some development related code ...) 37 pre-compiled
primitives or low-level words, 39 pre-compiled high-level words, and (NEW!)
30 Forth words entirely as ASCII text. The words aren't new, but parsing
them using the other 37+39 words is. I finally fixed the C side code enough
that I could migrate them out and did so. Anyway, if the implemented words
needed for ANS were ANS compliant (they aren't), that would leave another
122 words needed to implement the ANS Core and ANS Core extentsion sets. I
hope to end up with mainly just my primitives in C, but that'll require some
creativity since the initial setup words, inner and outer interpreter, and
parsing words are now needed to parse. I.e., I'll need to create minimal or
dummy versions, so I can move out as much code as possible in pure text
Forth. Without comments, I'd say 1700 lines of C. That's quite a bit
larger than it was recently. I reimplemented the entire dictionary as
pre-compiled C with dictionary headers. The headers in C added quite a bit
of lines of code. Previously, I used a C function to compile headers into
the dictionary and link to the correct compiled definitions. That took much
less code, but was dependent on a C function. If I eliminate the dictionary
(high- and low-level), the C code that does the work is maybe 100 lines,
most of which is #defines or executed once ... I've named my ITC inner
interpreter NEXT (whether that is correct historical usage or not). In
terms of lines of C, NEXT is 12. ENTER is 2. EXECUTE is 5. EXIT is 1.
DOCON is 2. DOVAR is 1. DODOES is 2. etc.
> I have for OOP and thunks and generators within this context?
None.
> This is pretty basic assembly language --- implementing DUP
> and SWAP isn't exactly rocket science.
As mentioned before, they can very simple, or be more complicated depending
on how you implemented your Forth system. The quantity of stack items
cached in registers, the quantity of stacks, etc all affect your
implementation. E.g., if you have two stacks, most Forth's do, one for data
or parameter stack, and one for control-flow or return stack, then you'll
need code to switch stacks. This can be done with XCHG, or other
instructions depending on where your two stack pointers are located. E.g.,
if you have the top two stack items in registers, you could use XCHG. If
you have the top one stack item in register, you'll need some other
sequence. If you don't cache, then PUSH and POP will do.
> You have stated on comp.lang.forth that you are writing a Forth in C,
> and I have told you several times that this is an incredibly bad idea.
Why?
1) I'm not implementing an ANS Forth (at least, not yet ...). Mine is an
ITC Forth. C can do that. It works (or seems to so far ...). It's mostly
fig-Forth like, but has some features from other Forths or changes which are
better choices based on my programming experiences, e.g., true as -1, CELLS,
etc.
2) I don't need your non-approved by ISO memory words which apparently
aren't compatible with GForth (GNU Forth) in GCC syntax C. I'm not sure how
or where I'd use them anyway. Nor am I familiar with what limitations a
Forth that couldn't implement them would have. It seemed that those adept
in Forth on c.l.f. were questioning their purpose too ... If they don't
understand what they are for, how would I?
3) While Forth's syntax and use of a stack are poor choices, IMO, ITC code,
Forth's dictionary, ability to compile words, Forth's inner and outer
interpreter's, etc are very effective given their minimalism. They could be
re-purposed to other language interpreter's, and maybe with far greater
influence than Forth has had.
I posted a list of implemented words a while back on c.l.f. I've been
working on other issues with it, so not many more words have been added
since then. Do you want to see my list of implemented words? I broke a
couple of them when eliminating some of the C side code, but I'll re-fix
them, e.g., I broke DOES> since it messed with DP which was being sync'd by
the C code.
> C-based Forth systems are inherently under-powered and over-
> complicated.
AISI, if my system is underpowered, it's underpowered because ITC is
underpowered or because fig-Forth is underpowered or both. As I stated
above, there is not much actual C. Each of the primitives has a tiny bit.
Pre-compiled words are lists of addresses. Since it's still being
developed, I do have 3 to 6 "primitives" which shouldn't be implemented as
primitives ... However, I haven't rewritten them as Forth yet. I'm working
on it, but it is delayed until I fix the other issues.
> Believe me, I know a lot more about Forth compiler-
> writing than you do.
Since this is my first ever, I'd say that is probably true. But, I'm adept
with C (and GP x86 instructions). I've implemented the ITC interpreter in
C. I'm not coding a compiler for Forth in C. After implementing an ITC
interpreter, it's just a matter of implementing a Forth word set either as
arrays of addresses (pre-compiled high-level words), as primitives
(pre-compiled low-level words in C), or as text (for parsing). I've already
implemented roughly 136 words. Does my interpreter have a ways to go? Yes,
quite a bit, IMO. I've still got too much C side code. But, it's
progressively getting there, to my goals. As mentioned above, I broke a few
words. I also converted to line-oriented parsing from word-by-word. That
introduced a few more problems. I don't "see" any of these as something
critical. They just require my time.
> I have also told you several times that it is a
> good idea to write at least one small application
> in Forth before delving into Forth compiler-writing,
> in order to first learn the rudiments of the language
> from a user's perspective.
That may introduce some inherent bias. ISTM, that Charles Moore followed a
path very similar to the process I'm going through, but for different
machines and languages. Many of the "mystery comments" one reads about
Forth from CM, CH Ting, etc make sense now.
> The world is already full of people who claim to be
> great experts at Forth because they have written
> an interpreter for Forth
You mean Anton Ertl. Something seriously gets lost when he translates
to/from English. He seems to think if one does not have a degree then one
is not smart or can't understand what he knows, or he just doesn't like
justifying his claims. IRL, I know a few PHDs from HS who aren't as smart
as I am. Lack of a degree doesn't affect your intellect. It will affect
your pocket book and your exposure to experiences for which a degree is
needed, i.e., guys paid to drive taxi cabs are not being paid to solve
programming problems, foregone experiences ...
> (usually in C, but it has even been done in Perl)
...
> [...] but who in the next breath will state that
> Forth is grossly inefficient, ugly and unreadable,
Well, that is true. At least, that's my belief about the syntax chosen for
Forth. That belief has been strengthened through this process of
implementing an interpreter for Forth. Fortunately, one can discard the
Forth syntax, because there is none, and implement their own. But, no one
seems to do that ... Or, perhaps they did it too much and still called it
"Forth", and so perhaps that's why Forth got labeled "write once" ...
> [...] completely lacking in HLL features
It's as "turing complete" as any non-turing complete language
(all of them) can be. DOES> is definately a OOP like feature.
> [...] and generally worthless for application programming
I've not used it for that, but ISTM that many Forth programmers don't use
Forth in an advanced way. They prefer stack programming. Yet, it is
perfectly fine for using variables in memory. It is true that other
languages, like C, take care of many things for the programmer that Forth
does not.
> [...] --- you are well on your way toward joining their ranks --- I
> can tell you upfront that nobody will care; there is no point in going
> through all of this effort just to make a negative contribution to Forth.
Yes, I agree that there are many things for which there is "no point", i.e.,
"re-inventing the wheel". This evolved out of another project. But, if I
needed the approval of other people, I never would've done anything in my
life. I certainly wouldn't have chosen to write a Forth interpreter with so
many of them out there, i.e., I agree there is "no point" from that
perspective. How am I to know if I'm going to have time to complete it?
How am I to know if I'll release it someday or sell it or if it'll become
part of the property of a company or if I'll keep it private? How am I to
know if it'll be used if released to the public? There are too many
unknowns for you to sit around and not do something because there is "no
point". At some point, you must do something that has a point, even if it
leads you to a "no point" situation.
> You currently know as much about HLA as you do about Forth,
> which is something close to nothing.
I've seen enough of it's syntax. I know it's not an assembler.
> All of you guys' responses to my question about the MOV(dummy,[ebp]);
> instruction have been comparable to the above --- informed by
> ignorance, driven by arrogance and successful at nothing! I asked a
> straight question about how to assemble a particular addressing-mode
> in HLA, and I never got a straight answer --- if you guys are in doubt
> about the answer to any question that I may ask, please don't hesitate
> to shut the hell up.
Did I state that you were likely missing a size related keyword? (yes)
Did Nathan post the correct sequence? (yes)
> I'm not championing HLA; I'm still a complete novice at it --- [...]
> whether this was a good choice or a bad choice, isn't really
> anybody's business except my own.
Apparently, you made your choice. So, why did you take offense to some of
us not liking HLA? But, if you don't need "OOP and thunks and generators
within this context," as you stated, why not use a real assembler, without
that stuff, perhaps NASM?
Rod Pemberton