The following warnings occurred:
Warning [2] Undefined array key 145677 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 145677 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





A reversed numbering scheme of the HP48's RPN stack



#2

Hi all,

On HP48 calculators or similar, the stack level in which objects are pushed is the first. When you push another object, the object at first level will go to level two, while the currently pushed object will go to level one.
This is practical for everyday use of the calculator but not for
programming. Anyone who has written a RPL program for HP48 may know how cumbersome the stack is for storing things. You always have to wonder which level your data is; as this level change every time you push an objet to the stack or pop one, this quickly become unbearable.

I have just thought about numbering the stack levels "upside down", that is, the level in which you push object is the one with the highest number; the "oldest" level is numbered with one. As you may notice, pushing or DROPing objects does not change numbers of other objects.

As an illustration, I wrote a small utility which provides the RSIZE, RRCL and RSTO commands. These commands may recall you the SIZE, RCL and STO commands of the HP41 (I wrote them precisely because I like the RPN way of the HP41).

I called this small program REGS. Here are the source. The comments follow. On my HP50g, BYTES gives #D54Fh and 626.5:

%%HP: T(3)A(D)F(.);
DIR
RSIZE
\<< 1. RCHKNARGS \-> N
\<< N ~RSIZE -
IF DUP 0. \>=
THEN 1. SWAP
START 0.
DEPTH ~RSIZE - ROLLD
NEXT
ELSE NEG 1.
SWAP
START DEPTH N
- ROLL DROP
NEXT
END N '~RSIZE'
STO
\>>
\>>
RRCL
\<< 1. RCHKNARGS \-> N
\<<
IF N ~RSIZE \>= N
0. < OR
THEN # 203h
DOERR
ELSE DEPTH
~RTOP - N - PICK
END
\>>
\>>
RSTO
\<< 2. RCHKNARGS \-> N
\<<
IF N ~RSIZE \>= N
0. < OR
THEN # 203h
DOERR
ELSE DEPTH
~RTOP - N - \-> n
\<< n ROLL DROP
n 1. - ROLLD
\>>
END
\>>
\>>
RDEPTH
\<< DEPTH ~RTOP -
~RSIZE -
\>>
RCHKNARGS
\<<
IF RDEPTH 1. - >
THEN # 201h DOERR
END
\>>
~RSIZE 0.
~RTOP 0.
END

== Usage:

RRCL ( n --> obj )
Recall the content of the n-th register (betwen 0 and ~RSIZE-1).

RSTO ( obj n --> )
Put the specified object in the n-th register.

RSIZE ( n --> )
Set the size of the registers area to the integer n. This size is internally stored in the global variable '~RSIZE' (you may not modify it).

RDEPTH ( --> n )
Returns the number of available levels in the stack. The levels that are part of the registers area are considered as unavailable. (And you may not want to modify those without using RSIZE, RRCL or RSTO.)


== Notes:

The '~RTOP' global variable specifies the level from the last one at which the registers area starts. You usually want to let it to the value 0, so that the registers area is at the very top levels of the stack. If you want to set this variable, do it before using RSIZE.

Of course, these programs were written only to illustrate how easy the reversed numbering scheme of the stack is (and because the HP41's RPN way is nice). Indeed, note that the RRCL is as simple as « DEPTH ~RTOP - N - PICK », all other commands are for error checking.

If anyone like these commands, I may write and gather them in a SysRPL library (with other commands such as RSTO+, RSTO-, etc).

Regards,

Khanh-Dang


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP 50g - select characters on the stack, copy/paste Sean Freeman 7 2,609 11-20-2013, 07:11 AM
Last Post: Sean Freeman
  Prime: Placing more than 1 item on the RPN stack in a single program? John Colvin 4 2,204 11-19-2013, 08:59 AM
Last Post: Miguel Toro
  emu48 - copy stack doesn't work (as expected) Thomas Radtke 2 1,924 11-11-2013, 02:19 PM
Last Post: Thomas Radtke
  HP Prime Stack operations from within a program John Colvin 1 1,341 11-08-2013, 09:45 PM
Last Post: Helge Gabert
  [PRIME] RPN: another attempt at returning more than one value to the RPN stack Marcus von Cube, Germany 5 2,382 11-05-2013, 02:44 AM
Last Post: Marcus von Cube, Germany
  Prime: Anyway to refresh stack? kris223 5 2,070 10-16-2013, 05:09 PM
Last Post: kris223
  hp prime - sending program results to the stack giancarlo 6 2,024 10-15-2013, 02:00 AM
Last Post: Giancarlo
  Colour scheme? Geoff Quickfall 21 4,698 10-02-2013, 10:35 PM
Last Post: LHH
  HP Prime - RPN stack access from programs? Mike Mander (Canada) 10 3,293 09-30-2013, 11:20 AM
Last Post: steindid
  WP-34S: Stack after divide by 0 Marcel Samek 4 1,355 08-24-2013, 11:57 PM
Last Post: Paul Dale

Forum Jump: