Author Topic: Swapping Pages during Program...  (Read 4588 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Swapping Pages during Program...
« on: November 10, 2010, 12:34:41 pm »
Okay, I have another APP related question. I have another random project that I am working on and I wanted to store all of the data in an APP, but have it called and executed by an assembly program. If I load it into 4000h, what problems will I have while the program is running? I still don't know what that page does, I only know that I swap that page to copy archived data to RAM sometimes.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Swapping Pages during Program...
« Reply #1 on: November 10, 2010, 05:26:22 pm »
That is super easy. What you'll be interested in is port (06), that controls what page is swapped in for the $4000-$7FFF range. So values 0 - $7F are flash and $80-$87 are ram.

Here's how you'd do it.
Code: [Select]
in a, (06)
push af ;make sure to save this for later

ld hl, appName
rst 20h
bcall(_chkFindSym)
jr c, noAppFound ;a = flash page of app

out (06), a

ld hl, $4000
ld de, $9872 ;do whatever with the data
ld bc, $300 ;you can even jump to it and run it
ldir

pop af
out (06), a

And just a few notes: The page you output to port (06) doesn't have to be the app page, you can output whatever you want, but just realize that whatever page you output is what you'll be looking at. And also, you can have the page swapped in for your entire program, Ti OS has no problem with what page is in port (06). Just be sure to put it back when you are done considering that your program returns to somewhere around $6000.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Swapping Pages during Program...
« Reply #2 on: November 10, 2010, 05:58:27 pm »
Actually, you have to bcall(_FindApp) instead of bcall(_chkFindSym).
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Swapping Pages during Program...
« Reply #3 on: November 10, 2010, 09:59:06 pm »
Oh, I know how to do all that, I was just wondering if I could still use things like b_calls and stuff. I have been working with the flash for a few months now, but I never figured out what that page does.

Sorry for not specifying.

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: Swapping Pages during Program...
« Reply #4 on: November 10, 2010, 10:03:51 pm »
Essentially, if you use a b_call, it switches out the flash pages for you.  Unless your wanting to b_call your app from another location in ram. Essentially, you could swap in the page and call it yourself for all the work that setting up a b_call would take.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Swapping Pages during Program...
« Reply #5 on: November 10, 2010, 10:08:50 pm »
Okay, so I want to put a bunch of data into an app so that it can be in a fixed spot of archive memory. Could I then, say, put a program or two into that app and call them using a RAM based program? (while I am still learning how to make an actual app)
I plan to put that special exiting b_call as the first line, so the rest of the program will start at 4083.

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Swapping Pages during Program...
« Reply #6 on: November 10, 2010, 10:25:58 pm »
Why not put your code into the app as well?

But yeah, you can basically do whatever you want with port 6 - the OS doesn't mind - but you do have to be careful to restore the port to its original value when your program exits.  Also note that you need to have the correct value in port 6 when calling shell library routines (e.g., ionFastCopy).

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Swapping Pages during Program...
« Reply #7 on: November 10, 2010, 10:33:18 pm »
Well, I was actually going to store all of the random calls and hooks I have made into the app for when I make programs. This way they can be used by all of my programs. I do not fully understand all of the stuff I need for apps, also. Plus, I would prefer to test code in RAM and make modifications that way instead of constantly loading and deleting apps. Thanks for the info, too. I am pretty confident now that I cn go ahead and experiment a little more.