[Free42] RTN Stack Full
|
01-14-2024, 10:29 PM
Post: #1
|
|||
|
|||
[Free42] RTN Stack Full
I used pl0_hp42s.py to compile this recursive PL/0 program to calculate the factorial of a number \(n\):
Code: VAR n,f; This is the result: Code: GTO 00 # main To my surprise it worked using Free42. To analyse it further, I reduced the program to: Code: 00 { 19-Byte Prgm } You can run it with any integer number from 0 to 1023 and will get \(\pi\). However, with 1024 you will get an error message: RTN Stack Full In HISTORY I found the following remark: Quote: On a real HP-42S or an HP-41C the program would stop at line 09 when all return addresses are consumed. Instead of \(\pi\) it would display \(0\). In case of the fact program from above the following lines are not executed: Code: RCL 02 # f Therefore the result is not displayed. Conclusion For any meaningful program, recursion doesn't work on a real HP-42S. However, if the target machine is Free42, it can be used within the limitation of 1024 stack levels. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
[Free42] RTN Stack Full - Thomas Klemm - 01-14-2024 10:29 PM
RE: [Free42] RTN Stack Full - Thomas Okken - 01-14-2024, 11:20 PM
RE: [Free42] RTN Stack Full - Thomas Klemm - 01-15-2024, 12:17 AM
RE: [Free42] RTN Stack Full - Thomas Okken - 01-15-2024, 02:14 AM
|
User(s) browsing this thread: 1 Guest(s)