The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

HP35s Programming Help
Message #1 Posted by Chuck on 6 Apr 2008, 2:33 p.m.

I'm not the most efficient programmer in the box. I've written a little program to calculate the partial sums of the function stored in F, iterated as K goes from A to B. Is this about as efficient (minimal steps) the program can get?

Partial Sums

F001 LBL F F002 1 ÷ K^2 F003 RTN A001 LBL A A002 0 A003 STO S A004 INPUT A A005 INPUT B A006 1000 A007 ÷ A008 STO+ A A009 RCL A A010 INTG A011 STO K A012 XEQ F001 A013 STO+ S A014 ISG A A015 GTO A009 A016 VIEW S A017 RTN

Thanks for any suggestions, CHUCK
      
Re: HP35s Programming Help
Message #2 Posted by Marcus von Cube, Germany on 23 Apr 2008, 3:43 a.m.,
in response to message #1 by Chuck

Hi Chuck,

nobody is willing to comment on this? Let me try!

It looks like your loop is perfectly ok. You can save some steps if you redefine F to use the stack instead of K:

F001	LBL F
F002	X^2           ' RPN instead of an equation
F003    1/X
F003	RTN
A001	LBL A
A002	0
A003	STO S
A004	INPUT A
A005	INPUT B
A006	1E3           ' shorter than 1000 (may use the same memory, though)
A007	÷
A008	STO+ A
A009	RCL A
A010	INTG          ' value on stack, not in register
A011	XEQ F002      ' no need to execute the label
A012	STO+ S
A013	ISG A
A014	GTO A009
A015	VIEW S
A016	RTN
I replaced 1000 by 1E3 which might save a byte but need not (I didn't check it).

Marcus


[ Return to Index | Top of Index ]

Go back to the main exhibit hall