Qunestion about extending the HP-71B BASIC



#2

As I return to dabble in HP71B BASIC programming I am faced with the limitations on variables' names. The JPC ROM (especially using the EMU71 emulator) offers more structured program flow for the 71B BASIC. These improvements are a welcome sign. Of course the 71B BASIC supports GOTOs and GOSUBs that support named labels, which is a much welcome improvement over line numbers.

My question to 71B extension gurus is "Is there anyway to extend the 71B BASIC to support reasonably long variable names?"

Namir


#3

"Is there anyway to extend the 71B BASIC to support reasonably long variable names?"

I tried to extend 71B BASIC with longer variable names when developing my HP-71X emulator for HP-48/49, but eventually I gave up. It seems that HP programmers were totally obsessed with packing a variable name into 3 nibbles, so they forgot about the existence (and usefulness) of longer names. This makes the implementation of longer names almost impossible without a big BASIC ROM rewrite, which wasn't worth a trouble to me, because it would probably break a lot of other things.

The above is one thing that irritates me so much about 71B and I really cannot understand how they couldn't provide a proper variable naming after they provide a lot of other extensions and overcomplicated 71B ROM to a Space Shuttle levels. OK, the speed etc., but they could leave this 3-nibble format for short names and implement longer names that will be slower and will consume more memory, but will be there if you need them.

The other thing that irritates me is the lack of proper integer numbers. Yes, 71B has INTEGER variables but those are just for saving some memory because they, in fact, contain truncated real numbers and the calculator (computer) is dealing internally with real numbers only. Because of those REAL=>"INTEGER" conversion, working with INTEGER variables can actually be slower to some extent than working with REAL variables, what a joke. For some reasons unknown to me, HP insists on that REAL/SHORT/INTEGER variable representation on all BASICs ranging from HP-85 (probably even from HP-9830/9845) via HP-75C to HP-71B.

These are just two reasons that motivated me to start developing my own BASIC (Hrast BASIC-4X) for HP-48/49 series a few months ago ;-)


#4

Thank you for your insight an detailed explanation. I was hoping that someone can add an extension to complement the more structured program flow control done by the JPC ROM. If I am not wrong the TI-74 BASIC supports names longer than one or two letters, and I am almost certain that some Sharp and Casio pocket computers also do that.

Namir


#5

Yes, TI-74 has variable names of up to 15 characters and Sharp PC-E500 has names of up to 40 characters (not sure 100% => should check manual). Lower Sharps (PC-14xx, etc.) have only 1- or 2-character names but, at least, you can have 2-letter names compared to HP-71B, HP-75C and HP-85 (EDIT: and perhaps some other members of HP-8x family) where only letter+number names are supported.

Edited: 3 Dec 2010, 5:22 a.m. after one or more responses were posted


#6

Just for sake of truth, the HP86/87 basic has long variable name up to 31 chars with case distinguished.

Olivier

Edited: 3 Dec 2010, 4:01 p.m.

#7

I am thinking about writing a Windows-based pre-processor utility that takes a pseudo-HP-71B program with long variable names and generates HP-71B code. The choice I have for this kind of utility is either have a user-defined list of name-translation table or the name translation is done entirely by the utility. The latter can more elaborate since the program has to derive the shorter variable names based on the long ones, device a scheme to deal with overflow in variable names (e.g using up A, A1, ..., A9, A0).

Using a user-defined allows the user to control the mapping of long variable names into short ones, so that he/she can edit/correct the translated program with more ease.

Namir


#8

An automatic approach would simply map the first variable to A, the second to B, the 27th to A1, and so forth. If you start writing your programs on the PC you should stick to it.

Use EMU71 for testing.


#9

That's one approach, the other one is to take the first letter of the long variable name and append a digit, starting with 0 and going up.

I have implemented an Visual Basic utility that is an HP71B program pre-processor that adds line numbers, converts pseudo-labels into line numbers, and replace variables with long names with shorter one. The approach I am using is to let the program extract the list of long-name variables and give the user an option of manually naming them or let the program name them using the above scheme. Once the program uses <letter>0 through <letter>9 it stops translating and yields a blank name to let the user choose a name. The program avoids renaming long-name variables to single-letter variables (A, B, C, ... Z) as these may be used in the source code.

Namir

#10

Quote:
These are just two reasons that motivated me to start developing my own BASIC (Hrast BASIC-4X) for HP-48/49 series a few months ago ;-)

Awesome.
#11

Hi Hrast,

I second your opinion about the variable naming scheme on the HP-71B, this is definitevly the major weakness of the otherwise excellent HP-71B Basic implementation.
As mentionned by Olivier, the HP-85 had the same limitation, that was overcomed in the HP-86/87, together with much larger program space.

The main practical use of INTEGER/SHORT variable types was for memory saving when using large numeric arrays. Independently of the INTEGER type, the HP-85 and HP-75C (but not the HP-71B!) had a fast integer processing using a clever implementation, see
Speed comparison

These are just two reasons that motivated me to start developing my own BASIC (Hrast BASIC-4X) for HP-48/49 series a few months ago ;-)

Great! Let us know more soon, a target specification would be very interesting to discuss :-)

J-F


#12

Quote:
As mentionned by Olivier, the HP-85 had the same limitation, that was overcomed in the HP-86/87, together with much larger program space.

Hi J-F,

Thank you (and Olivier) for clarifying this because I was under impression that HP-86/87 used the same BASIC as HP-85.

Quote:
Great! Let us know more soon, a target specification would be very interesting to discuss :-)

I don't have the exact specifications yet because this is work in progress and I am experimenting with a lot of things in order to choose optimal solution (in terms of speed and memory consumption).
Currently I mainly have goals that I would like to achieve in the final product. I can present those goals in a separate thread if the community is interested in this subject ...

But, despite of the specifications, I can asure you that:

(1) It won't be an ordinary BASIC and in many ways it looks and behaves more like Pascal than BASIC.

(2) It will be fast, and I mean real *fast*.

(3) It will have many fancy and useful things ;-)

I executed your tests from the above link and here are the results:

REAL version (looking almost like your program):

10:REM
20:T=TIME
30:X=1
40:FOR I=X TO 1000: NEXT
50:DISP TIME-T

Time: 0.943 seconds

In regard to real numbers, Hrast BASIC-4X works internally with 15-digit mantisa/5-digit exponent, all the time. Native REAL variable type is REAL15, but it supports REAL12, as well, and automatically converts REAL15 to REAL12 when storing to REAL12 variable. It also rounds 15-digit mantissa to 12 digits when executing comparision operations.

INTEGER version (looking almost like your program):

10:REM
20:T=TIME
30:X=%1
40:FOR I=X TO 1000: NEXT
50:DISP TIME-T

Time: 0.254 seconds

Integer range is -524288..524287.

Native REAL version:

REM
T=TIME
X=1
FOR I=X TO 1000 NEXT
DISP TIME-T

Time: 0.898 seconds

Native INTEGER version:

REM
T=TIME
X=%1
FOR I=X TO 1000 NEXT
DISP TIME-T

Time: 0.208 seconds

You can also write it in more packed form:

T=TIME:X=1 FOR I=X TO 1000 NEXT DISP TIME-T

Timing is the same because FOR/NEXT is inside the same line in all versions. Notice that it doesn't need line numbers or statement separators (except before assignment if you don't use LET) and doesn't allow identifier after NEXT (so, NEXT always closes the inner FOR and FOR/NEXT crossing isn't possible).

All tests were executed on HP-48GX running Hrast BASIC-4X initial "1st step" working prototype ...

Edited: 4 Dec 2010, 11:27 a.m.


#13

This seems excellent, and very fast indeed!

J-F

#14

Quote:
doesn't allow identifier after NEXT (so, NEXT always closes the inner FOR and FOR/NEXT crossing isn't possible).

So how do you exit a for loop early????


- Pauli

#15

Quote:
My question to 71B extension gurus is "Is there anyway to extend the 71B BASIC to support reasonably long variable names?"
Once I got my very full-featured text editor going (which used a ton of LEX file material from the Paris user's group), I have written my more complex HP-71 BASIC programs in text. One of the text editor's features uses TRANSFORM to turn it into BASIC, but it also replaces long variable names with the HP-71 kind before the transformation, and additionally adds the line numbers and takes out blank lines and so on. This allows making the program very readable while you're working on it. You can use indentation for conditions, loops, etc., vertical alignment, and other things that make it easier to visually factor. I use a particular character to concatenate lines so even though the HP-71 requires certain things to be kept all on the same line, I can put them on separate lines. I have an extra 160K of RAM, so memory space is not a problem.

Edited: 3 Dec 2010, 3:25 p.m.

#16

Quote:
Is there anyway to extend the 71B BASIC to support reasonably long variable names?

Have you considered giving FORTH a shot?

Possibly Related Threads…
Thread Author Replies Views Last Post
  HP PRIME - Need help for basic program svp. dg1969 4 1,768 10-08-2013, 04:06 PM
Last Post: dg1969
  Easter Sunday Basic Trigs (HP-12C) Gerson W. Barbosa 29 8,872 04-04-2013, 02:19 PM
Last Post: Gerson W. Barbosa
  "The Basic HP-71" Jeff Davis 3 1,604 08-30-2012, 12:20 AM
Last Post: Howard Owen
  HP's Tired Basic Calculator Line Jeff 4 1,801 02-10-2012, 01:33 PM
Last Post: Dirk Mehldau
  HP-41CL & TIME module (extending time keeping) Diego Diaz 2 1,097 12-25-2011, 06:51 PM
Last Post: Diego Diaz
  After the 15c LE, better chance of a basic RPN calc from HP now? nick lidakis 80 16,080 09-18-2011, 08:15 AM
Last Post: snaggs
  BASIC BEEP Howard Owen 5 1,679 05-12-2011, 05:03 PM
Last Post: Garth Wilson
  Better Late Than Never--VAL() in HP-71B BASIC Namir 25 6,497 05-08-2011, 11:50 AM
Last Post: Howard Owen
  Mardi Gras Basic Trigs (HP-12C) Gerson W. Barbosa 10 3,065 03-09-2011, 09:49 PM
Last Post: Gerson W. Barbosa
  OT: Sharp PC-1270 BASIC Compiler V3.3 XYZT 1 1,163 12-18-2010, 05:02 PM
Last Post: Thomas Okken

Forum Jump: