Name that calculator - from the program listing... - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Name that calculator - from the program listing... (/thread-11783.html) Name that calculator - from the program listing... - Ángel Martin - 11-11-2018 07:58 PM Here's a reverse puzzle for the eagle-eyed amongst the audience: Upon ocular inspection (i.e. eye-balling it) name the calculator on which the program below runs Code: ```01  LBL "COUNT" 01  CLX 02  DO 03    1 04    + 05    VIEW X 06    "X#5" 07  WHILE 08  END``` Not really sure, you say? Here's a second listing example that may (or may not) help: Code: ```01  LBL "BLIP" 02  "X=5" 03  IF 04    TONE 4 05  ELSE 06    BEEP 07  ENDIF 08  END``` So what say you, is this fictitious or a real case? ;-) Spoiler: The solution soon at a TOS near you, believe it or not... RE: Name that calculator - from the program listing... - Massimo Gnerucci - 11-11-2018 08:16 PM (11-11-2018 07:58 PM)Ángel Martin Wrote:  Here's a reverse puzzle for the eagle-eyed amongst the audience: Upon ocular inspection (i.e. eye-balling it) name the calculator on which the program below runs Code: ```01  LBL "COUNT" 01  CLX 02  DO 03    1 04    + 05    VIEW X 06    "X#5" 07  WHILE 08  END``` Not really sure, you say? Here's a second listing example that may (or may not) help: Code: ```01  LBL "BLIP" 02  "X=5" 03  IF 04    TONE 4 05  ELSE 06    BEEP 07  ENDIF 08  END``` So what say you, is this fictitious or a real case? ;-) Spoiler: The solution soon at a TOS near you, believe it or not... What module did you devised this time Ángel? Looks intriguing! RE: Name that calculator - from the program listing... - mfleming - 11-11-2018 08:17 PM HP41! So, a High Level Language module? Which syntax is it modeled on, BASIC or Pascal? Looks similar enough to RPL to make certain members' head explode ~Mark RE: Name that calculator - from the program listing... - JurgenRo - 11-11-2018 08:18 PM (11-11-2018 07:58 PM)Ángel Martin Wrote:  Here's a reverse puzzle for the eagle-eyed amongst the audience: Upon ocular inspection (i.e. eye-balling it) name the calculator on which the program below runs Code: ```01  LBL "COUNT" 01  CLX 02  DO 03    1 04    + 05    VIEW X 06    "X#5" 07  WHILE 08  END``` Not really sure, you say? Here's a second listing example that may (or may not) help: Code: ```01  LBL "BLIP" 02  "X=5" 03  IF 04    TONE 4 05  ELSE 06    BEEP 07  ENDIF 08  END``` So what say you, is this fictitious or a real case? ;-) Spoiler: The solution soon at a TOS near you, believe it or not... It is real for sure and it's the HP41C equipped with the 41CL board and a new amazing module by Ángel :-))) RE: Name that calculator - from the program listing... - Sylvain Cote - 11-12-2018 12:43 AM Another jewel from Ángel the magician! HP-41 of course! I would assume CL is not mandatory for this one, using alpha to hold enter/exit condition is brilliant. DO ... "condition" WHILE "condition" IF ... THEN ... ENDIF Some questions ... did you also include the loop : "condition" WHILE ... WEND ? will it it support a control decision/loop inside another control decision/loop ? Sylvain RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018 08:00 AM (11-12-2018 12:43 AM)Sylvain Cote Wrote:  Another jewel from Ángel the magician! HP-41 of course! I would assume CL is not mandatory for this one, using alpha to hold enter/exit condition is brilliant. DO ... "condition" WHILE "condition" IF ... THEN ... ENDIF Some questions ... did you also include the loop : "condition" WHILE ... WEND ? will it it support a control decision/loop inside another control decision/loop ? You're all correct - but let's not set up expectations too high though: - These extensions will be released in a forthcoming revision of the Formula_Evaluation Module, revision 1G. - At the heart of the implementation lies the EVAL? function (which actually is a FOCAL routine, if you need to know). Both WHILE and IF perform some housekeeping with the RTN addresses, foreseeing both a TRUE and a FALSE contingency, and then launch EVAL? for a Boolean evaluation of the test condition stated in ALPHA. Depending on the result the RTN addresses are re-arranged so the program flow responds to the desired scheme. - DO/WHILE supports up to three levels of nested calls, but IF.ELSE.ENDIF currently does not. However, it's possible to have and IF.ELSE.ENDIF structure within a DO/WHILE loop; and vice-versa. Here's a couple of examples to whet you appetite (BTW, the mathematicians out there can provide some real-life application to try?) The code below increments the value in Y until reaching 10, which (showing off the most inefficient way to do it) is tested using the value of its decimal LOG. This shows that the test condition can be *anything* supported by EVAL? Code: ```01  LBL "YLO10" 02  5.1 03  DO 04    VIEW Y 05    ISG  Y 06    "LG(IP(Y))#1" 07  WHILE 08  "DONE" 09  AVIEW 10  END``` The next example shows the Fibonacci numbers between 1 and 100: Code: ```01  LBL "FIB\$" 02  1 03  ENTER^ 04  DO 05    "X+Y" 06    EVAL\$ 07    "L" 08    EVALY 09    VIEW X 10    PSE 11    "X<100" 12  WHILE 13  END``` Exciting times in the ASDL, a.k.a "Archeological Software Development Lab ;-) ÁM RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018 10:17 AM Here's an example using the IF.ELSE.ENDIF structure to calculate the roots of a second degree equation, a.x^2 + b.x + c = 0 The program is *not* optimized for size; the purpose of the example is to show the strings more clearly in the respective branches. Feel free to improve on it, for instance by calculating the value of the discriminant beforehand and reusing it in the appropriate sections. Code: ```01     LBL “QRT” 02     “00XYZT” 03     SHFL 04     “b^2-4*a*c>=0” 05     IF 06       “#(b+Q(b^2-4*a*c” 07       “|- ))/2/a” 08       EVALY 09       “(Q(b^2-4*a*c)-b" 10        "|- )/2/a” 11     ELSE 12       "Q(4*a*c-b^2)/2/” 13       “|- a” 14       EVALY 15       “#b/2/a” 16     ENDIF 17     EVAL\$ 18     END``` On entry the coefficients a,b,c are expected in (Z, Y, X} respectively. On exit the roots are placed in {Y,X} if real (F4 set), or the Imaginary and real parts of the complex conjugate roots (F4 clear). Example: try it for x^2 = 1, that is a=1, b=0, and c=-1 Result: x1= 1, x2 = -1 and to exercise the complex branch, how about x^2 + x + 1 = 0 resulting Re(z) = -0.5 ; Im(z) = 0.866025404 Cheers, ÁM RE: Name that calculator - from the program listing... - Ángel Martin - 11-12-2018 03:20 PM ok, to put this one to bed - below is the optimized code for the same example. It uses one intermediate calculation for the discriminant, which saves a ton of bytes in the strings: Code: ```01  LBL  "QRT" 02  "00XYZ" 03  SFHL 04  "b^2-4*a*c" 05  EVAL\$ 06  "X<0" 07  IF 08    "Q(#X)/2/a" 09    EVALY 10    "#b/2/a" 11  ELSE 12    "#(Q(X)+b)/2/a" 13    EVALY 14    "(Q(X)-b)/2/a" 15  ENDIF 16  EVAL\$ 17  END``` ÁM RE: Name that calculator - from the program listing... - derekamos - 11-14-2018 09:59 AM Hi Angel, you have reached LISPyness in profundus. DA RE: Name that calculator - from the program listing... - Eddie W. Shore - 11-14-2018 01:54 PM My guess is the HP 42S. RE: Name that calculator - from the program listing... - Ángel Martin - 11-14-2018 05:38 PM (11-14-2018 09:59 AM)derekamos Wrote:  Hi Angel, you have reached LISPyness in profundus. DA I long time ago I read that LISP stands for "Lots of Insidious Superfluous Parentheses" ;-) RE: Name that calculator - from the program listing... - Ángel Martin - 11-14-2018 05:40 PM (11-14-2018 01:54 PM)Eddie W. Shore Wrote:  My guess is the HP 42S. Not quite! - add this to the list of "things the 41 can do that are not possible on the 42" Not such a big deal anyway, the 42 has plenty of other ways to get the task done.... but not this one! RE: Name that calculator - from the program listing... - derekamos - 11-14-2018 11:26 PM Angel wrote: "Lots of Insidious Superfluous Parentheses". Ah, but my angle is the Lisp-ability to write macros for code/functions that don't exist, I.E surpassing the 41's RPN with other needed functions, no need for insidious "((()))" there. DA