Hey all,

I have recently been working on a project for the calculator that would ideally involve running a few scripts from AppVars that call C functions within the main program; this would allow the project to be easily extendable in a way that I think would be quite cool. In the past couple days, I have thrown together two partial LISPs, but keep struggling to get an interpreter to a workable state. I have never made one before... Neutral

Does anybody know of a previous project I could draw on that is capable of:


    Performing mathematics with unsigned integers

    Reading/writing without assumption of FILE layer

    Calling C functions provided as primitives

    Recursion


Alternatively, could anybody give me some advice for a good, basic memory structure to go for in my own interpreter, or a way to identify an existing interpreter that might be easy to port instead? (Or a quick and dirty way to emulate FILE*s, which seems to be a big holdup)

For anybody who wants to see my floundering: https://tangled.org/@euphory.gay/hg
Lua is a very common choice for embedding, but might be heavier-weight than what you're looking for depending on the complexity of operations you're looking to enable. The Lua developers have a handy technical report describing how it's easy to get a build down to 24k code size on x86, with room to go smaller by disabling more features.

I'm not aware of any other work that's sought to build Lua for eZ80, but that seems like it would be broadly useful.
Thanks! 24k is still a lot, though, and that's just code... but that might be a good place to start. Plus, it'll be smaller than 24k just by virtue of being on ez80 instead of x86, if that jump is surmountable in the first place.
Hmm. Actually, I've come up with a couple more ideas on how to exploit the memory layout of the CE to cram more information into each object. [link]https://github.com/rxi/fe[/link] also has a cool way of storing strings with all the other language objects, which I think I've come up with a way to improve upon by 50%!

Here's roughly what this data structure looks like:


Code:

#define HG_FREE (0x0 << 19)
#define HG_ERR (0x1 << 19)
#define HG_NUM (0x2 << 19)
#define HG_SYM (0x3 << 19)
#define HG_FUNC (0x4 << 19)
#define HG_NIL (0x5 << 19)
#define HG_PRIM (0x6 << 19)
#define HG_MACRO (0x7 << 19)
#define HG_STR (0xC << 19)
#define HG_CONS (0xD << 19)
#define HG_CFUNC (0xE << 19)
#define HG_PTR (0xF << 19)

typedef struct hg_expr_t {
    union {
        uint24_t tag;
        struct hg_expr_t *ptr;
    } car;
    union {
        void *ptr;
        struct hg_expr_t (*fn)(struct hg_expr_t, struct hg_expr_t);
        int24_t num;
        char chars[3];
    } cdr;
} hg_expr_t;
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement