John,
This morning I did some poking around with this. MFORTH compiles words into
memory when you define them and it leaves them there even when you BYE out
of the interpreter.

I guess in theory to use a FORTH word from BASIC all you'd have to do is
grab the xt with ', do whatever is necessary to switch to the OPTROM, then
CALL the xt address of your word. For FORTH : words, the very first
instruction is always JMP ENTER (C3 5C 01), which is an OPTROM address.
It's probably going to EXIT back to the MFORTH interpreter after it's done,
or crash because something wasn't set up right. I'm not enough of a BASIC
wizard to know how to actually try this from there, but you can re-open
MFORTH and run a word that got left in memory if you know its xt address
and it wasn't overwritten.

For assembled CODE words, it might even be easier, since the xt points
straight to your code. If you leave off NEXT before END-CODE, you might be
able to avoid returning to MFORTH's interpreter entirely.

If you're curious, MFORTH's memory map and dictionary headers are described
in src/MFORTH/main.asm

On Wed, Jun 18, 2025 at 7:06 AM Alex ... <abortretryf...@gmail.com> wrote:

> My own code is hard enough to troubleshoot. I can't imagine how bad
> something Gemini gave up on would be...
>
>
> On Tue, Jun 17, 2025 at 12:29 PM John R. Hogerhuis <jho...@pobox.com>
> wrote:
>
>>
>>
>> On Tue, Jun 17, 2025 at 9:02 AM Alex ... <abortretryf...@gmail.com>
>> wrote:
>>
>>> Hey John,
>>> Okay, two ideas here...
>>> First, as it stands now, MFORTH's neutered file access words are
>>> read-only, but that seems more to do with the author's reluctance
>>> <https://github.com/AbortRetryFail/MFORTH/blob/main/src/MFORTH/answords/file.asm#L446>
>>> than any technical limitations of the machine. I don't think there's
>>> anything stopping the user from using MFORTH to assemble machine code
>>> somewhere in memory and then create a CO file to run it, but it doesn't
>>> give you any tools to do so out of the box.
>>> The second one, embedding MFORTH's interpreter? I have no idea how you'd
>>> go about doing such a thing. Maybe it's possible, but I'm still puzzling
>>> with how to translate DO...LEAVE...LOOP into the TASM macros. Pig iron,
>>> rock, etc. :)
>>>
>>
>> Yeah all that sounds major. Packaging just a launcher which depends on
>> the MFORTH as a runtime seems much easier.
>>
>> My knowledge is mostly about pre-ANS forth. Changing where it compiles
>> words would be a matter of changing HERE.
>>
>> So I guess you would decide where to locate the CO. Change HERE and
>> interpret the program, all the words would go there.
>>
>> The work seems like the boilerplate entry and exit. So some assembly code
>> to get from my CO program into the interpreter and into the "init" word for
>> my program.
>>
>> And then some code for the exit to return to BASIC control.
>>
>> And of course ANS forth is not FIG forth so there's probably some
>> learning to get the dictionary headers into my CO. Maybe, maybe not.
>>
>> Might be fun to feed MFORTH code and docs into Gemini and see if it's in
>> the mood to write the entry/exit for me.
>>
>> I've played with AI stuff lately and have been able to make useful web
>> utilities and even some embedded C code. But it's funny because sometimes
>> Gemini whines. Like, "oh that is complicated I think we should leave it as
>> it is" and refuses to do what I ask.
>>
>> -- John.
>>
>>>
>
> --
> Disclaimer: Any resemblance between the above views and those of my
> employer, my terminal, or the view out my window are purely coincidental.
> Any resemblance between the above and my own views is non-deterministic.
> The question of the existence of views in the absence of anyone to hold
> them is left as an exercise for the reader.
> The question of the existence of the reader is left as an exercise for the
> second god coefficient.  (A discussion of non-orthogonal, non-integral
> polytheism is beyond the scope of this article.) Thanks /usr/games/fortune
>


-- 
Disclaimer: Any resemblance between the above views and those of my
employer, my terminal, or the view out my window are purely coincidental.
Any resemblance between the above and my own views is non-deterministic.
The question of the existence of views in the absence of anyone to hold
them is left as an exercise for the reader.
The question of the existence of the reader is left as an exercise for the
second god coefficient.  (A discussion of non-orthogonal, non-integral
polytheism is beyond the scope of this article.) Thanks /usr/games/fortune

Reply via email to