Re: Newbie in Forth needs help...



"Stephen Pelc" <stephenXXX@xxxxxxxxxxxx> wrote in message
news:44084748.778879812@xxxxxxxxxxxxxxxxxxx
On Fri, 3 Mar 2006 13:07:41 +0100, "Maki" <XYZveselic@xxxxxxxx> wrote:

vocabulary target \ Create vocabulary
forth definitions \ All the word for a cross assembly goes to
main
dict.
...
words for cross assembly ( if, then, while, )
...
target definitions \ Now begin assembly and gradually build an
image
.... \ assembly
L: test \ But how to prevent to create constant in
current dictionary which is target?

You have two choices:

Choice 1
========
only forth definitions
vocabulary *target
also *target definitions \ will search *TARGET before FORTH

l: test \ searches FORTH to find L:
\ TEST is in *TARGET

Choice 2
========

: L: \ -- ; L: <name>
also *target definitions
here(t) constant
previous definitions
;

This creates TEST in *TARGET regardless of the defined search
order. If you use an ANS Forth host, you will have more control
than using a Forth-83 host.

If you want to generate a Forth cross compiler as well, read
Brad Rodriguez series of articles on "Moving Forth". If you
are doing this for work rather than entertainment, buy a
commercial compiler with source code from MPE or Forth Inc.
We've been doing this stuff for a long time, the chassis is
rock solid, and you'll get all the tools you need. Forth
cross compilers are conceptually easy, but are very difficult
to implement well - the devil's in the detail and there's
a lot of detail. Yes, I'm biased. We sell cross-compilers
but even at very low wage rates, the cost of a commercial
compiler is very low compared to that of the time it will
take to write a good tool from scratch.

Stephen


--
Stephen Pelc, stephenXXX@xxxxxxxxxxxx
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

Ok I'm not sure I understand yet...

vocabulary *target
only forth definitions \ Compiling to Forth dictionary
.... \ words for assembly
: L:
also *target definitions \ include *target dictionary first in search
order
here \ dictionary pointer of *target
previous definitions \ return previous search order
constant \ build constant in forth dictionary
;
also *target definitions \
\ Later in the code if I use L:

L: test \ will compile constant in forth dictionary
\ with value of here from *target dictionary
test call, \ returns address of test to assemble call,

As I understoded the constant is compiled in the dictionary where L: is
found? That's why I have to switch back to *target to be able do take "here"
of *target in order to assign that value to a constant which is then after
restoring search order compiled in the forth dict.
I'm a student and can't afford to buy any commercial tools :( so I have to
make them myself :o))
I have built a simple 16-bit Forth processor in FPGA.. But I'm sick and
tired of coding hex values so I decided to build an assembler. With
assembler
at hand I can make bootloader and after that ( which is far away... ) I'm
planning to port eForth for my processor so I can enjoy in a powerful
programming environment !

Thanks,
Best regards,
M.Veselic






.



Relevant Pages

  • Re: mixing C and assembly
    ... there are compiler extensions or assembly wrappers that link C functions to interrupts. ... Since you hang out gcc for not being "a full C implementation", and for having "extensions quite apart from extensions for the target", can you give me some examples of other available compilers that *are* "full C implementations", which have *no* compiler extensions, and which are targeted at embedded systems? ... The "C" function to set up the UART on an 8051 with a Keil compiler looks almost the same as assembler! ...
    (comp.arch.embedded)
  • Re: Build your own Forth for Microchip PIC (Episode 837)
    ... the unreasonablly small hardware stack size for my particular target. ... You are handcuffed in the sense that you would like to be able to download small amounts of code into ram and execute it. ... because once you do away with the inner interpreter, ... An optimizing compiler isn't a post-processor, it's an *alternative* to another kind of compiler. ...
    (comp.lang.forth)
  • Re: Build your own Forth for Microchip PIC (Episode 837)
    ... put those tokens in RAM. ... This is the reason I'm wanting to use the host as a remote execution ... Test/Debug code on target recompiling and reloading as necessary. ... of implementing anything other than a batch forth compiler for it. ...
    (comp.lang.forth)
  • Re: Build your own Forth for Microchip PIC: Design thoughts
    ... compiler is the only task that's burning in my brain right. ... that puts PIC code on the host for the simulator to execute. ... I'm not so sure about the simulator. ... That target will execute compiled forth words. ...
    (comp.lang.forth)
  • Re: Writing an ANS Forth
    ... I just wish there was more literature to be found on the inner workings of a cross target compiler. ... only included in the $1295 Professional SwiftX versions of the compiler, I'm afraid that is way beyond what I can justify for hobby use. ... The major missing component for doing a new target is the assembler, but designing a new assembler is a lot smaller task than designing a whole new cross-compiler. ...
    (comp.lang.forth)

Loading