Author Topic: Memory Juggling?  (Read 4840 times)

0 Members and 1 Guest are viewing this topic.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Memory Juggling?
« on: September 04, 2010, 10:48:18 pm »
So i had this idea recently, inspired by the fact that programs are loaded to $9C95 and therefore only have about 8800 bytes of space to excecute in.  BUT, what if after the program is safely copied into $9C95, it then is shifted down to a lower location, and the memory that it overlaps is moved around so that nothing is earased.  If the Assembly program is completely self sufficient (like no OS calls or whatever), and all the labels were compiled as if the program was copied there in the first place,  could it be run safely assuming it rearranged the memory back the way it was before it exited back to the OS?

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Memory Juggling?
« Reply #1 on: September 04, 2010, 10:51:23 pm »
That's fine if your program disables the OS interrupt and doesn't use a single bcall.  But if it does, it's going to be reading and writing over your program memory where it expects all the OS variables to be causing the bcall to not work properly either so it will surely cause a ram clear.
« Last Edit: September 04, 2010, 10:52:08 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Memory Juggling?
« Reply #2 on: September 04, 2010, 10:54:06 pm »
Hmmm but this would likely be very complicated to get working, since you would either only use relative jumps, or set the .org statement to a separate value.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Memory Juggling?
« Reply #3 on: September 04, 2010, 11:04:34 pm »
Its actually not that difficult.  But you need somewhere to store the ~7k bytes.  If you use the extra ram page, then that would work very well and you could execute programs as large as half the free ram ~12k bytes.  If you have your program in 2 parts, an archived executable and another program that runs it, then you can use the entire 16k bytes.  But unfortunately, the regular 83+ doesn't have the extra page.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline BuckeyeDude

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 283
  • Rating: +42/-0
    • View Profile
Re: Memory Juggling?
« Reply #4 on: September 04, 2010, 11:09:15 pm »
If you have extra ram pages, you might as well just swap in the ram page and use that to execute the code :P Also if you need more 8.8k of executable code you should really be using an application. That's really what they were created for and the reason the 8.8k barrier exists.

Offline Jonius7

  • python! Lua!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1918
  • Rating: +82/-18
  • Still bringing new dimensions to the TI-nspire...
    • View Profile
    • TI Stadium
Re: Memory Juggling?
« Reply #5 on: September 04, 2010, 11:22:08 pm »
wouldn't that be hard, it's not just as simple as copying it, there's extra stuff such as configuration for that particular part of memory and more... ie" it's not just black (filled) and white (empty)

...does that make sense?
« Last Edit: September 04, 2010, 11:22:49 pm by jhgenius01 »
Programmed some CASIO Basic in the past
DJ Omnimaga Music Discographist ;)
DJ Omnimaga Discography
My Own Music!
My Released Projects (Updated 2015/05/08)
TI-nspire BASIC
TI-nspire Hold 'em
Health Bar
Scissors Paper Rock
TI-nspire Lua
Numstrat
TI-nspire Hold 'em Lua
Transport Chooser
Secret Project (at v0.08.2 - 2015/05/08)
Spoiler For Extra To-Be-Sorted Clutter:

Spoiler For Relegated Projects:
TI-nspire BASIC
Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled) | Cosmic Legions (stalled)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Offline Iambian

  • Coder Of Tomorrow
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 739
  • Rating: +216/-3
  • Cherry Flavoured Nommer of Fishies
    • View Profile
Re: Memory Juggling?
« Reply #6 on: September 05, 2010, 12:00:16 am »
If you wanted more execution space, it's as BuckeyeDude says. Use an app.

Now, sometimes you just need more contiguous RAM than the OS allows and you don't want to eat up much of the calc's "Free RAM". I've done a little memory juggling in CaDan to allow me access to $8000 and $8EFF by selectively copying stuff to plotsscreen and appbackupscreen. Selective copying, so I can safely eat up all the other saferam areas between the mentioned addresses. Might want to check out it's source if you want to do this.

Sorry for not really answering you question, tho. You might want to do a little study (by looking at the ti83plus.inc's RAM locations) and find out what memory you might want to shuffle away and what memory you can safely overwrite. Also include in your little study areas that can be reliably initialized if you don't want to or need to save that information. What comes to mind is this chunk of RAM at "statVars" and using bcall(_DelRes) to "invalidate statistics" so the OS doesn't crash if you try to do statistics after using that RAM as scratch.
A Cherry-Flavored Iambian draws near... what do you do? ...

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Memory Juggling?
« Reply #7 on: September 05, 2010, 12:52:41 am »
Alright thanks for all the info guys :) I was just speculating, because my PortalX game (which is in Axe) is getting rather large, maybe too large for the entire program to fit into one page.  I think i will be able to get all of my *code* into 16K, but i am trying to figure out what to do with the data.

One idea was to have all the data in an Appvar, but thats a hassle to have more than one file
Another idea was to try to make it a program and do the fancy memory swapping so that i could get more execution space, but it seems that the limitations of Axe in regards to filesize is very hard to code around.  Maybe i will put in a request for 2 page apps, as long as the 2nd page contains only data?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Memory Juggling?
« Reply #8 on: September 05, 2010, 12:57:31 am »
Well the good thing is that appvars won't show up in the APPS/PRGM menus, just in mem menu. At least there are two menus that they won't clutter for people who got many programs.

As for 2 pages apps, I think Quigibo had the idea in mind, but I'm not sure if he's adding it for the next version.