CodeWalrus

Development => Calculators => Calculator News, Coding, Help & Talk => Topic started by: Hayleia on February 19, 2015, 02:40:02 PM

Title: Run Axe program from an application ?
Post by: Hayleia on February 19, 2015, 02:40:02 PM
Basically what the title says.

I tried something stupid like

#Axiom(MEMKIT)
GetCalc("appvNope",1)->V
New(V,e9D93-V,5000)
GetCalc("prgmPROGRAM",Y0)
Copy(Y0,e9D93,5000)
(e9D95)() .9D95 to skip the AsmPrgm
Delete(V,e9D93-V,5000)
DelVar "appvNope"

but there are some problems. It does run the program from the app, and the program runs fine, but when it exits, there are problems (basically, if after running the program, I just do a "Return", the calculator turns off and RAM Clears when turned on).

I am pretty sure matref knows the answer to my problem after doing AxeSh :P
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 02:44:06 PM
Can't you just do something with some inline ASM magic?
(sorry, not helping. I'll try something out when im home, because i don't have memkit on my calc)
Title: Re: Run Axe program from an application ?
Post by: CKH4 on February 19, 2015, 03:00:45 PM
Is this attempting to create a shell with axe?
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 03:02:15 PM
Oh! Oh! Wont

V

be corrupted after running the program, causing some random location to be deleted?
Title: Re: Run Axe program from an application ?
Post by: Hayleia on February 19, 2015, 03:30:42 PM
Quote from: Cumred_Snektron on February 19, 2015, 02:44:06 PM
Can't you just do something with some inline ASM magic?
(sorry, not helping. I'll try something out when im home, because i don't have memkit on my calc)
Well inline ASM can always help, but only if someone gives the helping portion of ASM.

Quote from: CKH4 on February 19, 2015, 03:00:45 PM
Is this attempting to create a shell with axe?
Nope.

Quote from: Cumred_Snektron on February 19, 2015, 03:02:15 PM
Oh! Oh! Wont

V

be corrupted after running the program, causing some random location to be deleted?
Nope, I checked and it keeps the same value from the beginning to the end.
Title: Re: Run Axe program from an application ?
Post by: Dream of Omnimaga on February 19, 2015, 05:07:11 PM
This is most likely due to saferam or other memory conflicts. When you exit the program you need to ensure that the state of the calculator RAM (and in the case of ASM programs, ports) is identical to how it was before you launched the program in the first place. I could be wrong, though, since I don't do much Axe, but this seems like the common cause when we exit something and stuff messes up.
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 05:36:20 PM
Maybe put in a small test after
DelVar "appvNope"
to see if
Delete(V,e9D93-V,5000)
DelVar "appvNope"

is causing problems
Title: Re: Run Axe program from an application ?
Post by: Hayleia on February 19, 2015, 06:43:50 PM
What do you mean by "small test" ?
If I put a Text(0,,"Back to App") right after the call, it is displayed.
If I put a Text(0,,"Temp ram deleted") after the Delete, it is displayed.
If I put a Text(0,,"Appvar deleted") after the DelVar, it is displayed.
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 06:51:17 PM
hmm. But i think i've got a solution, but i'll have to test it out :P
Title: Re: Run Axe program from an application ?
Post by: Duke "Tape" Eiyeron on February 19, 2015, 07:39:08 PM
T'was a double post but I was there.
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 07:48:19 PM
Ah thnx.

So... I remembered there was a BCALL which runs an ASM program,
and i put it in an Axiom for you! :D
All the code you posted can now be replaced by a SINGLE line (well, 2 if you count #Axiom(RUN)):

Run("prgmPROGRAM")

The "Run(" token can be found in the stat-calc menu (QuadReg).
Have fun  ;)

Oh and btw the actual ASM which gets parsed form the axiom is a stunning 2 lines
EDIT: 6 lines. i fixed the asm_prgm_size part  ;)
Title: Re: Run Axe program from an application ?
Post by: matrefeytontias on February 19, 2015, 07:55:58 PM
Quote from: Hayleia on February 19, 2015, 02:40:02 PM
I am pretty sure matref knows the answer to my problem after doing AxeSh :P

/me comes to save the day

You have to use that certain BCALL called ExecutePrgm (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4E7C), but before that, you must save what is in asm_prgm_size ($89EC) somewhere, and you must restore it afterwards.

Cumred: you didn't take care of that asm_prgm_size part :P

EDIT : by the way, you probably wonder how to use it. So I did a nice opcode for you, just put a pointer to the name of the program in HL before calling it :
Asm(E72AEC89E5EF7C4EE122EC89)
Title: Re: Run Axe program from an application ?
Post by: Hayleia on February 19, 2015, 07:59:14 PM
Thanks both of you :D

Quote from: matrefeytontias on February 19, 2015, 07:55:58 PM
you must save what is in asm_prgm_size ($89EC) somewhere, and you must restore it afterwards.
How many bytes do I need to save ? 2 ?
Title: Re: Run Axe program from an application ?
Post by: matrefeytontias on February 19, 2015, 08:00:03 PM
Yeah two, but don't worry I edited the message with an opcode to execute directly.
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 08:05:25 PM
Quote from: matrefeytontias on February 19, 2015, 07:55:58 PM
You have to use that certain BCALL called ExecutePrgm (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:4E7C), but before that, you must save what is in asm_prgm_size ($89EC) somewhere, and you must restore it afterwards.

Cumred: you didn't take care of that asm_prgm_size part :P
Ah thanks for clarifying. I fixed it ;)
/me sees a replacing hex code
/me cries a little inside :(
Also why do you need to save the asm_prgm_size part? im interested because it seemed to run fine without :P
Title: Re: Run Axe program from an application ?
Post by: matrefeytontias on February 19, 2015, 08:07:01 PM
You can't fight the power of hand-written hex ~_~

Okay really, nice try :P but never assume that the OS has a logical behavior.
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 19, 2015, 08:08:13 PM
/me squints at ti
Title: Re: Run Axe program from an application ?
Post by: Dream of Omnimaga on February 19, 2015, 10:22:37 PM
Quote from: matrefeytontias on February 19, 2015, 08:07:01 PM
You can't fight the power of hand-written hex ~_~

Okay really, nice try :P but never assume that the OS has a logical behavior.
careful, you can get banned from Cemetech for referrring to hexadecimal-written ASM as hex *.*. Just kidding, although people hate it with a passion :P
Title: Re: Run Axe program from an application ?
Post by: TheMachine02 on February 20, 2015, 08:58:54 AM
Or you can use this : http://www.omnimaga.org/other-calculator-discussion-and-news/run-programs-axiom/ with will also take care of all errors/messing stuff that can, occurs.  :P
Title: Re: Run Axe program from an application ?
Post by: Snektron on February 20, 2015, 09:04:16 AM
While were on the topic (though this might be something completely different):
Does anybody happen to know how you can run Basic code from ASM or Axe?
(Just curious, im not making anything)
Title: Re: Run Axe program from an application ?
Post by: Hayleia on February 20, 2015, 09:12:34 AM
Quote from: TheMachine02 on February 20, 2015, 08:58:54 AM
Or you can use this : http://www.omnimaga.org/other-calculator-discussion-and-news/run-programs-axiom/ with will also take care of all errors/messing stuff that can, occurs.  :P
Thanks, I saw it when it was out but completely forgot about this -.-
edit The download link is broken (thanks Omnimaga).
edit Found it here https://www.omnimaga.org/the-axe-parser-project/%28axiom%29-run-%28unarchived%29-external-assembly-programs/msg289458/#msg289458

Quote from: Cumred_Snektron on February 20, 2015, 09:04:16 AM
While were on the topic (though this might be something completely different):
Does anybody happen to know how you can run Basic code from ASM or Axe?
(Just curious, im not making anything)
I found this while looking for what brought me to create this topic https://www.omnimaga.org/axe-language/running-basic-in-axe-from-an-application/msg380255/#msg380255
Doesn't answer my question but seems to answer yours ;)
Title: Re: Run Axe program from an application ?
Post by: CKH4 on February 20, 2015, 05:56:35 PM
That would be cool to have hybrid axe-basic programs. It would make a lot of stuff much easier for n00bs like me
Title: Re: Run Axe program from an application ?
Post by: Dream of Omnimaga on February 20, 2015, 07:53:24 PM
Another solution could be the opposite: Have the launcher program be in BASIC and launch Axe sub-programs with the Asm command. Just like hybrid games.