Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reverse Engineering - Are there any helpful tools?

33 views
Skip to first unread message

Friederike Löwe

unread,
Sep 28, 2009, 5:10:53 AM9/28/09
to
Hi there.
I am searching for a Tool what can help me to understand some Forth-code
which already exists.
My ideas are either structuring the code by myself or let them be by an
editor.
I thougt about some kind of a tree-structure-tool so I can visualize the
words and its dependings. Of course it would be great if the basic words
would be linked to each other so I would not have to build them twice.

Another great possibility would be to have an editor which is able to
recognize the colon-definitions and variables and so on and which can
link the words in the higher context to the definitions so it would be
possible to jump between the higher code and the words to understand
what they migth do.
Does anyone have an idea to help me? I hope that I did describe my
problem well...

Best regards,
Rike

m_l_g3

unread,
Sep 28, 2009, 3:20:41 PM9/28/09
to
1) Far Manager (works under both Win32 and Linux Wine), Alt-F7 to
search in files,
F2 (menu) if you need to change directories fast

The same may be achieved with the linux mc, but I prefer Far.

2. SEE <name>
it's the standard decompiler; hopefully on your system it shows the
Forth source rather than assembly.

3. whereused <name>
this word reports occurences of <name> in the code of other
definitions. probably on one of the systems it was called REF or REFS.
I suspect that you will have to implement it yourself, which is
feasible in the case that your system uses threaded code.


In addition, if your system prints the stack trace, you may modify the
code to create an exception and examine the stack trace.

Friederike Löwe wrote:
> Hi there.
> I am searching for a Tool what can help me to understand some Forth-code
> which already exists.
> My ideas are either structuring the code by myself or let them be by an
> editor.
> I thougt about some kind of a tree-structure-tool so I can visualize the
> words and its dependings. Of course it would be great if the basic words
> would be linked to each other so I would not have to build them twice.
>
> Another great possibility would be to have an editor which is able to
> recognize the colon-definitions and variables and so on and which can
> link the words in the higher context to the definitions so it would be
> possible to jump between the higher code and the words to understand
> what they migth do.

F-PC and probably Win32Forth used to have stuff like that

John Passaniti

unread,
Sep 28, 2009, 4:50:11 PM9/28/09
to
On Sep 28, 5:10 am, Friederike Löwe <p...@friederike-loewe.de> wrote:
> I am searching for a Tool what can help me to understand some Forth-code
> which already exists.
> My ideas are either structuring the code by myself or let them be by an
> editor.
> I thougt about some kind of a tree-structure-tool so I can visualize the
> words and its dependings. Of course it would be great if the basic words
> would be linked to each other so I would not have to build them twice.

One of my favorite tools to visualize the relationships and
dependencies in software is to transform the code into the DOT
language and use the dot graph renderer in Graphviz (http://
www.graphviz.org) to visualize it. You can get really fancy with the
DOT language, but I keep it simple and stupid.

I've never done this with Forth source, but the basic approach would
be the same. When I've done this with C code, I avoid dealing with
the C source at all and use the C compiler to generate assembly
language code. Then, I scan through the assembly language code and
transform interesting relationships in the code to DOT. So for
example:

void test(void) { a(); b(); }

might be transformed into this assembly language:

test:
call a
jmp b

Then, slapping together some script (I usually use Perl for simple
stuff), you extract labels, calls, and jumps. Depending on how
complex the assembly language is, you might have to massage the data a
bit more, but typically we're talking about a handful of lines of
script to generate DOT code like this:

digragh G {
test -> a;
test -> b;
}

For Forth, the same basic idea could be applied. Since the only thing
that can reliably interpret Forth source is Fort, you could extend the
compiler to output DOT code as a side effect of compiling Forth
source. Or, perhaps more simply you could look at how "SEE" is
implemented in your Forth, and hack it to walk your top-level word
recursively down to primitives, outputting DOT code instead.

flash

unread,
Sep 29, 2009, 9:35:25 AM9/29/09
to
I think , the only one you need ,is
SEE

Friederike Löwe

unread,
Sep 30, 2009, 10:46:52 AM9/30/09
to
Thank you very much for your ideas! They all help me a little... :)
I'll do my very best.

Friederike Löwe

unread,
Oct 2, 2009, 9:04:24 AM10/2/09
to
I thought I had seen this possibility before - just didn't recognize how
mighty it might be. But now I see that there is no word "see" in my
system. How can I implement it?

Dennis Ruffer

unread,
Oct 2, 2009, 10:03:31 AM10/2/09
to

Check to see if WORDS exists. That might give you a start.

DaR

heytwo

unread,
Oct 2, 2009, 4:16:32 PM10/2/09
to

Wasting time . Dont try to read others code .

Imagine the task ,
learn Forth ,
create it yourself.
Then flood it so you can copyright it .

Friederike Löwe

unread,
Oct 5, 2009, 4:47:59 AM10/5/09
to
Sorry if I seam stupid, but how could a list of words give me a start to
decompile words?


Dennis Ruffer schrieb:

Jonah Thomas

unread,
Oct 5, 2009, 10:16:10 AM10/5/09
to
Friederike Löwe <po...@friederike-loewe.de> wrote:
> Dennis Ruffer schrieb:
> > Friederike Löwe <p...@friederike-loewe.de> wrote:

> >> I thought I had seen this possibility before - just didn't
> >recognize how> mighty it might be. But now I see that there is no
> >word "see" in my> system. How can I implement it?
> >
> > Check to see if WORDS exists. That might give you a start.

> Sorry if I seam stupid, but how could a list of words give me a start
> to decompile words?

You are obviously using a Forth which is very poorly documented, so you
don't know whether there is a word SEE . If you look at the list of
words that are there, you might see candidates that might do SEE . VIEW
? DECOMPILE ? If you see something with a suggestive name and you don't
know what else it does, you might try it out and see what happens. If
you're a little bit paranoid you might want to try that with your mass
storage disconnected or read-only.

If you find that you have DUMP then that will give you a hex dump from
memory. You probably don't want to look at a hex dump and figure out how
headers work and then look at the code that way. But if you find
yourself writing SEE from scratch that's one way to start.

If you don't have WORDS see whether you have VLIST . That is a name for
WORDS that people used to use before they noticed that WORDS was such a
better name esthetically.

Dennis Ruffer

unread,
Oct 5, 2009, 10:10:58 AM10/5/09
to

The list of words can give clues as to how the Forth is built and
gives you things to try. It takes a little bit of prior knowledge
about how Forth, in general, is organized, but it's a good place to
start when faced with a new implementation.

Try executing each word and see what happens. ;)

DaR

Aleksej Saushev

unread,
Oct 6, 2009, 3:26:05 AM10/6/09
to
Dennis Ruffer <dru...@worldnet.att.net> writes:

> The list of words can give clues as to how the Forth is built and
> gives you things to try. It takes a little bit of prior knowledge
> about how Forth, in general, is organized, but it's a good place to
> start when faced with a new implementation.
>
> Try executing each word and see what happens. ;)

How does this help?

Consider pForth. It lists words with names

FP.APPEND
OB.STATS?
(S+@)
TRACE-STATE-2
SM
XX
HISTORY#
$SDAD.LINE
;;;;

How does running any of these help understanding the system?

Compare that to Common Lisp (SBCL in this case):

* (documentation 'car 'function)

"Return the 1st object in a list."
* (documentation 'function 'function)

"FUNCTION name

Return the lexically apparent definition of the function NAME. NAME may also
be a lambda expression."
* (documentation '*standard-input* 'variable)

"default input stream"


Here's what ECL does:

> (documentation 'function 'function)

"Special Form in COMMON-LISP package:
Syntax: (function x) | #'x

If X is a lambda expression, creates and returns a lexical closure of X in the
current lexical environment. If X is a symbol that names a function, returns
that function definition.
"
> (documentation '*standard-input* 'variable)

"Variable in COMMON-LISP package:
The default input stream used by the ECL reader. The initial value is a
synonym stream to *TERMINAL-IO*.
"
> (documentation 'car 'function)

"Function in COMMON-LISP package:
Syntax: (X)

Returns the car of X if X is a cons. Returns NIL if X is NIL.
"


It is easy to see from above that Forth is inferior to interactive
systems of 1980s style.

Just in case you don't notice, 1980s are over.


--
HE CE3OH...

Jonah Thomas

unread,
Oct 6, 2009, 7:57:40 AM10/6/09
to
Aleksej Saushev <as...@inbox.ru> wrote:
> Dennis Ruffer <dru...@worldnet.att.net> writes:
>
> > The list of words can give clues as to how the Forth is built and
> > gives you things to try. It takes a little bit of prior knowledge
> > about how Forth, in general, is organized, but it's a good place to
> > start when faced with a new implementation.
> >
> > Try executing each word and see what happens. ;)
>
> How does this help?
>
> Consider pForth. It lists words with names
>
> FP.APPEND
> OB.STATS?
> (S+@)
> TRACE-STATE-2
> SM
> XX
> HISTORY#
> $SDAD.LINE
> ;;;;
>
> How does running any of these help understanding the system?

Clearly, you would do better if you already knew Forth.

"When you've seen one Forth, then you've seen one Forth."

If your Forth system is inadequately documented, and you need better,
perhaps you should try a different Forth. Many Forth systems give you a
SEE command that decompiles some (maybe most) words for you. If you are
using a Forth with a fancy optimiser, it might not be able to get Forth
code back from its optimised code. In that case they might have an
unoptimised version you can use SEE on.

Many Forth systems give you a VIEW command that show you the source code
for most words. Some Forth developers try to keep the source for some of
their code semi-secret so that it will not be too easy for competitors
to just copy it and change it and market it as their own. Sometimes they
provide SEE for the words that are not otherwise documented, so that if
you need to understand or change some specific feature you can do so,
but it's a big enough effort that you will probably not reverse-engineer
the whole system.

Dennis Ruffer

unread,
Oct 6, 2009, 8:09:22 AM10/6/09
to
On Oct 6, 6:57 am, Jonah Thomas <jethom...@gmail.com> wrote:
> Aleksej Saushev <a...@inbox.ru> wrote:

Beyond what Jonah said, I don't see the point of Aleksej's comment.
It's pointless to compare Forth to Lisp, and doesn't even begin to
address Friederike's question. However, I suspect that it would be
easier to reverse engineer pForth than it would to do the same to
Steel Bank Common Lisp.

DaR

Stephen Pelc

unread,
Oct 6, 2009, 9:28:34 AM10/6/09
to

How much of the source code do you have?

Which Forth host does it use? Do you have access to the
host Forth? What threading model does it use?

There used to be various tools at www.forth.org for building call
trees and cross-references, but someone else will have to give
you a definitive pointer.

The really important part in all this is to document all the
source code and have accurate stack comments for every word.

Stephen


--
Stephen Pelc, steph...@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads

Ian Osgood

unread,
Oct 6, 2009, 12:02:07 PM10/6/09
to
On Sep 28, 12:20 pm, m_l_g3 <m_l...@yahoo.com> wrote:
> 1) Far Manager (works under both Win32 and Linux Wine), Alt-F7 to
> search in files,
> F2 (menu) if you need to change directories fast
>
> The same may be achieved with the linux mc, but I prefer Far.
>
> 2. SEE <name>
> it's the standard decompiler; hopefully on your system it shows the
> Forth source rather than assembly.
>
> 3. whereused <name>
> this word reports occurences of <name> in the code of other
> definitions. probably on one of the systems it was called REF or REFS.
> I suspect that you will have to implement it yourself, which is
> feasible in the case that your system uses threaded code.

I have often wanted a cross-reference lookup like "whereused" when
learning a new language, vocabulary, or Forth system. Often the
easiest and most reliable way to determine the contract of a word is
to see how it is used by the language and library implementors.

How many Forth systems capable of SEE or VIEW have the inverse
WHEREUSED? and what is it called on those systems? How hard would it
be to implement it on GNU Forth?

Ian

P.S. Don't disparage folks who value context sensitive language/
library documentation. A language will only survive if there is a
steady source of new users into its community. Anything which aids
the new user will help the language survive.

Anton Ertl

unread,
Oct 6, 2009, 12:33:50 PM10/6/09
to
Ian Osgood <ia...@quirkster.com> writes:
>How many Forth systems capable of SEE or VIEW have the inverse
>WHEREUSED? and what is it called on those systems? How hard would it
>be to implement it on GNU Forth?

My editor (Emacs) does this for me (see below), and I'm sure other
capable editors can do that, too, so I see little benefit from
additional support in Forth.

With Emacs it works like this:

First you create a TAGS file with

gforth etags.fs app.fs -e bye #your application loader is app.fs

Then, in Emacs you do the following:

For VIEW: Type M-. and then the word you are interested in (a default
is supplied from the word the cursor is on). You can go back to where
you were with M-*.

For WHEREUSED: Type M-x tags-search and the name of the word you are
interested in. After the first hit you can continue with M-,. This
will also find the definition and words that have the same name.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2009: http://www.euroforth.org/ef09/

Elizabeth D Rather

unread,
Oct 6, 2009, 1:01:33 PM10/6/09
to
Ian Osgood wrote:
...

> I have often wanted a cross-reference lookup like "whereused" when
> learning a new language, vocabulary, or Forth system. Often the
> easiest and most reliable way to determine the contract of a word is
> to see how it is used by the language and library implementors.
>
> How many Forth systems capable of SEE or VIEW have the inverse
> WHEREUSED? and what is it called on those systems? How hard would it
> be to implement it on GNU Forth?

In SwiftForth, double-clicking any word in the command window will
select it. The right mouse button presents a menu of operations you can
apply to a selected word:
� LOCATE displays the source for any word defined in your current scope
by doubleclicking the word. If the source is not present (e.g. you are
running a turnkey but do not have the source files that generated it) or
if the word you are trying to LOCATE was defined interactively in the
command window, you will see the error message �Source file not available.�
� EDIT launches or switches to your linked editor positioned
at the source for the word (if it�s available).
� SEE disassembles the word.
� Cross Ref generates a cross-reference for the word.
� Execute executes the word, just as though you had typed it and pressed
Enter.
� Copy copies it to the clipboard.
� Paste pastes whatever is currently in the clipboard at the current
cursor position in the command window.

MostL of these options have command-line equivalents. For a
cross-reference, you can type:

WHERE <name> or WH <name> (a shortcut)

LOCATE, EDIT, and SEE are other command-line equivalents. We work very
hard to supply user conveniences of this sort!

Cheers,
Elizabeth

--
==================================================
Elizabeth D. Rather (US & Canada) 800-55-FORTH
FORTH Inc. +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

Aleksej Saushev

unread,
Oct 6, 2009, 1:35:22 PM10/6/09
to
Dennis Ruffer <dru...@worldnet.att.net> writes:

> On Oct 6, 6:57О©╫am, Jonah Thomas <jethom...@gmail.com> wrote:
>> Aleksej Saushev <a...@inbox.ru> wrote:
>> > Dennis Ruffer <druf...@worldnet.att.net> writes:
>>
>> > > The list of words can give clues as to how the Forth is built and

>> > > gives you things to try. О©╫It takes a little bit of prior knowledge

>> > X in the current lexical environment. О©╫If X is a symbol that names a


>> > function, returns that function definition.
>> > "
>> > > (documentation '*standard-input* 'variable)
>>
>> > "Variable in COMMON-LISP package:

>> > The default input stream used by the ECL reader. О©╫The initial value is


>> > a synonym stream to *TERMINAL-IO*.
>> > "
>> > > (documentation 'car 'function)
>>
>> > "Function in COMMON-LISP package:
>> > Syntax: (X)
>>

>> > Returns the car of X if X is a cons. О©╫Returns NIL if X is NIL.


>> > "
>>
>> > It is easy to see from above that Forth is inferior to interactive
>> > systems of 1980s style.
>>
>> > Just in case you don't notice, 1980s are over.
>>
>> "When you've seen one Forth, then you've seen one Forth."
>>
>> If your Forth system is inadequately documented, and you need better,
>> perhaps you should try a different Forth. Many Forth systems give you a
>> SEE command that decompiles some (maybe most) words for you. If you are
>> using a Forth with a fancy optimiser, it might not be able to get Forth
>> code back from its optimised code. In that case they might have an
>> unoptimised version you can use SEE on.
>>
>> Many Forth systems give you a VIEW command that show you the source code
>> for most words. Some Forth developers try to keep the source for some of
>> their code semi-secret so that it will not be too easy for competitors
>> to just copy it and change it and market it as their own. Sometimes they
>> provide SEE for the words that are not otherwise documented, so that if
>> you need to understand or change some specific feature you can do so,
>> but it's a big enough effort that you will probably not reverse-engineer
>> the whole system.
>
> Beyond what Jonah said, I don't see the point of Aleksej's comment.
> It's pointless to compare Forth to Lisp, and doesn't even begin to
> address Friederike's question. However, I suspect that it would be
> easier to reverse engineer pForth than it would to do the same to
> Steel Bank Common Lisp.

You're either quite stubborn or quite stupid.

It is perfectly valid to compare Forth to Lisp, because the comparison
deals with the very point of your reply. You stated that with a little
knowledge you can understand Forth intrinsics given the list of words.
This comparison shows pretty nice that this is less possible with Forth
than with Common Lisp, which is much more complex language.

This comparison shows perfectly that:
a) Forth requires way more knowledge to understand than Common Lisp at
the same level;
b) Forth has much lower quality standards than Common Lisp with respect
to on-line documentation.

You could argue that not all Common Lisp implementations provide the
feature, though you can't refute it in general, because 2 of 3 free ones do.
Or you could argue that decompiler is enough, which might be true,
if that worked better than it usually does. Instead you chose to hide
yourself in the most stupid resort of imaginary invalidity of comparison.

You're yet to show me free Forth implementation that provides VIEW.
Do those implementors "keep their source semi-secret"?
Why free CL implementations provide me with "documentation"?

You don't need to reverse engineer neither pForth nor SBCL, you've got
the source already. The whole argument is concocted, the talk wasn't
about reverse engineering, it was about documentation, it wasn't me who
started talking about poorly documented Forth.


--
HE CE3OH...

Aleksej Saushev

unread,
Oct 6, 2009, 1:39:25 PM10/6/09
to
an...@mips.complang.tuwien.ac.at (Anton Ertl) writes:

> Ian Osgood <ia...@quirkster.com> writes:
>>How many Forth systems capable of SEE or VIEW have the inverse
>>WHEREUSED? and what is it called on those systems? How hard would it
>>be to implement it on GNU Forth?
>
> My editor (Emacs)

Which is basically Lisp (though archaic dialect of) interpreter.

> does this for me (see below), and I'm sure other
> capable editors can do that, too, so I see little benefit from
> additional support in Forth.

I wonder, why Common Lisp implementors think different.
They have more reasons to use Emacs than you. It's just another Lisp dialect.


--
HE CE3OH...

Marcel Hendrix

unread,
Oct 6, 2009, 2:23:22 PM10/6/09
to
Ian Osgood <ia...@quirkster.com> writes Re: Reverse Engineering - Are there any helpful tools?

> On Sep 28, 12:20=A0pm, m_l_g3 <m_l...@yahoo.com> wrote:
[..]


>> 2. SEE <name>
>> it's the standard decompiler; hopefully on your system it shows the
>> Forth source rather than assembly.

FORTH> see f4dup
Flags: TOKENIZE, ANSI
: F4DUP 3 FPICK 3 FPICK 3 FPICK 3 FPICK ; ok
FORTH> see zswap
Flags: TOKENIZE, ANSI
: ZSWAP F2SWAP ; ok
FORTH> see zrot
Flags: TOKENIZE, ANSI
: ZROT F2ROT ; ok

It will not work for complex words (or very simple ones).

>> 3. whereused <name>
>> this word reports occurences of <name> in the code of other
>> definitions. probably on one of the systems it was called REF or REFS.
>> I suspect that you will have to implement it yourself, which is
>> feasible in the case that your system uses threaded code.

-- ----------------------------------------------------------------
iForth version 4.0.7, generated 20:20:54, October 5, 2009.
x86_32 binary, native floating-point, extended precision.
Copyright 1996 - 2009 Marcel Hendrix.

FORTH> include nspiceac.frt
NSPICE> cd utils
Directory: C:\dfwforth\examples\nspice\utils ok
NSPICE> in ac-gui
Creating --- OS Library linking Version 1.20 ---
Creating --- Fetch WIN32 consts Version 1.02 ---
Creating --- Use WIN32 resources Version 1.06 ---
Creating --- SPICE NT (AC) GUI Version 1.05 ---
reading resource: #forthpad.res#
reading resource: #nspiceac.res#

iForth Windows application loaded: schematic drawing language.
To run the GUI, type: GUI <Enter>
Exit with STOP on the SPICE Popup of the Graphics Terminal.
Note that the COPY and PRINT menubar items are enabled.
Watch the status bar.
ok
NSPICE> locate SHOW1
File: C:\dfwforth\examples\nspice/nspiceac.frt, line: 1672
1670| R> ]TEXT ;
1671|
1672>> : SHOW1 #31 >SHOW1 ;
1673|
1674| : >SHOW2 TEXT[ >R \ <n1> <2> --- <>
ok
NSPICE> where SHOW1
C:/dfwforth/include/eplot.frt:1019:: PRINT1 ( n1 "name" -- ) ['] SHOW1 (PRINTn) ;
C:/dfwforth/include/eplot.frt:1030:: CLIPBOARD1 ( n1 "name" -- ) ['] SHOW1 (CBn) ;

C:/dfwforth/examples/nspice/nspicetr.frt:2833:: SHOW1 #31 >SHOW1 ;
C:/dfwforth/examples/nspice/nspicetr.frt:2872:: PRINT1 ['] SHOW1 (PRINTn) ;
C:/dfwforth/examples/nspice/nspicetr.frt:2874:: CLIP1 ['] SHOW1 (CBn) ;
C:/dfwforth/examples/nspice/nspicetr.frt:3356: CR ." SHOW1 CLIP1 PRINT1 "

C:/dfwforth/examples/nspice/nspiceac.frt:1672:: SHOW1 #31 >SHOW1 ;
C:/dfwforth/examples/nspice/nspiceac.frt:1689:: PRINT1 ['] SHOW1 (PRINTn) ; : CLIP1 ['] SHOW1 (CBn) ;
C:/dfwforth/examples/nspice/nspiceac.frt:1696:: (SHOW1) WHITE-PAGE GCLEAR SHOW1 BLACK-PAGE ;
C:/dfwforth/examples/nspice/nspiceac.frt:1956: [IF] CR ." SHOW1 CLIP1 PRINT1 "
C:/dfwforth/examples/nspice/nspiceac.frt:1961:[ELSE] CR ." SHOW1 -- Show as assigned in .CIR file"
ok
NSPICE> where GUI
C:/dfwforth/include/schema.frt:5: * CATEGORY : CAD tool, needs GUI
C:/dfwforth/include/schema.frt:50: May 7, 1998: It looks the new SCHEMA can be used as a GUI input

C:/dfwforth/include/winconst.frt:5: * CATEGORY : GUI Tool

C:/dfwforth/include/dialogs.frt:5: * CATEGORY : GUI Tool

C:/dfwforth/examples/nspice/utils/ac-gui.frt:4: * DESCRIPTION : Simple GUI for a SPICE that solves AC networks
C:/dfwforth/examples/nspice/utils/ac-gui.frt:18: REVISION -ac-gui "--- SPICE NT (AC) GUI Version 1.05 ---"
C:/dfwforth/examples/nspice/utils/ac-gui.frt:1210:: GUI ( -- )
C:/dfwforth/examples/nspice/utils/ac-gui.frt:1273: CR ." To run the GUI, type: GUI <Enter>"

C:/dfwforth/examples/nspice/nspiceac.frt:1960: CR ." GUI -- Start the graphical user interface"
-- ----------------------------------------------------------------

> I have often wanted a cross-reference lookup like "whereused" when
> learning a new language, vocabulary, or Forth system. Often the
> easiest and most reliable way to determine the contract of a word is
> to see how it is used by the language and library implementors.

> How many Forth systems capable of SEE or VIEW have the inverse
> WHEREUSED? and what is it called on those systems? How hard would it
> be to implement it on GNU Forth?

It is named WHERE ( LOCATE INSPECT WHERE ) and is a recent addition.

-marcel

Stephen Pelc

unread,
Oct 6, 2009, 3:13:06 PM10/6/09
to
On Tue, 6 Oct 2009 09:02:07 -0700 (PDT), Ian Osgood
<ia...@quirkster.com> wrote:

>How many Forth systems capable of SEE or VIEW have the inverse
>WHEREUSED? and what is it called on those systems? How hard would it
>be to implement it on GNU Forth?

VFX Forth has LOCATE <name> (puts source in your editor),
DIS/SEE <name>, WHEREIS <name>, as well as the XREF package.

XREF <name>
Where it is used.
XREF-UNUSED
display unused words
SHOW <name>
A sort of source reconstruction.

Friederike Löwe

unread,
Oct 7, 2009, 3:11:19 AM10/7/09
to
Stephen Pelc wrote:
> How much of the source code do you have?
There are round about 80 files, each one about 300 lines and more.

The topic is to change a part of this system to use a newer technology.
It would not make sense to rewrite the whole system, like somebody else
suggested. I know the parts of the system that are relevant to me and do
not have to change (or understand) anything else (just if it is
necessary to understand to do my job).

> Which Forth host does it use? Do you have access to the
> host Forth? What threading model does it use?

All I know is, that the system based on Forth86.

One of my problems is, that I am very new at Forth and that I am trying
to understand code some professionals have written.

> The really important part in all this is to document all the
> source code and have accurate stack comments for every word.

There are some already. I hoped to find a tool wich can help to get an
overwiev because I am not able to read Forth fluently already. So it is
a mixture of a lack of documentation and a lack of experience.

(One version of the tool of my dreams will read the code, structure the
words into a interactive diagram and adds the stack-comments as
descriptions. And it will allow to add descriptions on my own as soon as
I got to know what one specific word does. - This tool would not be
necessary but perhaps there is a possibility to realize a part of it or
structure the code in another way.)

Thank you all for writing so many ideas!
I will have to think about them.

My professor suggested to write a program wich creates html-code which
works like http://lxr.linux.no/+trees - so that I can browse the code
and can navigate with the browser functions. That seams to be like
searching in an editor, but there I am losing the plot after some steps.
Perhaps that can be a way that is a little better than with just an
editor. (With time I can add the descriptions of the words etc...)

Friederike

Bernd Paysan

unread,
Oct 7, 2009, 3:41:55 AM10/7/09
to
Aleksej Saushev wrote:
>
> You're yet to show me free Forth implementation that provides VIEW.

bigForth provides VIEW.

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/

Stephen Pelc

unread,
Oct 7, 2009, 6:00:57 AM10/7/09
to
On Wed, 07 Oct 2009 09:11:19 +0200,
=?ISO-8859-15?Q?Friederike_L=F6we?= <po...@friederike-loewe.de> wrote:

>> How much of the source code do you have?
>There are round about 80 files, each one about 300 lines and more.

You have 24,000 lines of code. Once you know what you are doing, a
guesstimate suggests at least 30 person days if the code is
reasonable. If it uses tricks and/or assembler it could be much more.

>> Which Forth host does it use? Do you have access to the
>> host Forth? What threading model does it use?
>All I know is, that the system based on Forth86.

A quick google on Forth86 suggests that it may be a FIG-Forth for the
8086 under DOS. This was used to host a cross compiler for 8051s.

So What does the compiler run on and what hardware does the final code
run on? What would you like it to run on?

>One of my problems is, that I am very new at Forth and that I am trying
>to understand code some professionals have written.

That will take a long time!

>My professor suggested to write a program wich creates html-code which
>works like http://lxr.linux.no/+trees - so that I can browse the code
>and can navigate with the browser functions. That seams to be like
>searching in an editor, but there I am losing the plot after some steps.
>Perhaps that can be a way that is a little better than with just an
>editor. (With time I can add the descriptions of the words etc...)

A good fast editor is better investment than writing another set of
tools, which may/do already exist in a commercial Forth.

MPE has done enough of these conversion jobs to know that estimating
such jobs is hard.

Aleksej Saushev

unread,
Oct 7, 2009, 6:24:50 AM10/7/09
to
Bernd Paysan <bernd....@gmx.de> writes:

> Aleksej Saushev wrote:
>>
>> You're yet to show me free Forth implementation that provides VIEW.
>
> bigForth provides VIEW.

bigForth is linux-only, i.e. it has other drawbacks, which are critical.


--
HE CE3OH...

Bernd Paysan

unread,
Oct 7, 2009, 6:59:29 AM10/7/09
to
Aleksej Saushev wrote:

bigForth is x86-only, but it currently runs on Linux, Mac OS X, and Windows,
and IMHO the most critical drawback is that Windows users don't report bugs,
so that's why I say the Windows version is "unsupported". There's just no
community out there in the Windows empire which understands how free
software works and how to report bugs. The Linux users report bugs. The
best bug reporter is Stephen Pelc. You need to be a good programmer to
generate good bug reports. If your bug reports are lousy, your programming
skills quite likely suck as well - or at least your interpersonal skills.

It however *is* a free Forth that provides VIEW, and you didn't ask for more
;-). Every Forth system has some drawbacks or others, but as long as you
say just "which are critical", you won't get them fixed. Be specific, and
don't sound like a jerk when reporting bugs. The latter is a pretty
critical problem with you. Even though you often are technically correct,
you overdo it by name-calling.

Aleksej Saushev

unread,
Oct 7, 2009, 11:13:44 AM10/7/09
to
Bernd Paysan <bernd....@gmx.de> writes:

> Aleksej Saushev wrote:
>> Bernd Paysan <bernd....@gmx.de> writes:
>>> Aleksej Saushev wrote:
>>>>
>>>> You're yet to show me free Forth implementation that provides VIEW.
>>>
>>> bigForth provides VIEW.
>>
>> bigForth is linux-only, i.e. it has other drawbacks, which are critical.
>
> bigForth is x86-only, but it currently runs on Linux, Mac OS X, and Windows,
> and IMHO the most critical drawback is that Windows users don't report bugs,
> so that's why I say the Windows version is "unsupported". There's just no
> community out there in the Windows empire which understands how free
> software works and how to report bugs. The Linux users report bugs. The
> best bug reporter is Stephen Pelc. You need to be a good programmer to
> generate good bug reports. If your bug reports are lousy, your programming
> skills quite likely suck as well - or at least your interpersonal skills.
>
> It however *is* a free Forth that provides VIEW, and you didn't ask for more
> ;-).

Alright, alright, I accept it even though I can't check it, since none of
interesting to me platforms are supported.

Note the outcome: 2/3 for CL v. 0/3 for Forth. If I extend the list to take
into account other platforms, which are outside of my interests, that
will make 3/4 v. 1/5. Forth loses a great deal.

Now you may start arguing that "you can't compare," this won't change facts
though. They are pretty stubborn, the only way to refute them is to implement
the feature.

> Every Forth system has some drawbacks or others, but as long as you
> say just "which are critical", you won't get them fixed. Be specific, and
> don't sound like a jerk when reporting bugs. The latter is a pretty
> critical problem with you. Even though you often are technically correct,
> you overdo it by name-calling.

Oh, well. Go outside and ask what others think about it.
Informal answers are even more harsh than "inferior quality."


--
HE CE3OH...

Dennis Ruffer

unread,
Oct 7, 2009, 12:33:34 PM10/7/09
to
On Oct 7, 5:00 am, stephen...@mpeforth.com (Stephen Pelc) wrote:
> On Wed, 07 Oct 2009 09:11:19 +0200,
>
> =?ISO-8859-15?Q?Friederike_L=F6we?= <p...@friederike-loewe.de> wrote:
> >My professor suggested to write a program wich creates html-code which
> >works likehttp://lxr.linux.no/+trees- so that I can browse the code

> >and can navigate with the browser functions. That seams to be like
> >searching in an editor, but there I am losing the plot after some steps.
> >Perhaps that can be a way that is a little better than with just an
> >editor. (With time I can add the descriptions of the words etc...)
>
> A good fast editor is better investment than writing another set of
> tools, which may/do already exist in a commercial Forth.

Friederike, I agree with Stephen, but I would also suggest that you
look at an outlining editor. If you can plug the source into an
outline, expanding and intermingling the code as you go, you may be
able to get a good sense of the program flow. I have used the
technique quite a few times, when faced with legacy code. There used
to be diagramming techniques, called Action Diagrams, that supported
this in an editor, and I wrote something similar in Forth, once upon a
time. However, these days, any editor that supports outlining can do
it. Something like DOORS even supports the linkages, but others, even
free ones, can do just about the same things.

DaR

Friederike Löwe

unread,
Oct 7, 2009, 12:49:59 PM10/7/09
to
Stephen Pelc wrote:
>>> How much of the source code do you have?
>> There are round about 80 files, each one about 300 lines and more.
>
> You have 24,000 lines of code. Once you know what you are doing, a
> guesstimate suggests at least 30 person days if the code is
> reasonable. If it uses tricks and/or assembler it could be much more.

That sounds a bit scary, but hopefully i don't need to understand all of
the code. I need to change the implemented filesystem from FAT16 to
FAT32. It seems that i only need to change four "high level" words. To
do so, i need to understand on which words they depend on and what they
do. I can't actually say how deep i need to go in the system.

>>> Which Forth host does it use? Do you have access to the
>>> host Forth? What threading model does it use?
>> All I know is, that the system based on Forth86.
>
> A quick google on Forth86 suggests that it may be a FIG-Forth for the
> 8086 under DOS. This was used to host a cross compiler for 8051s.
>
> So What does the compiler run on and what hardware does the final code
> run on? What would you like it to run on?

The target is an "embedded system", i don't know much about the hardware
used. I just got an working device on my desk that "talks" to me via a
terminal program. I use a windows system with a cross-compiler.

>> My professor suggested to write a program wich creates html-code which
>> works like http://lxr.linux.no/+trees - so that I can browse the code
>> and can navigate with the browser functions. That seams to be like
>> searching in an editor, but there I am losing the plot after some steps.
>> Perhaps that can be a way that is a little better than with just an
>> editor. (With time I can add the descriptions of the words etc...)
>
> A good fast editor is better investment than writing another set of
> tools, which may/do already exist in a commercial Forth.

The editors i used until now only have simple "find in files" functions.
I can find the definitions of words but i have no possibility to
navigate through the code. Can you suggest an editor that is more useful
for my problem?

Friederike

ken...@cix.compulink.co.uk

unread,
Oct 8, 2009, 5:46:26 AM10/8/09
to
In article <haigru$hsv$1...@news.eternal-september.org>,
po...@friederike-loewe.de (=?ISO-8859-15?Q?Friederike_L=F6we?=) wrote:

> I need to change the implemented filesystem from FAT16 to
> FAT32. It seems that i only need to change four "high level" words.

You need to know how the file system is implemented. Normally if it is
a version of Forth running on an OS the underlying OS actually handles
the nuts and bolts with the Forth only making OS calls with the actual
file system structure being invisible to it. IIRC WinForth will run on
Fat16, Fat32 and NFTS without any changes depending on which Windows
version is used. If your problem is that Fat16 can not handle large
discs using multiple partitions might be easier. Or try running in a DOS
box on Windows as I do not remember any stand alone version of DOS that
has Fat32.

Ken Young

Stephen Pelc

unread,
Oct 8, 2009, 7:44:35 AM10/8/09
to
On Wed, 07 Oct 2009 18:49:59 +0200,
=?ISO-8859-15?Q?Friederike_L=F6we?= <po...@friederike-loewe.de> wrote:

>That sounds a bit scary, but hopefully i don't need to understand all of
>the code. I need to change the implemented filesystem from FAT16 to
>FAT32. It seems that i only need to change four "high level" words. To
>do so, i need to understand on which words they depend on and what they
>do. I can't actually say how deep i need to go in the system.

You will need to change the FAT access routines. You will also need
to change the start up code because there are many changes in things
like the directory start location. You need to read the Microsoft
documentation. AFAIR you need a file called something like
fatgen103.pdf. You may also find that you n eed to update the disk
partitioning code.

If you are using SD cards, you'll also have to upgrade from SD
to SDHC.

It might well be cheaper in the long term to use existing code. We
sell an adapted version of Brad Eckert's FAT code.

0 new messages