The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

33S: new programming strategy
Message #1 Posted by KC on 15 May 2004, 2:13 a.m.

For all of us who have learned programming, be it computer or calculator programming, the two most important keys to writing good programs are (1) to maximize program running speed; and (2) to minimize program space. With the introduction of HP 33S, a totally new strategy comes up where nobody have never meet: to minimize the use of label while not worrying too much about program space. For instance, in the past, when you want to write a program to loop several times, you'd write something like: Lbl L 1.07 STO Z Lbl M Xeq A ISG Z Gto M RTN

And now, you'd rather save one label by writing something like: Lbl L Xeq A Xeq A Xeq A . . Xeq A RTN (Of course, whether it should be changed depends on how many times it loops and how long is the program code in between the loop)

When I got the HP32SII, I looked at the manual, and found out that most example programs in the manual already occupied most of the memory. Now I've acquired the 33S, and look at the manual, and found out most of the programs use up a lot of labels! So limitations are still there, though they are different. I wonder if there would come up in this forum, or new books about techniques that could minimize the use of labels for programming 33S.


My take on why calc programs use lots of labels (slighty OT)
Message #2 Posted by Cameron Paine on 15 May 2004, 2:58 a.m.,
in response to message #1 by KC

This doesn't apply to the 33s per se.

For many of us HLL programmers, the most succinct and unambiguous expression of an algorithm is in the HLL with which we are most conversant. Sometimes this is laziness; oftentimes it's because we've solved that class of problem before and we know that our coded solution works. (As an aside, cut and paste remains the dominant method of code reuse IMO).

If you attempt to hand-convert an algorithm expressed in a HLL to low-level code for an assembler, you will find that you end up with a *lot* of labels. I encounter this often as I go from Java or C++ to H8 ASM. So, to optimise for memory footprint, you *have* to re-implement the algorithm for the target platform (calculator, ucontroller or PIC).

Perhaps the writers who created the 33s examples simply re-implemented them from existing HLL code.


HLL - high-level language

Re: 33S: new programming strategy
Message #3 Posted by bill platt on 15 May 2004, 10:13 a.m.,
in response to message #1 by KC

Some have definitely already though about this, and their ideas have been posted here on this forum (some stuff at comp.sys.hp48 too but more here!)

Go to the latest archives, and search for 33s and you will find many threads.

Also search in the current forum, and you will find more.

One idea is to use equations as space-holder labels for programs that are being "stored" but not actively run. The can describe what follows. Of course The line-numbering is strange when you do this----but it can work---thoug hyou really need a little notebook to keep track (which the 33s slipcase is great for carrying with the calc--along with a pencil!).

There are definitely at least one post which directly discusses how to turn subroutines into one program.

Good luck in your search!



Re: 33S: new programming strategy
Message #4 Posted by bill platt on 15 May 2004, 12:23 p.m.,
in response to message #3 by bill platt


[ Return to Index | Top of Index ]

Go back to the main exhibit hall