Author Topic: FORTH implementation  (Read 1691 times)

0 Members and 1 Guest are viewing this topic.

Offline adrusi

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +4/-0
    • View Profile
    • Adrusi
FORTH implementation
« on: May 30, 2012, 09:54:53 pm »
I'm thinking of implementing a FORTH environment in Axe. I think FORTH is a great environment for old devices like the TI 8x models, even though they are on the upper end of what I would consider FORTH appropriate for.

I'm wondering if anyone else is interested in a dynamically compiled FORTH environment. The rest of this post is me rambling about specifics and somewhat less interesting stuff.

I have a system set up for dynamic compilation of words into actual machine code. It's not the prettiest, and it could be about 2 machine instructions per word (as in FORTH word) more efficient if I were willing to write it in assembly, but I think the way I have it is good enough efficiency-wise and also lets me write all but 3 lines in Axe.

I basically have an implementation of linked lists, except instead of a list it's a subroutine.

Code: [Select]
:lbl BCONS

(the above code has unicode characters, if it doesn't display right for you I have a less pretty version below)
Spoiler For Spoiler:
Code: [Select]
:lbl BCONS

funny story about how I came up with that code:
Spoiler For Spoiler:
I started writing the program during school when I had no access to z80 documentation, so to find the opcodes I used the calcsys app I had installed to decompile the calculator memory and then look up what the original value was in the hex editor. This is exciting for me since I almost always work in a memory-safe environment.

So it can be called like this:

Code: [Select]
:Disp A▶DEC

(no unicode version)
Spoiler For Spoiler:
Code: [Select]
:Disp A >DEC

That's not all there is so far, but there's not really anything else that's interesting yet.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
Re: FORTH implementation
« Reply #1 on: May 31, 2012, 03:05:19 am »
Argh, plz don't put code tags in spoilers, they are tiny in chrome D:
I'm not a nerd but I pretend:

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: FORTH implementation
« Reply #2 on: May 31, 2012, 03:08:04 am »
Welcome to the forums !

Interesting idea !
I always like to see people implemented old languages :)

But I can't help you with your programming, as I'm no z80 programmer.