Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:38 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: why no CHAIN?

Author Message
nattacca
Newbie

Joined: 29/07/2020
Location: United Kingdom
Posts: 2
Posted: 07:38pm 29 Oct 2020
Copy link to clipboard 
Print this post

Hi!

The manual states, that CHAIN is not supported on the CMM2 because "The Colour Maximite 2 has an exceptionally large program memory space so this feature is not necessary."

This sounds like the infamous Bill Gates quote "640K ought to be enough for anybody." :/

Even if memory itself is not the immediate problem, what about some means of dynamically loading program code, depending on whatever conditions one might see necessary? I.e. using some sort of library functions that are loaded during run time, depending on user choices.

Is there any chance we can get CHAIN or similar commands for the CMM2? Or are there other ways to accomplish something similar?
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 07:55pm 29 Oct 2020
Copy link to clipboard 
Print this post

Hello "nattaca",

What do you want to achieve (in BASIC) that storage (if not performance) wise cannot be achieved in 0.5 MB of program memory and 5 MB of data memory all backed by a fast storage device with 128 GB capacity?

If you want to run one program from another then you can call RUN on a new program if it's location and arguments are fixed. If you need to create them dynamically then use EXECUTE to call RUN. If you need programs to share variables then stream them in and out of a file.

Genuinely curious to know what you have planned,

Tom
Edited 2020-10-30 05:59 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
nattacca
Newbie

Joined: 29/07/2020
Location: United Kingdom
Posts: 2
Posted: 09:21am 30 Oct 2020
Copy link to clipboard 
Print this post

I seem to have misinterpreted the intended behaviour of CHAIN ... it basically just loads and runs another program, similar to RUN, but with a bit more options to configure it's behaviour, right?

What I really want is a way to dynamically load code at runtime, pass the control flow to it, but then return to the original code and continue from there. I just want to dynamically load some sort of library with a bunch of subroutines that I then can call from my main program. I want different implementations of a sub routine in different (library)files, that I can load and call at run time.

#INCLUDE seems to do that for me, but it lacks the dynamic part where I could decide at run time which file I want to include.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 09:36am 30 Oct 2020
Copy link to clipboard 
Print this post

  Quote  What I really want is a way to dynamically load code at runtime


You can't do this and you won't ever be able to do this. MMBasic does quite a lot of manipulation of the program when it loads it to improve performance this is completely incompatible with being able to dynamically load new elements
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 11:30am 30 Oct 2020
Copy link to clipboard 
Print this post

  nattacca said  I seem to have misinterpreted the intended behaviour of CHAIN ... it basically just loads and runs another program, similar to RUN, but with a bit more options to configure it's behaviour, right?


Different platforms may have had different interpretations of CHAIN. If memory serves then on the BBC Micro it would load and run a new program whilst keeping the variables (and probably other non-program memory) intact.

On your main topic you've described a desired solution without describing a concrete use-case. The CMM2 has sufficient program memory to store 10,000+ lines of BASIC which is probably enough to store multiple implementations of any given subroutine in a single monolith and use a SELECT CASE to dispatch requests to the desired one. I believe it is enough to knock off most, if not all, 8 and 16-bit video games plus the productivity applications that were available on those platforms.

If you really do need more program memory then depending on your application you could either:

Use a chain of multiple programs each operating on the outputs of the previous one, or

Have a master/launcher program that dynamically writes the "real" program with the correct #INCLUDEs for the specific subroutine implementations required for a given execution.

In a crazy future some insane genius might (even without further firmware extensions) concoct a mechanism to load machine code into integer arrays and then use a CSUB to pass control into that code. Such arrays could be dynamically loaded and swapped. @matherp may now point out some hardware limitation that means this is impossible, or he might just stand back and say that the "engine's cannae' take it!"

Best wishes,

Tom
Edited 2020-10-30 21:44 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025