Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: rizoom on April 05, 2011, 12:15:22 pm

Title: ASM code and program editoring
Post by: rizoom on April 05, 2011, 12:15:22 pm
Hi,

I saw that in the Axe Parser application, when an error occurs, it is always possible to press the "prgm" button, and it opens the program editor exactly where the error is located.

Because it is sometimes very painful to scroll down the entire program, I would like to make an Axe Parser program that can open another program at the location I want.

Is there an ASM code for that? How can I do?

Rizoom

Sorry if there are some english mistakes (I'm french)
Title: Re: ASM code and program editoring
Post by: Xeda112358 on April 05, 2011, 12:18:11 pm
I'm not sure how to do that, sorry :/ I am curious, too. It will probably involve installing hooks, though.
Title: Re: ASM code and program editoring
Post by: rizoom on April 05, 2011, 12:24:38 pm
What's that?
Title: Re: ASM code and program editoring
Post by: Xeda112358 on April 05, 2011, 12:29:28 pm
Are you familiar with Celtic 3 or xLIB? They use hooks that change the way commands work. There might be a hook to change how errors work.

Sorry, my french is horrible XD :

Êtes-vous familiare avec les apps Celtic 3 et xLIB? Ils utilisent des <<hooks>> pour changer les commands. Peut-être il y a un <<hook>> pour les erreurs?
Title: Re: ASM code and program editoring
Post by: FloppusMaximus on April 05, 2011, 09:22:02 pm
I don't know how the Axe parser does it.  But what I would do is this:

- set parseVar to the name of the program, begPC and endPC to the starting and ending addresses, and curPC to the location of the error - just as if you're really executing the program
- set errNo to a valid error code greater than 128, indicating an editable error
- reset the stacks (B_CALL ResetStacks / ld sp, (onSP))
- load the cxError context (ld a, cxError / B_CALL NewContext0)
- and send a k2 keycode (ld a, k2 / B_JUMP MonForceKey)

This can only be done by a Flash app.

From an Asm( program, it's simpler: I would simply set up parseVar, begPC, curPC, and endPC, as before, then throw the desired error, and let the user choose whether to Quit or Goto it.  (If the built-in error messages aren't enough for you, you can use AppErr1/AppErr2 to display a custom error message.)  I don't think it would be worth trying to do anything fancier, and anything fancier would be likely to break in nasty ways.

Shell programs absolutely cannot do this kind of thing ever.

Edit: Oops, I made a couple of mistakes there.  You want an error code with bit 7 set, not bit 0, and it does have to be a valid error code.  And directly sending kGoto doesn't quite work because there's still a popup active.
Title: Re: ASM code and program editoring
Post by: Quigibo on April 06, 2011, 07:29:02 pm
Wouldn't this force the program to scroll to the error rather than instantly appearing at the error?  Or does this do that for you when you set curPC?
Title: Re: ASM code and program editoring
Post by: FloppusMaximus on April 08, 2011, 12:00:43 am
You're right, that does seem to be the case.  What would you do instead?