HP Forums

Full Version: Another wishlist for 43s
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

1) Literal constant command

like # nnn, but for arbitrary length nnn with decimal point, sign, eex, etc. There are 10 digits plus sign, plus eex, plus decimal point. Literal constants are a staple of kind of programming calculators are ideal for, there must be a way to enter them in programs in less wasteful way than 1 digit = 1 program step.

2) Like skip/back pair, GTO should have "go backward" counterpart, say, GTB.
This will allow to reuse numeric labels more efficiently.
The system is known as "local symbols" and it is so convenient that I have no explanation why its implementation in actual assemblers is so rare.

Here is a wp34s example, demonstating the power and convenience of local symbols.
This is a alternating series summation program from Valentin Albillo. I translated it verbatim without understanding the magic behind it and it worked on all the examples.

Anyway, back to the local symbols. In my proof of concept preprocessor the local symbols are labels of form 1H 2H 3H ... 9H.
The forward references to the label 1H is <1F> and back reference to the label is <1B>.

Note how all the loops and if/then/elses of the program required only one local symbol -- 1H, where it is being reused as the source unfolds. In contrast, regular labels have infinite scope and require severe mental effort to come up with random new ones and keep track of them to not reuse accidentally. In the languages where labels are primary means of flow control (like assemblers) this can be quite an advantage.

More so for calculators, where LBL labels are available in finite quantity.

```// DatafileVA001.pdf
// by Valentin Albillo
// port by nsg, 2013-07-11 21:11:55
// Sum alternating series [SIGMA](-1)^i f(i), i=0..&#8734;
// LBL B defines f(i) (i in rX)
// Start:
// PSum [^] NDif [A]
// PSum -- integer >=0, may be >7, say 10
// NDif -- 1[<=]NDif[<=]7, integer
LBL'[SIGMA][infinity]±'
LBL A
CF 00
STO 11
x<> Y
STO 10
1
STO 08
0
STO 09
STO I
1H      XEQ B
RCL 08
STO- 08
STO- 08
*
STO+ 09
INC I
RCL 10
RCL I
x[<=]? Y
BACK <1B>
STO 08
2
/
FP
x[!=]0?
SF 0
CLx
STO I
1H      RCL 08
XEQ B
STO[->]I
INC I
1
STO+ 08
RCL 11
RCL I
x[<=]? Y
BACK <1B>
2
FS? 00
+/-
STO 08
ABS
1H      -
STO I
STO 12
LBL 00
RCL[->]I
INC I
STO-[->]I
RCL 11
RCL I
x[!=]? Y
GTO 00
RCL 12
STO I
x=0?
SKIP <1F>
1
BACK <1B>
1H      RCL[->]I
RCL 08
/
STO+ 09
2
+/-
STO* 08
INC I
RCL 11
RCL I
x[<=]? Y
BACK <1B>
RCL 09
RTN
// define ith element here (starting with 0-th)
LBL B
1
+
1/x
RTN
```

Edited: 14 July 2013, 9:00 p.m. after one or more responses were posted

The forum software has translated some of your text to &...; codes :-(. Please use the ASCII character translations such as [->] for the right arrow.

The assembler allows to use symbolic labels with the -pp (preprocessor) switch. They are translated to SKIP/BACK commands (or GTO if out of range). This makes it hard to edit the code on the device but is handy for large projects which are better developed on the PC anyway.

Marcus, I am aware of the preprocessor's labels feature.

What it is missing is the "local labels" (or local symbols as i referred them above), which, in my opinion, greatly improve readability and reduce mental effort of generating and tracking one-off random labels that are used to implement if/then/else and loops.

I implemented it in my own "proof of concept" preprocessor (which also translates utf8 to ascii, that is why my source contained all those &# characters) to demonstrate their advantage.

Here I reuse the "1H" local label 4 times. This is enabled by the fact that the direction of reference (forward or backward) is specified explicitly at the point of reference (as <1F> or <1B>, respectively). Now, in wp34s, the direction is encoded in the opcode (skip or back), so there is no need for specifying the direction in the label, but I did it anyway for demonstration purposes.

Also, same trick can be applied to LBL labels. If the backward version of GTO (say, GTB) is added, so they form a pair analogous to SKIP/BACK, this will allow reuse of numeric labels to a much greater extent. In my experience using local symbols, I never needed to use more than 6. So, the programmer can use and reuse LBL 00 .. LBL 09 for one-off flow control, LBL 80 .. 99 for internal subroutines, and the rest for keyboard handling. For example. Or whatever.

Writing JMP instead of SKIP or BACK actually reduces readability, since BACK, most likely, means a loop and SKIP is most likely a part of if/then/else and when you write JMP you leave the reader (human reader, that is) with need to investigate which of the 2 possibilities you actually meant.