Initializing Values in a Program (HP35s)



#2

Suppose you need to initialize X=2 and Y=3 in a program. One method is:

001  2
002 STO X
003 3
004 STO Y

A second method is to use EQN before each line

001  2 -> X
002 3 -> Y

where -> is the STO command.

The second method obviously reduces the number of lines of code, but is one method any more efficient (timewise) over the other? I haven't been able to discern a difference in my small programs, so it's just really a matter of curiousity.

CHUCK


#3

Create a loop and time it:

E.g.:

A001 100
A002 STO I
A003 your code here
...
An DSE I
An+1 GTO A003
An+2 RTN
This will run your code 100 times. Use a stopwatch to time it.

Edited: 3 Oct 2007, 1:03 p.m.


#4

Y001 LBL Y

Y002 0.999

Y003 STO X

Y004 2

Y005 STO Y

Y006 ISG X

Y007 GTO Y004

Y008 RTN

Used 1m 8s

Y001 LBL Y

Y002 0.999

Y003 STO X

Y004 eq 2>Y

Y005 ISG X

Y006 GTO Y004

Y007 RTN

Used 1m 57s


Edited: 3 Oct 2007, 1:22 p.m.

#5

Okay, I looped it 100 times.

11 seconds with

2
sto x
3
sto y

and 20 seconds with

2 -> x
3 -> y

Looks like there is definitely a trade-off with speed -vs- size.


#6

The difference in length is only

LBL A

2

STO


LN=67



LBL A

2>A

LN=66


Edited: 3 Oct 2007, 2:43 p.m.


#7

Equation are parsed run time every time used, so clearly there will by an overhead.

#8

I've not checked if this is the case here or not but don't trust the reported program lengths, they are wrong.

To measure sizes more accurately, try looking at the change in the bytes free in the memory menu.

- Pauli


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP35s Program Four Slings Lift Calculation Jean-Marc Biram (Australia) 2 1,016 12-16-2013, 07:21 PM
Last Post: Jean-Marc Biram (Australia)
  HP35s Calculator Max Rope Tension Program Jean-Marc Biram (Australia) 10 2,015 12-12-2013, 12:03 AM
Last Post: Jean-Marc Biram (Australia)
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 1,114 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  [HP Prime] Constants Library Values Timothy Roche 24 3,091 11-02-2013, 04:17 PM
Last Post: Les Koller
  HP 35s - multiple program input values? Arno 3 783 04-29-2013, 11:27 AM
Last Post: Gerson W. Barbosa
  Trouble entering a HP35s program line Arno 2 703 04-05-2013, 06:28 PM
Last Post: Arno
  HP35s scientific calculator GREG W THOMAS 4 834 03-22-2013, 06:49 AM
Last Post: Thomas Radtke
  [wp34s] Alternative MIO (allows calculations when entering element values) David Maier 1 505 02-03-2013, 02:51 PM
Last Post: Marcus von Cube, Germany
  DM-xxCC Default Display Values Mark Hardman 3 638 09-13-2012, 03:42 PM
Last Post: Lode
  HP35s "MEMORY CLEAR" flashes Mark Paris 1 567 08-31-2012, 07:35 PM
Last Post: Bart (UK)

Forum Jump: