Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: FinaleTI on November 17, 2010, 09:19:19 pm

Title: Executing nostub progs
Post by: FinaleTI on November 17, 2010, 09:19:19 pm
Is there a way to execute a nostub program from an Axe app, or would I need ASM code to use with Asm()? If so, what would that routine be?
Title: Re: Executing nostub progs
Post by: Runer112 on November 17, 2010, 09:39:29 pm
I believe it's actually quite simple to jump from an App to a nostub program and then back. Say the pointer to the program name you wanted to jump to was in P:
Code: [Select]
PAsm(E7EF7C4E)This would execute the program whose name is pointed to by P, just as if you had run it by typing Asm(prgmNAME) on the homescreen, and then return right back to where you were in the App when the program exits.

Can someone verify that this is safe to do? It appears to at least work for simple examples, but could any bcalls or other things during the time the program is executing overwrite data in the App?
Title: Re: Executing nostub progs
Post by: squidgetx on November 18, 2010, 07:13:28 am
If it works, that could be very useful....

/me thinks he knows what FinaleTI is thinking
Title: Re: Executing nostub progs
Post by: FinaleTI on November 18, 2010, 08:56:22 pm
It this (http://ourl.ca/7950/142864) is what you're thinking I'm thinking, then yes.

I did a small test that used a simple multi-page program I scrounged up, and executed it from an app. It worked flawlessly. :)
Title: Re: Executing nostub progs
Post by: DJ Omnimaga on November 18, 2010, 08:58:44 pm
If it works, that could be very useful....

/me thinks he knows what FinaleTI is thinking
Getting around the 16 KB limit? I'm wondering...
Title: Re: Executing nostub progs
Post by: FinaleTI on November 18, 2010, 09:00:28 pm
That's the idea. ;D
Title: Re: Executing nostub progs
Post by: Xeda112358 on November 18, 2010, 09:02:37 pm
Well, I see a few potential problems. For one, the program won't be called from a fixed location, so that means any calls will be wrong and could crash your calculator. Secondly, if the code executes beyond address BFFFh, I believe the calc automatically crashes.
Title: Re: Executing nostub progs
Post by: FinaleTI on November 18, 2010, 09:12:01 pm
Well, were does this copy to program too? If it copies it to 9D95h (I think that's right) then that would give me about 8810 bytes of code. Builderboy's multipage programs swap around a program's code to allow for multiple virtual pages to execute. Each virtual page essentially acts as a program and the code on the other pages isn't touched until you swap pages. So if the pages aren't larger than the code limit, I think that's OK.
But as for calls being wrong, what kind of calls? I've had Runer's code execute a simple multi-page program, as well as my current walking engine for Nostalgia without any noticeable adverse effects.
Title: Re: Executing nostub progs
Post by: Xeda112358 on November 18, 2010, 09:15:08 pm
Sorry, it looks like a few other posts occurred before I finished... :D Okay, it looks like there are some working ideas.
Title: Re: Executing nostub progs
Post by: calc84maniac on November 18, 2010, 09:31:19 pm
The main problem I can see is that all of these Asm programs need to be in RAM, which might take up a lot of space. You could unarchive them before calling and archive afterwards, but that might cause garbage collects.
Title: Re: Executing nostub progs
Post by: FinaleTI on November 18, 2010, 10:37:45 pm
I create them by copying data from archived appvars, so nothing needs to be rearchived, as Axe can read from the archive. Also, I would only have one program in the RAM at a time, so as to cut down on my memory footprint.
The temp program I create to house these programs gets deleted when the app quits.
I'll have to see about uploading a demo of what I'm doing when I'm not using my iPod.
Title: Re: Executing nostub progs
Post by: Builderboy on November 19, 2010, 06:26:29 am
Note that the address $9D95 is inside user RAM.  What does the hex code you posted do exactly?  If it copies it to $9D95 it needs to make sure it doesn't overwrite any user variables.  If it jumps straight to the address, absolute jumps and calls wont work anymore either.
Title: Re: Executing nostub progs
Post by: Runer112 on November 19, 2010, 10:13:59 am
The hex code I posted runs the assembly program whose name is pointed to by hl, just like if you were to run it from the homescreen with Asm(prgmNAME). It uses the bcall ExecutePrgm.
Title: Re: Executing nostub progs
Post by: squidgetx on November 19, 2010, 02:10:58 pm
^ so it simply stops execution in the current program and executes the pointed-to program, then returns to the original program?

I can't think of anything that might interfere...

Edit: something sort of related was discussed here (http://ourl.ca/7424)
I'm not sure what ended up happening though :x
Title: Re: Executing nostub progs
Post by: Builderboy on November 20, 2010, 03:48:05 am
The hex code I posted runs the assembly program whose name is pointed to by hl, just like if you were to run it from the homescreen with Asm(prgmNAME). It uses the bcall ExecutePrgm.

oh okay gotcha :D
Title: Re: Executing nostub progs
Post by: squidgetx on November 20, 2010, 07:23:04 am
So this could actually work and be a feasible way of getting around the 8k/16k limit?
Title: Re: Executing nostub progs
Post by: DJ Omnimaga on November 20, 2010, 09:58:21 am
Hmm now that would be cool if it's feasible. O.O
Title: Re: Executing nostub progs
Post by: squidgetx on November 23, 2010, 11:57:27 am
Runer: the hex you pointed takes the pointer to the program from hl?
Title: Re: Executing nostub progs
Post by: Runer112 on November 23, 2010, 01:03:10 pm
It takes a pointer to a zero-terminated string that contains the name of the program.
Title: Re: Executing nostub progs
Post by: squidgetx on November 23, 2010, 06:09:44 pm
well, I just meant that if I decided to put the hex into a subroutine, I could call it by loading the pointer to the zero-terminated string into the last argument of the routine call (sub(EXC,pointer).....Lbl EXC:Asm(E7EF7C4E):Return)