Program only works when stepping, not when running?



#2

I've got a little 32sII program that doesn't work when I run it but if I step through it, it works!

I am confused by this. I know where the program fails when I run it (an Enter command) so when the Enter command in the program is processed, x is not duplicated when running but is duplicated when stepping.

This means there is a programmatic difference with the Enter command compared to interactive which I've never seen before. If I put two Enter commands in the program, it does what I expect one Enter command to do.

Maybe my brain is fried today but is this difference in Enter functionality a known issue?

Thanks :)

Mark


#3

On some HPs, SST changes the "stack lift enabled" flag, so SSTing through a program may give different results than running it normally. I'm not sure which models have that "feature", but perhaps the 32SII is one of them.


#4

Well, that must be it Eric. I've never seen that documented anywhere so it is rather useful to know!



Here is the listing. It is a simple thing.



LBL R

INPUT R

INPUT X

INPUT Y

x SWAP y

/ (divide)

*

SQRT

ENTER // Duplicate the result of the SQRT

RCL X

RCL / Y

x

STOP

That is the version that only works when stepping through it. To get it to work when running, you need to add another ENTER after the ENTER so it reads



SQRT

ENTER

ENTER

RCL X





The use of the 2nd Enter totally confused me.



When running the program typical values might be 12, 3, 2 and use x SWAP y to get the result pair.



Mark


#5

As you want to have two copies of the same number in the stack you need the two ENTER as the stack lift is disabled after each ENTER. As stated in the 32SII manual:

ENTER replicates the content of the X-register into the Y-register. The next number you key in (or recall) writes over the copy of the first number left in the X-register. The effect is simply to separate two entered numbers.

This means that after a single ENTER you have the SQRT result in the Y-register and in the X-register, but the RCL X writes over the X-register so you end up with only one copy of the SQRT result in the Y-register and you have the X value in the X-register.

As Eric said above the SST instruction may change the stack lift enable flag on the HP 32sII and allow the RCL X to not overwrite the X-register but instead to move the values in the Y_register and X-register to the Z-register and Y_register.

I've tried your program on my 35s and there is no difference between running and single stepping modes: two ENTER are needed
(and thanks to the two lines display there is no need to swap x & y to see the result pair...)

#6

The only similar example I can remember encountering is that on some earlier models (HP33C, HP11C, HP34C) R/S seems to enable stack lift but SST does not. (Though I can't remember what the manuals say about stack lift and R/S without checking).

The result is that this can have the opposite effect - running a program will 'work' but single stepping it doesn't.

Mike T.


#7

Thanks for all your help chaps. With the benefit of a clearer brain today, I can now explain exactly what was going wrong. The route cause of the problem was operator error! I could see where things were going wrong but I was totally on the wrong track.

I typed in the program, ran it and found it gave wrong results so I stepped through it and found it gave right results. This totally confused me and made me look at things the wrong way - I thought it was a bug in the 32sII or my program, not that it was actually my fault!

The reason is that when I was stepping through, after the Enter command, I was checking the stack contents by using "x swap y" which of course, enabled stack lift and therefore cancelled the disabled stack lift after the Enter command. Hence, the stepped run gave the right answer. Had I tried stepping through the program without checking the stack, I would have found that it also gave the wrong answer!

So, like most code mysteries, the cause was simple operator error and me looking for the solution in the wrong place (which had I applied my 5 minute rule, I would have stopped doing).

A somewhat embarrassing saga but a good one to learn and a nice way to remind myself that even if you consider yourself competent at programming, simple mistakes are still simple to make! :)

Mark


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime works from the traditionally TI community... debrouxl 1 189 12-06-2013, 09:00 PM
Last Post: Erwin Ried
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 328 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  Fun things found by running strings on the 39gII emulator bhtooefr 11 477 05-16-2013, 12:40 AM
Last Post: Mic
  HHC 2013 Website up and running Joe Horn 4 243 05-05-2013, 07:17 PM
Last Post: bhtooefr
  Running 33S and 35S emulators in Win 8 Ed Look 12 481 12-07-2012, 03:24 PM
Last Post: Ed Look
  HP48GX everything works perfectly except the 'ON' key? Bruce Larrabee 5 314 10-22-2012, 05:41 AM
Last Post: Bruce Larrabee
  Program works in emulators but not on HP-15c hardware Marcel Samek 32 1,183 05-11-2012, 08:46 PM
Last Post: Jeff O.
  [WP34S] Problem Running wp34s_lib.pl in Mac OS X Les Wright 17 602 03-21-2012, 06:05 PM
Last Post: Neil Hamilton (Ottawa)
  Successful running EmuXY under Wine 1.4 Christoph Giesselink 0 96 03-12-2012, 03:06 PM
Last Post: Christoph Giesselink
  running hp200lx solver on kindle fire william egan 4 234 03-10-2012, 07:25 PM
Last Post: Bill (Smithville, NJ)

Forum Jump: