[rrd-developers] ROL and ROR for RPN

Steve Shipway s.shipway at auckland.ac.nz
Tue May 6 04:43:26 CEST 2014


So, I have a patch (unified context diff) to add the RPN operators ROLL,
INDEX, COPY and DEPTH.

DEPTH: push the number of stack elements onto the stack
  1,2,3,DEPTH ==> 1,2,3,3
COPY: pop the top value form the stack.  Copy that number of elements on the
stack.  So, DUP is the same as 1,COPY
   1,2,3,2,COPY ==>  1,2,3,2,3
INDEX: identify the item that far down the stack and copy it onto the top of
the stack (1-based). So, DUP is the same as 1,INDEX
 1,2,3,4,5,2,INDEX ==> 1,2,3,4,5,4
ROLL: rotate the top n items by s steps (can be positive or negative) So
EXCH is the same as 2,1,ROLL or 2,-1,ROLL
 1,2,3,4,5,3,-1,ROLL ==> 1,2,4,5,3

This should allow much more extensive stack manipulation.  Stack underflow
and overflow are handled.

Thanks for the feedback from the group on making ROLL more generic, and
adding DEPTH, INDEX and COPY.  These functions may benefit from more
extensive testing as properly debugging the RPN engine is awkward.  More
feedback always welcome.

Steve
  
Steve Shipway
s.shipway at auckland.ac.nz


-------------- next part --------------
A non-text attachment was scrubbed...
Name: rpn.patch
Type: application/octet-stream
Size: 3879 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20140506/edd12e3f/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5909 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20140506/edd12e3f/attachment-0001.bin 


More information about the rrd-developers mailing list