#24 File Error when too many strings/arrays

open
John Hansen
None
5
2009-01-26
2007-08-12
Pavel Petrovic
No

When the data segment together with immediate strings contains too much data, the compiler creates bytecode that downloads fine to the NXT brick, but cannot be started (File Error message before the execution starts).
Instead, should not the compiler refuse to compile or at least to download such program....?

Discussion

  • John Hansen
    John Hansen
    2007-08-12

    Logged In: YES
    user_id=661666
    Originator: NO

    Please attach a program which demonstrates this problem.

    John Hansen

     
  • Pavel Petrovic
    Pavel Petrovic
    2007-08-12

    Logged In: YES
    user_id=9375
    Originator: YES

    Ops, sorry, it is ok, I cancel it. I had a code eqiv. to this:

    ---
    #define BIGSIZE 18500

    dseg segment
    bigarray word[]
    w word
    ends

    thread main
    TextOutEx(10,40,"start",1)
    arrinit bigarray, 0xFFFF, BIGSIZE
    index w, bigarray, 1234
    replace bigarray, bigarray, 4321, w
    TextOutEx(10,30,"Hello",0)
    TextOutEx(10,20," NXT!",0)
    NumOutEx(10,10,w,0)
    exit
    endt

    ---

    But now I see that the start actually gets printed but disappears too quickly.
    This File Error message confused me again. Also that I did not realize fully
    that I am allocating the array dynamically as it seems to be the only option,
    except of initializing with some values? and that it was not so clear to me
    from the manual what arrinit does when there is not enough memory. Glad that
    it is not a compiler problem.

    BTW. are the constant strings sharing the same data segment as dynamic arrays?
    Or can they perhaps be in the flash? I understand that the program is running
    directly from where it is stored on the "flash disk" on NXT, is that right?
    Are also static data are stored there, or do they have to be copied to RAM first?
    Would it be possible to have read-only arrays that would be stored only in the flash
    - or at least in static ram and that could be accessed with "index" call?
    Is that what happens with the static strings that are passed directly to macros
    at least? Or do they also get a copy in ram?

    What exactly are the size restrictions for static and dynamic data? 32KB for
    dynamic and 32KB for static? Is there no chance to modify these VM limits
    in the standard firmware?
    And how about the stack? What size? Does it run in the same memory as dynamic?
    Does it grow? If I allocate all dynamic memory at the start of the program,
    how big initial stack do I get? Can that be somehow controlled by compiler?

    Well, please, do not answer now, if you are busy, please, it is not so important for me now.
    Maybe you have a direct pointer to where this information is available? I know, the firmware sourcecode...
    Thanks for great work anyway.

     
  • Pavel Petrovic
    Pavel Petrovic
    2007-08-13

    Logged In: YES
    user_id=9375
    Originator: YES

    Ah, I think you told me already that there is no stack because there is no recursion,
    so each subroutine only has one slot for the return address. The problem are threads
    so it should have a return address for each thread. I will enjoy being puzzled with
    the other questions for a bit longer.

     
  • John Hansen
    John Hansen
    2009-01-26

    • assigned_to: nobody --> afanofosc_99