Announcement

Collapse
No announcement yet.

uVGA-II in GFX mode - Optimal use of the 14Kb prog memory

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

  • uVGA-II in GFX mode - Optimal use of the 14Kb prog memory

    Hi,

    As I understand it the GOLDELOX-GFX2 has 14K for program (FLASH) and 14K of RAM. Actually the manual says :
    - 14KB of Flash memory for user code storage and
    - 14KB of SRAM for user variables.


    From what I understand that last 14 Kb actually load the program from the FLASH. So it looks like it contains both Program and Data. But may be I am getting confused here?

    Anyway the memory in not that big, so if I want to run a fairly big program should I use as much as possible the functions :
    - file_LoadFunction(fname.4XE)
    - file_Run(fname.4XE, arglistptr)
    - file_Exec(fname.4XE, arglistptr)
    to load consecutive part of my program from a micro-SD card?

    I am actually wondering if the 4D Workshop3 IDE does "automatically" do that kind of "program slicing" if the program gets to big?

    Thanks in advance for any help/insight you can give.

    Cheers,
    ERIC

  • #2


    The 'default' is to copy the program from FLASH to RAM and run it from there. This gives the best performance.

    If you include

    #MODE RUNFLASH

    in your program then it will run from FLASH, this will give your program more RAM, at the expense of a bit of performance.

    Workshop does not do any 'slicing', it is all controlled by you.

    The compiled code is usually quite small. If you code carefully and use subroutines 'efficiently' (i.e. to save 'repeated' code space) you will be surprised how much you can fit in before needing file_ load/run/exec.

    If you need lots of strings, consider storing them on uSD and using a subroutine to print them
    Mark

    Comment


    • #3


      Ok, if and when I run out of space, I will use #MODE RUNFLASH in my program. Do you roughly know how much slower does the program runs ?

      Ok Workshop does what it is told to do. It up to me (the programmer) to organize the code properly.


      I havn't started the programming yet, but I should to that from next week. Actually my main computer is a MAC, does anybody has experience with running WORKSHOP from a MAC in a window emulator? Is the communication with the uVGA-II or other GOLDELOX-GFX2 based module work?

      Looking again at these functions :
      - file_Run(fname.4XE, arglistptr)
      - file_Exec(fname.4XE, arglistptr)
      If was wondering when the control is given back to the calling program? Ok, it should be at the end of the called program, but is there any specific instruction to put in the program? Say to pass some result variables back to the calling program.

      I have a few questions on the manual description of the file_Run function :
      Any memory allocations in the main FLASH program are released, however, the stack and
      globals are maintained. func 'main' in the called program accepts the arguments, if any. If
      arglistptr is 0, no arguments are passed, else arglistptr points to an array, the first element
      containing the number of additional elements in the array which contain the arguments.
      The disk does not need to be mounted, file_Run automatically mounts the drive.

      - not sure what "Any memory allocations in the main FLASH program are released
      " means? Does this statement implies that the calling program is explicitly loaded in FLASH? Or can memory allocation function allocate Flash memory?
      - "the first element
      containing the number of additional elements"
      means it contans the number of arguments?
      - "The disk does not need to be mounted"
      does that means that the SD card does not have to be initialized?

      The difference between ge_1275893727">file_Run function and file_Exec function is :
      This function is similar to file_Run, however, the main program in FLASH retains all memory
      allocations (eg file buffers, memory allocated with mem_Alloc etc)
      Does that mean that with file_Exec the calling program does not "lose" any variable/info even if it has been allocated in FLASH memory ?

      The file_LoadFunction
      () sounds pretty cool. Similar to DLL but managed by the program;

      Cheers,
      ERIC

      Comment


      • #4


        The difference in speed varies with what your program does, some people don't notice the difference, others do, I can't really give a figure.

        Many people run from a MAC, results vary according to the emulator and the 'fix level' of it, most eventually get it to work.

        Exit and return operates in the same way as a normal subroutine.

        The main program must run from FLASH, all called programs are loaded into RAM, so the calling program is in FLASH all along.

        'Number of Additional elements' is the arg count.

        All file_ functions require a FAT formatted uSD card, mounting is what a program needs to do to acess the uSD card. All OSes have the concept of mounting a disk, many just hide it from the user.

        A program cannot allocate memory in FLASH, file_Run only retains memory allocated in globals (i.e. variables defined outside of 'main'. All variables defined inside of main, all mem_Alloc(ed) and all file buffers (which are transparently mem_Alloced) are discarded before file_Run and re allocated afterwards, with the loss of their contents. This results in the maximum amount of memory being available for the 'runned' program.

        file_Exec does not release any memory allocations, this means a) less memory will be available to the 'Execced' program and b) depending on how your program has been written / progressed to date the heap may be so fragmented that your 'execced' program cannot run.
        Mark

        Comment


        • #5


          The difference in speed varies with what your program does, some people don't notice the difference, others do, I can't really give a figure.OK so the speed difference from running from RAM or FLASH is not that big.

          Many people run from a MAC, results vary according to the emulator and the 'fix level' of it, most eventually get it to work.I will give a go at a Windows emulator and see if I can program from my MACows.

          The main program must run from FLASH, all called programs are loaded into RAM, so the calling program is in FLASH all along.
          Ok that is clearer the calling program must be loaded in flash.

          All file_ functions require a FAT formatted uSD card, mounting is what a program needs to do to acess the uSD card. All OSes have the concept of mounting a disk, many just hide it from the user.
          So does that means that mounting (in GFX mode) is the same thing as calling the Initialise Memory Card function (in SGC mode)?

          A program cannot allocate memory in FLASH, file_Run only retains memory allocated in globals (i.e. variables defined outside of 'main'. All variables defined inside of main, all mem_Alloc(ed) and all file buffers (which are transparently mem_Alloced) are discarded before file_Run and re allocated afterwards, with the loss of their contents. This results in the maximum amount of memory being available for the 'runned' program.

          file_Exec does not release any memory allocations, this means a) less memory will be available to the 'Execced' program and b) depending on how your program has been written / progressed to date the heap may be so fragmented that your 'execced' program cannot run.
          Ok, thanks, that is clearer.

          Comment


          • #6


            So does that means that mounting (in GFX mode) is the same thing as calling the Initialise Memory Card function (in SGC mode)?
            Ahh, yep.
            Mark

            Comment


            • #7
              Good news, I got FAT controller, Workshop 3, PmmCLoader to work in the VirtualBox (v4.2.4) on my MAC (10.7.5 Lion). I was able to update the firmware on the uVGA-II card to change it from SGC to GFX.

              I have run a few test and they are much faster than in SGC mode.

              I ran the "4D Labs\PICASO GFX2\PICASO - RUN FROM DISK\R_RunProgram.4dg" program. But it is menu and touch based for the selection. I will update it to go though the 4 programs sequentially.

              I will give a go at using the file_run() function.

              Have a happy Christmas and New Year .... and enjoy the Australian sun.

              Cheers,
              ERIC

              Comment

              Working...
              X