![]() |
Forum Index : Microcontroller and PC projects : FLASH CHAIN
Author | Message | ||||
palcal![]() Guru ![]() Joined: 12/10/2011 Location: AustraliaPosts: 1989 |
From the manual..... 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: AustraliaPosts: 2611 |
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 KingdomPosts: 7865 |
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 KingdomPosts: 1360 |
What happens to libraries? |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2611 |
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 KingdomPosts: 7865 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |