Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:44 12 Jul 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 : FLASH CHAIN

Author Message
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1989
Posted: 07:12am 02 Jan 2025
Copy link to clipboard 
Print this post

From the manual.....
  Quote  FLASH CHAIN n Load and run a program from flash location n, leaving all variables intact.
As with FLASH RUN this command but does not erase or change the
program held in the main program memory.

Bit of a grammatical hiccup I think, but can some one explain the bit about leaving all variables intact and why you can run a much larger program.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2611
Posted: 07:52am 02 Jan 2025
Copy link to clipboard 
Print this post

  Quote  As with FLASH RUN this command but does not erase or change the program held in the main program memory.
Yes perhaps that could be amended to "...this command loads and runs a program but does not erase or change..."

If you have a program that is too big to fit in program memory it may, depending on the nature of the program, be possible to break it into two programs. The second program then has access to all the variables, and their values, created in the first.

If the second needs to loop back to the first it could get a bit messy!
Though you can with FLASH CHAIN 0 as normal program memory is effectively Flash 0.
.
Edited 2025-01-02 17:56 by phil99
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7865
Posted: 08:52am 02 Jan 2025
Copy link to clipboard 
Print this post

Peter (or someone): Please correct me if I'm wrong on this.

Programs in flash run from flash. If you use FLASH RUN 1 it will clear the variables area and run the program in flash slot 1 (they are already tokenized when stored in flash so there is no pre-processing). There is no need to disturb the existing program - nothing is loaded. If you use FLASH LOAD 1 then flash area 1 is copied over the main program area and the variables area is cleared. If you use FLASH CHAIN 1 then the program in flash slot 1 is run, but the variables area is not cleared first.

Obviously, while running in a flash slot you can't "return" as it's not a subroutine, it's a program in its own right. You have to let the program know what it has to do, in the case of FLASH CHAIN you need to set a variable to tell it which flash slot to CHAIN to next.

So, basically, FLASH LOAD copies from its flash slot to flash slot 0 (the main program area), FLASH RUN runs from its flash slot but wipes variables, FLASH CHAIN runs from its flash slot without wiping variables.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1360
Posted: 08:01pm 02 Jan 2025
Copy link to clipboard 
Print this post

What happens to libraries?
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2611
Posted: 08:24pm 02 Jan 2025
Copy link to clipboard 
Print this post

The Library uses flash slot 3 so a very big program can be cut in 3 and use 0, 1 and 2.

Subs in the library can be accessed from any of the 3 program segments, so that is the best place for Subs that are used in more than one segment.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7865
Posted: 10:37pm 02 Jan 2025
Copy link to clipboard 
Print this post

Flash slot 3 is special.
Until you use LIBRARY SAVE it is a normal flash slot. Once you use this command it can no longer be used as a regular flash area. Routines stored in here are automatically tokenized and compressed. They can be called using normal commands from MMBasic but they are taking up no space in the program area or in any of the other two flash slots. Because they are compressed they tend to run a bit faster too.

Flash slot 0 is also special in that it is generally thought of as the program area. That means that there are some commands that would make no sense (even if they were valid), like FLASH LOAD 0 to copy the program area into the program area!
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
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