HP Forums
Clearing Return Stack on HP-15C - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Clearing Return Stack on HP-15C (/thread-22455.html)



Clearing Return Stack on HP-15C - Pekis - 10-06-2024 12:58 PM

Hello,

I'm in the process of writing a special HP-15C special simulator (yes, another one Smile) for Android with Java, with a dot matrix display, so with symbols (or codes) in programming mode, but without Complex nor Matrix support, uneasy on the HP-15C.

It's a very interesting journey through the stackLift-land Smile and I have a question:

We know that if there are more than 7 nested GSB, the real HP-15C throws a "ERROR 5".
But what if there are 6 nested ones in a program and 4 in another one; we interrupt the first program while at 6th nesting level with R/S, do some SST, and then launch the second program.
Will the HP-15C throw and "Error 5" at the second nesting level of the second program ?

So, when does the HP-15C clear the return stack, after a "ERROR 5", or after a CLEAR PRGM instruction in normal mode, ... ?

Thanks

That special 15C will look more or less like this, ... don't bother with traces of an old chrono/timer program used for building it
[Image: SP15C.jpg]


RE: Clearing Return Stack on HP-15C - Nihotte(lma) - 10-06-2024 05:11 PM

(10-06-2024 12:58 PM)Pekis Wrote:  So, when does the HP-15C clear the return stack, after a "ERROR 5", or after a CLEAR PRGM instruction in normal mode, ... ?

Thanks

That special 15C will look more or less like this, ... don't bother with traces of an old chrono/timer program used for building it

Hello Pekis,

The HP15C PUSH all return address from a GSB instruction and stops when the dedicated stack is full
So a RTN instruction POP an address and this releases a level
The HP15C has the particularity of conserving all its context after passage in OFF mode
Probably it keeps all again on error (i doesn't make the test), but without acknowledging the error!

Did someone test it ?

Keep yourself healthy!

Laurent


RE: Clearing Return Stack on HP-15C - naddy - 10-06-2024 07:17 PM

(10-06-2024 12:58 PM)Pekis Wrote:  We know that if there are more than 7 nested GSB, the real HP-15C throws a "ERROR 5".
But what if there are 6 nested ones in a program and 4 in another one; we interrupt the first program while at 6th nesting level with R/S, do some SST, and then launch the second program.
Will the HP-15C throw and "Error 5" at the second nesting level of the second program ?

I played around with this, and as far as I can tell, this allows you to push more than 8 returns on the return stack, but the older ones are lost: If I interrupt (R/S) a program with 7 pending returns, execute another program with 7 returns, then resume (R/S) the first one, only 1 pending return is executed. There is no error!


RE: Clearing Return Stack on HP-15C - Pekis - 10-06-2024 07:20 PM

(10-06-2024 05:11 PM)Nihotte(lma) Wrote:  The HP15C PUSH all return address from a GSB instruction and stops when the dedicated stack is full
So a RTN instruction POP an address and this releases a level
The HP15C has the particularity of conserving all its context after passage in OFF mode
Probably it keeps all again on error (i doesn't make the test), but without acknowledging the error!

Of course I understand that the HP15C push/pop one level every time it encounters a GSB/RTN so that at the end of a program, the return stack is clear.
The problem is when you interrupt a program currently running a subroutine at a deep level. If you launch a second program, when those return adresses from the first program will be cleared ?... If not, they would prevent the return stack to use of all of ts 7 levels in the second program ...


RE: Clearing Return Stack on HP-15C - Nihotte(lma) - 10-06-2024 07:54 PM

(10-06-2024 07:20 PM)Pekis Wrote:  Of course I understand that the HP15C push/pop one level every time it encounters a GSB/RTN so that at the end of a program, the return stack is clear.
The problem is when you interrupt a program currently running a subroutine at a deep level. If you launch a second program, when those return adresses from the first program will be cleared ?... If not, they would prevent the return stack to use of all of ts 7 levels in the second program ...

Right!

In fact, you can also launch the second program with 'f E' or with 'GSB E', for example!

Keep yourself healthy!

Laurent


RE: Clearing Return Stack on HP-15C - brouhaha - 10-07-2024 03:22 AM

(10-06-2024 05:11 PM)Nihotte(lma) Wrote:  The HP15C PUSH all return address from a GSB instruction and stops when the dedicated stack is full

Executing a GSB doesn't "stop" when the return stack is full. It just loses the oldest entry.

Aside from doing a RTN when there's only one address on the return stack, there are several things that can explicitly clear the return stack, including CLR PRGM, executing RTN in run mode, and modifying the program (inserting or deleting program steps). I've identified the microcode subroutine that clears the return stack, but I haven't yet figured out the purpose of some of the microcode routines that call it.


RE: Clearing Return Stack on HP-15C - Pekis - 10-07-2024 07:26 AM

(10-07-2024 03:22 AM)brouhaha Wrote:  Executing a GSB doesn't "stop" when the return stack is full. It just loses the oldest entry.

Aside from doing a RTN when there's only one address on the return stack, there are several things that can explicitly clear the return stack, including CLR PRGM, executing RTN in run mode, and modifying the program (inserting or deleting program steps). I've identified the microcode subroutine that clears the return stack, but I haven't yet figured out the purpose of some of the microcode routines that call it.

Thanks for the explanation !

So, if I understand, once a program is running, it always accepts 7 GSB levels ... but in the worst case, if there is a R/S instruction in the program, just before entering the 8th GSB level (which would have thrown a "ERROR 5"), and then manually do R/S to resume the program execution, the HP15C will never report the problem nor end the program normally... Gasp


RE: Clearing Return Stack on HP-15C - Thomas Klemm - 10-07-2024 07:37 AM

(10-07-2024 03:22 AM)brouhaha Wrote:  Executing a GSB doesn't "stop" when the return stack is full. It just loses the oldest entry.

If the return stack is full, the program is stopped and Error 5 is displayed.
This can be tested with the following program:
Code:
   001 { 42 21 11 } f LBL A
   002 {    43 35 } g CLx
   003 { 42 21  0 } f LBL 0
   004 {       31 } R/S
   005 {        1 } 1
   006 {       40 } +
   007 {    32  0 } GSB 0

f A
0.0000

R/S
1.0000

R/S
2.0000

R/S
3.0000

R/S
4.0000

R/S
5.0000

R/S
6.0000

R/S
7.0000

R/S
Error 5

On the other hand, if you run GSB 0 after the 7th run, the return stack gets cleared:

(...)

R/S
7.0000

GSB 0
7.0000

R/S
8.0000

R/S
9.0000

R/S
10.0000

R/S
11.0000

R/S
12.0000

R/S
13.0000

R/S
14.0000

R/S
Error 5