HP Forums
[WP34s] Question about ERR - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: [WP34s] Question about ERR (/thread-202723.html)



[WP34s] Question about ERR - fhub - 10-23-2011

Is it possible that the ERR command is changing or destroying the return stack? :-(

In my main program I call a subroutine (with XEQ 81) and this subroutine makes a loop with a maximum of 100 runs. If the this loop reaches the desired accuracy before the counter is at 100, it makes a usual RTN and everything is working fine.

But if the counter reaches 100 I have a ERR 20 statement and a GTO 81 just after it, so if I just press R/S when the error message appears it repeats this subroutine (GTO 81) and should try another 100 iterations.

Now if within these next 100 iterations the accuracy is ok, then it goes to the RTN command again and so should return to the main program - but it doesn't! :-(

It jumps to the very first program step as if this RTN in the subroutine would be the RTN in the main program.

So I'm wondering if this ERR command has any effect on the return stack? Maybe it resets this stack?

Franz


Re: [WP34s] Question about ERR - Marcus von Cube, Germany - 10-24-2011

If I read the code correctly, ERR should not kill the stack but it decrements the program counter which is probably not what you want. Clearing the return stack might be a side effect which is not intended. I have to verify this.

Edit: I just found the piece of code that resets the return stack pointer. I cannot easily change this because an error in XROM might leave you in an illegal state. I'll discuss this with Pauli.


Edited: 24 Oct 2011, 4:00 a.m.


Re: [WP34s] Question about ERR - Paul Dale - 10-24-2011

Clearing the return stack on a hard error is the intended behaviour. At least until the triumvirate is convinced otherwise :-)


- Pauli


Re: [WP34s] Question about ERR - fhub - 10-24-2011

Quote:
Clearing the return stack on a hard error is the intended behaviour. At least until the triumvirate is convinced otherwise :-)

Well, I would say using the ERR command in a program is a bit different to a 'hard error' produced by the XROM (because of an illegal operation).

If the programmable ERR command does really reset the return stack, then this command is almost useless for own programs.

So please rethink again your position about this issue ...

Franz


Re: [WP34s] Question about ERR - fhub - 10-24-2011

One more thing about ERR:

Yesterday I've even checked if an ERR command in my program would clear the ENTRY? flag - I hoped it would do it and in fact it did! :-)

So it's very comfortable to check if the user has entered any new value before pressing R/S on an intentional ERR command in the program to decide what to do afterwards. But if ERR has this side-effect of clearing the return stack then all this won't work of course.


Re: [WP34s] Question about ERR - Paul Dale - 10-24-2011

A program stopping should clear the entry flag.

If it doesn't it is a bug that will be fixed.


- Pauli


Re: [WP34s] Question about ERR - fhub - 10-24-2011

Quote:
So please rethink again your position about this issue ...

Oh, I just see that my request was granted - very nice, thanks! :-)

Now my Polynomial RootSolver is indeed ready. The only problem left is to improve the convergence speed a bit, because as Marcus told me a real HP-20b/30b is quite slow on some bad-conditioned polynomials.

But I've already an idea to solve this speed problem. Unfortunately it will need still more program steps (currently about 250), and I hoped I could put this PRS program together with my TVM-Solver into one flash region. :-(

(well, maybe I should make the input and output a bit less comfortable!? ;-))

Franz.