Announcement

Collapse
No announcement yet.

Max program size?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16


    Thank you very much for the explanation, once I replaced that statement everything worked as it should.

    Mark

    Comment


    • #17


      Hello again,

      I have another question, as it turned out using File_Exec to run my sub-program required me to use mem_Free(hndl), to clear some ram, before it would load. This created other issues and I would like to use File_Run because I can execute the program without having to use mem_Free first, however according to the manual:
      "Any memory allocations in the main FLASH program are released, however, the stack and globals are maintained." What I need is help to know which variables need to be reinitialized. I use the statement


      hndl := file_LoadImageControl("NEWKBC~1.dat", "NEWKBC~1.gci", 1);

      but simply doing this still results in a restart. Can you point me in the right direction. The main program is very simple it just uses a few buttons to run different sub-programs.

      Thanks again for your help.

      Mark

      Comment


      • #18


        What were the other issues?

        "Any memory allocations in the main FLASH program are released, however, the stack and globals are maintained." What I need is help to know which variables need to be reinitialized.
        Any memory allocated will be lost, so things with mem_Alloc will be lost, as will memory allocated for file_LoadImageControl, file_Open, etc.
        Mark

        Comment


        • #19


          I was having issues with recursion because I was calling main() after I returned from the sub-program. Then I switched to File_Run and I didn't have to use mem_Free to get the program to run but it restarted on its own and I couldn't figure out why. But after looking at a sample program, I saw that they used goto redo: and that effectively reinitialized everything after the file_run. It's odd that you can't call main() without it being recursive, but you can put a goto statement right under the main() heading and that works fine. Anyhow, problem solved. Thank you for your help.

          Mark

          Comment


          • #20


            I think you have to remember that you are always in the 'main' function. If you call a function from inside itself you get problems with recursion because you are asking the program to return to 'main' after it's done running 'main'. If main never returns you have an ever growing stack of 'main's that you've called.


            That's why the 'goto' works. You never leave main function, you just move around inside it. You could also put all your initialization code into a separate function so that you could simply call that function and reinitialize it that way.

            Comment

            Working...
            X