Post Reply 
Clearing Return Stack on HP-15C
10-06-2024, 12:58 PM (This post was last modified: 10-06-2024 04:01 PM by Pekis.)
Post: #1
Clearing Return Stack on HP-15C
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]
Find all posts by this user
Quote this message in a reply
10-06-2024, 05:11 PM
Post: #2
RE: Clearing Return Stack on HP-15C
(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
Find all posts by this user
Quote this message in a reply
10-06-2024, 07:17 PM
Post: #3
RE: Clearing Return Stack on HP-15C
(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!
Find all posts by this user
Quote this message in a reply
10-06-2024, 07:20 PM (This post was last modified: 10-06-2024 07:20 PM by Pekis.)
Post: #4
RE: Clearing Return Stack on HP-15C
(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 ...
Find all posts by this user
Quote this message in a reply
10-06-2024, 07:54 PM
Post: #5
RE: Clearing Return Stack on HP-15C
(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
Find all posts by this user
Quote this message in a reply
10-07-2024, 03:22 AM
Post: #6
RE: Clearing Return Stack on HP-15C
(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.
Find all posts by this user
Quote this message in a reply
10-07-2024, 07:26 AM
Post: #7
RE: Clearing Return Stack on HP-15C
(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
Find all posts by this user
Quote this message in a reply
10-07-2024, 07:37 AM
Post: #8
RE: Clearing Return Stack on HP-15C
(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
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 7 Guest(s)