Post Reply 
newRPL - build 1255 released! [updated to 1299]
11-20-2019, 04:59 PM (This post was last modified: 11-20-2019 05:11 PM by Claudio L..)
Post: #607
RE: newRPL - build 1255 released! [updated to 1299]
(11-20-2019 04:47 AM)The Shadow Wrote:  I started using HP calculators with the 48, so I'm not familiar with old-school RPN. Are the assembly-like instructions primarily useful for RPN users, or do they have uses in RPL?

Assembly-like instructions are for everybody. They intermix with RPL as you wish. You can think of the registers as local variables that don't need to be declared, or as temporary storage to avoid (or reduce) stackrobatics.
I think that's the main usefulness: Reduce stackrobatics and cryptic code by making things more readable. The instructions are quite compact, think << :A+=B*C >> and compare with << B C * 'A' STO+ >>, so code is shorter and easier to read. Yes, there's a slight reduction in the overhead of running 1 command versus 5, so speed could end up improving (not tested yet as it wasn't the objective). On the other hand, the interpreter overhead is pretty thin as it is, so the improvement in speed won't be that impressive.
However, readability of numerical algorithms I think will improve significantly. It's easy to get lost in stackrobatics and these instructions can help keep the code clean.
An example: Given A, B, C on the stack, calculate the quadratic formula (-B+√(B^2-4*A*C))/(2*A)
I know, using a symbolic then ->NUM it's best for readability but for the sake of this excercise let's not use symbolics.
Using stackrobatics:
Code:

« PICK3 * 4 * OVER SQ SWAP - √ SWAP - SWAP DUP + / »

Using assembly-like code:
Code:

«
:A=RPOP.S1.#3     @ POP 3 VALUES FROM THE STACK STARTING AT S1, ASSIGN A=S3, B=S2, C=S1
:D=A*C
:D*=4
:E=B^2
:F=E-D
:F=SQRT.F
:F-=B
:F/=2*A
:P=F                   @ PUSH THE RESULT BACK TO THE STACK
»

There's 15 objects and commands on the stackrobatics version, vs. only 9 instructions in the assembly-like and it is more readable, once you get used to the syntax.

RPN people should find more at home with the assembly-like syntax than with plain RPL, but that doesn't prevent RPL people from using it too.

EDIT: A third way to code it, using locals:
Code:

« →  A B C « B SQ A C * 4 * - √ B - A 2 * / » »
This version improves readability (vs. stackrobatics), and in newRPL should be about the same speed as assembly-like code. Whether it is more or less readable than asm it's for the reader to decide.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
RE: newRPL - build 1255 released! [updated to 1299] - Claudio L. - 11-20-2019 04:59 PM
How to participate? - erazor - 12-13-2019, 07:12 AM



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