The Museum of HP Calculators

HP Articles Forum

[Return to the Index ]
[ Previous | Next ]

"Linear Programming" to Minimize LBL Usage on the HP-33s

Posted by Paul Brogger on 15 Mar 2004, 8:55 p.m.

The HP-33s, having 31K memory available but only 26 labels and 27 registers, will challenge us to program in different ways than we may have in the past.

One idea for minimizing label usage is to utilize Flags as either parameters to routines, or to encode parameters passed through other means. The routine below provides convenient keyboard STO/RCL access to the statistics registers, and illustrates encoding the sign of the first argument as a STO (positive) or RCL (negative) flag. In this manner, two related functions may be combined under a single LBL code.

Of course, another method of minimizing LBL use is unwinding subroutines (repetitively coding subroutine logic in-line), but this simple program wouldn't likely have embodied any subroutine calls. A variation on the approach used in this routine enabled me to write STO & RCL functions for any of 10 3-dimensional vectors (numbered 1-10), again under a single label. (That one does have some would-be subroutine logic strung out three times in the program body.)

(The program also shows how comments may be entered as an equation after an "FS? 10" test.)

I hope you find it useful. Comments or corrections are welcome: take the "NoHormel" out of my email address & fire away!

STO / RCL Sum (stat) registers

Accepts: 1 <= |x| <= 6 to specify register if x negative: RCL, otherwise STO

STO stores value saved in original y

Index mapping is |x|+27 -> i .

E0001 LBL E E0002 FS? 10 E0003 STO+RCL: STAT REGS

E0004 RUP move t to x E0005 STO i save original t for later E0006 RDN restore stack

E0007 CF 4 clear Flag 4 (“STO” flag) E0008 x>0? if x not negative E0009 SF 4 then “STO” is indicated

E0010 ABS remove sign E0011 6 six is upper limit for this function E0012 x<y? if original x is greater E0013 x<>y then substitute 6 E0014 RDN and use whatever is now in y

E0015 1 one is lower limit for this function E0016 x>y? if original x is lesser E0017 x<>y then substitute 1 E0018 RDN and use whatever is now in y

E0019 27 bias index by 27 E0020 + to obtain true stat register index

E0021 RCL i restore saved original t E0022 RDN and put back to simulate stack drop

E0023 x<>i swap adjusted stat register index with i E0024 RDN and move original y to x

E0025 FS? 4 was original x positive (STO)? E0026 STO (i) if so, store original y in indexed var.

E0027 FS? 4 is this a STO call? E0028 RDN if so, get rid of original y

E0029 RCL (i) whether STO or RCL, read addressed var.

E0030 CF 4 clear “positive” flag E0031 RTN

CK=163D Note: Checksum and length values will depend upon: LN=115 a. choice of "E" for program LBL, b. equations used to enter constants, and c. exact text of equation comment at E0003.


[ Return to the Message Index ]

Go back to the main exhibit hall