Hi, I'm new to Ti84 Plus CE programming, but I'm making a pretty large program. I'm only at 37k program size right now but I'm anticipating going over the size limit eventually. I've learned that the toolchain will auto-split my program into AppVars that it loads at runtime. However, apparently the extra code is copied into RAM when run. This is a problem because I need all the RAM I can get for storing various game objects.

My confusion is that the doc for the toolchain says:
Quote:
Running code directly from a flash memory instead of copying it to RAM first is known as XIP (execute-in-place) flash.

The TI-84 Plus CE continues to use an XIP design like the TI-83 Plus before it.


Therefore, why does the program need to be copied into RAM from flash? And is there any way to avoid this?

Also, kind of related question: Why is the program size limit 65k, which is 2^16, when the processor is 24-bit?
I'm going to assume that the docs are referring to how the OS functions instead of how a program is run because as far as I know programs are always copied to RAM to be run.

Program size is limited to a 16 bit size value because the structure of programs only allows for 2 bytes to represent the size.
You can read from flash memory and use it to store program objects/data instead if that is your question.

What type of program data do you have?
The eZ80 processor has very insufficient support for position-independent code. Unlike the OS (which is compiled to run from a specific address in Flash) and Flash Applications (which contain relocation info and the OS actively relocates them when they're moved), programs have no way of knowing where they'll be stored in Flash. That's why they're always loaded into RAM, in a specific location.

Also note that user RAM (where BASIC variables are stored, and what shows in the memory menu) is where the program is loaded, which is a completely separate area from static BSS and dynamic allocations in C and doesn't affect those.

As Mateo mentioned, it is possible to use AppVars to store data, and these don't have to be loaded into RAM unless you need to modify them. For things like sprites/images, the toolchain already has good tooling for accessing those directly from archived AppVars.

The program size limit is 65k because the program format is a legacy of the systems with 16-bit address space and far less than 65k RAM.
RoccoLox Programs wrote:
programs are always copied to RAM to be run.
To elaborate on why it works this way: it's not really feasible to generate position-independent code (PIC) for (e)Z80, and the system lacks virtual memory so you can't remap data stored somewhere in memory to appear at a fixed address. Copying programs to RAM allows them to run from a known address so the code doesn't need to be position-independent: they always get loaded at the same address.

Apps on the CE behave a little differently: my understanding is that the OS applies relocations when installing an app, because apps execute directly from flash. On the monochrome calculators, this isn't needed because apps are instead mapped into memory bank 1 (0x4000-0x8000) with paging (and this is one reason why apps are always multiples of 16 kilobytes in size).
Thanks for the responses everyone.

Quote:
Also note that user RAM (where BASIC variables are stored, and what shows in the memory menu) is where the program is loaded, which is a completely separate area from static BSS and dynamic allocations in C and doesn't affect those.


This is good to hear. Is this documented anywhere? Is this also where the dynamically loaded libraries from LibLoad go? What's the size of this area, e.g. how many of the extra appvars generated from the toolchain can fit there at runtime?

Also, if I do choose to display images or access readonly data straight from flash (like in some of the examples), how much slower is it than displaying from RAM?
Hopefully this helps answer your first question.
RoccoLox Programs wrote:
Hopefully this helps answer your first question.


Yeah, I’ve seen that diagram. I’m more asking where the extra loaded libraries go, since they couldn’t go where the main program already resides.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement