Post Reply 
4-level stack manipulation on 12c
03-04-2015, 12:11 PM
Post: #21
RE: 4-level stack manipulation on 12c
(03-04-2015 09:50 AM)PedroLeiva Wrote:  what is the reason of saving so much programming steps. Pedro

The early HP programmable RPN calculators had a very limited amount of program memory and storage registers, so these small stack manipulation routines would have been very useful to anyone who wanted to get the most out of their calculator. The 12c is still in production today (and probably always will be!) so these tricks are still useful for those who want to customize their 12c. I would imagine most of those would be members of this forum.
Find all posts by this user
Quote this message in a reply
03-04-2015, 01:31 PM (This post was last modified: 03-04-2015 02:15 PM by Don Shepherd.)
Post: #22
RE: 4-level stack manipulation on 12c
I guess I should document the reason that I wanted to get 5, 17, 5, and 17 on the stack in the first place. I wanted a little MOD function for my 12c and I realized if I arranged these numbers in the stack in that order, a simple \(\div\) INT \(\times\) - would give me the standard formula for MOD: 17-(int(17/5)x5). So the final 12c program is (after entering 17 in Y and 5 in X):

ENTER
ENTER
-
RDown
X<->Y
LastX
\(\div\)
INT
\(\times\)
-


Many thanks Werner.
Find all posts by this user
Quote this message in a reply
03-04-2015, 02:47 PM (This post was last modified: 03-04-2015 02:48 PM by Katie Wasserman.)
Post: #23
RE: 4-level stack manipulation on 12c
(03-04-2015 01:31 PM)Don Shepherd Wrote:  I guess I should document the reason that I wanted to get 5, 17, 5, and 17 on the stack in the first place. I wanted a little MOD function for my 12c and I realized if I arranged these numbers in the stack in that order, a simple \(\div\) INT \(\times\) - would give me the standard formula for MOD: 17-(int(17/5)x5). So the final 12c program is (after entering 17 in Y and 5 in X):

ENTER
ENTER
-
RDown
X<->Y
LastX
\(\div\)
INT
\(\times\)
-


Many thanks Werner.


Don,

This has come up a few time before, MOD is a missing function on the older HP calculators. Here are a couple of old threads giving some more ideas, but not limited to the 12c.

http://www.hpmuseum.org/cgi-sys/cgiwrap/...read=26358

http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=195228

-katie

Visit this user's website Find all posts by this user
Quote this message in a reply
03-04-2015, 03:15 PM
Post: #24
RE: 4-level stack manipulation on 12c
Thanks for those, Katie. I do remember your CMPLX function on the 32sii for getting MOD, that was brilliant.
Find all posts by this user
Quote this message in a reply
03-04-2015, 03:19 PM (This post was last modified: 03-04-2015 03:20 PM by Dieter.)
Post: #25
RE: 4-level stack manipulation on 12c
(03-04-2015 01:31 PM)Don Shepherd Wrote:  ENTER
ENTER
-
RDown
X<->Y
LastX
\(\div\)
INT
\(\times\)
-

This returns the modulus in x while the rest of the stack is filled with the initial y.
The following code takes the same 10 steps and exits with the upper stack registers filled with the initial x:

Code:
01  ENTER
02  ENTER
03  CLx
04  +
05  R↓
06  /
07  INT  (or IP)
08  R↑
09  x
10  -

So there are two options. Simply choose the one that fits your needs better.

Dieter
Find all posts by this user
Quote this message in a reply
03-04-2015, 03:42 PM
Post: #26
RE: 4-level stack manipulation on 12c
Thanks Dieter. The 12c doesn't have a roll-up function, however, and in my case I only care about what is in x when the routine completes. But your suggestion is certainly valid for a calculator with roll-up and those that need or want the upper registers filled with the initial x. Thanks for this idea.

Don
Find all posts by this user
Quote this message in a reply
03-04-2015, 04:54 PM (This post was last modified: 03-05-2015 03:38 PM by Gerson W. Barbosa.)
Post: #27
RE: 4-level stack manipulation on 12c
(03-04-2015 03:42 PM)Don Shepherd Wrote:  Thanks Dieter. The 12c doesn't have a roll-up function, however, and in my case I only care about what is in x when the routine completes. But your suggestion is certainly valid for a calculator with roll-up and those that need or want the upper registers filled with the initial x.

I find this feature very handy, so much I don't mind spending one extra step on the regular HP-12C:

Code:

01 f RND            001 f RND
02   Rv             002   Rv
03   ENTER          003   ENTER
04   ENTER          004 g LSTx
05 g LSTx           005   /
06   /              006 g LSTx
07 g LST            007   x<>y
08   x<>y           008 g INTG
09 g INTG           009   *
10   *              010   -
11   -              011 g GTO 000
12 g GTO 00

Gerson.

Edited per Dieter's observation below.
Find all posts by this user
Quote this message in a reply
03-04-2015, 11:21 PM
Post: #28
RE: 4-level stack manipulation on 12c
(03-04-2015 03:15 PM)Don Shepherd Wrote:  Thanks for those, Katie. I do remember your CMPLX function on the 32sii for getting MOD, that was brilliant.

But there are no CMPLX functions on the 12C, there are ideas in those threads.

-katie

Visit this user's website Find all posts by this user
Quote this message in a reply
03-05-2015, 12:11 AM
Post: #29
RE: 4-level stack manipulation on 12c
(03-04-2015 11:21 PM)Katie Wasserman Wrote:  But there are no CMPLX functions on the 12C, there are ideas in those threads.

Don't give the finance guys any ideas! The moment they start to think they can manipulate imaginary money it's over for the rest of us. Wink

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
03-05-2015, 12:28 AM
Post: #30
RE: 4-level stack manipulation on 12c
(03-05-2015 12:11 AM)rprosperi Wrote:  Don't give the finance guys any ideas! The moment they start to think they can manipulate imaginary money it's over for the rest of us. Wink

The people in Washington D.C. have been doing it for the last 60 years.

So, I guess you are correct. It is over for the rest of us (in the US).

Hopefully there are other governments out there that are fiscally responsible.

Ceci n'est pas une signature.
Find all posts by this user
Quote this message in a reply
03-05-2015, 06:56 AM
Post: #31
RE: 4-level stack manipulation on 12c
(03-05-2015 12:28 AM)Mark Hardman Wrote:  Hopefully there are other governments out there that are fiscally responsible.

Maybe, but don't look here.

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
03-05-2015, 01:01 PM
Post: #32
RE: 4-level stack manipulation on 12c
(03-04-2015 04:54 PM)Gerson W. Barbosa Wrote:  I find this feature very handy, so much I don't mind spending two extra steps:

If two more steps are fine, simply replace the R↑ in my suggestion with 3x R↓ ;-)

Code:
01  ENTER
02  ENTER
03  CLx
04  +
05  R↓
06  /
07  INT  (or IP)
08  R↓
09  R↓
10  R↓
11  x
12  -

Looking at your solution I have two questions:

Code:
   HP-12C           HP 12c Platinum

01 f RND            001 f RND
02   Rv             002   Rv
03   ENTER          003   ENTER
04   ENTER          004 g LSTx
05 g LSTx           005   /
06   /              006 g LSTx
07 g LST            007   x<>y
08   x<>y           008 g INTG
09 g INTG           009   *
10   *              010   CHS
11   CHS            011   +
12   +              012 g GTO 000
13 g GTO 00

First, is there a special reason why you chose [CHS] [+] instead of a simple [–] ?
Second, the 12C Platinum version uses just one ENTER instead of two in the standard 12C version. Is the Platinum actually different in this regard?

Dieter
Find all posts by this user
Quote this message in a reply
03-05-2015, 03:00 PM
Post: #33
RE: 4-level stack manipulation on 12c
(03-05-2015 01:01 PM)Dieter Wrote:  First, is there a special reason why you chose [CHS] [+] instead of a simple [–] ?
Second, the 12C Platinum version uses just one ENTER instead of two in the standard 12C version. Is the Platinum actually different in this regard?

Dieter

I am soo glad you asked these questions Dieter! I looked and looked at the programs and could not figure these same issues out, but concluded I must be missing some thing obvious, so stayed quiet. I feel better seeing you have the same questions.

For [CHS] [+] vs. [-] the only apparant difference is the LASTX would be different. We shall see...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
03-05-2015, 03:34 PM
Post: #34
RE: 4-level stack manipulation on 12c
(03-05-2015 01:01 PM)Dieter Wrote:  
(03-04-2015 04:54 PM)Gerson W. Barbosa Wrote:  I find this feature very handy, so much I don't mind spending two extra steps:

If two more steps are fine, simply replace the R↑ in my suggestion with 3x R↓ ;-)

Code:
01  ENTER
02  ENTER
03  CLx
04  +
05  R↓
06  /
07  INT  (or IP)
08  R↓
09  R↓
10  R↓
11  x
12  -

Looking at your solution I have two questions:

Code:
   HP-12C           HP 12c Platinum

01 f RND            001 f RND
02   Rv             002   Rv
03   ENTER          003   ENTER
04   ENTER          004 g LSTx
05 g LSTx           005   /
06   /              006 g LSTx
07 g LST            007   x<>y
08   x<>y           008 g INTG
09 g INTG           009   *
10   *              010   CHS
11   CHS            011   +
12   +              012 g GTO 000
13 g GTO 00

First, is there a special reason why you chose [CHS] [+] instead of a simple [–] ?
Second, the 12C Platinum version uses just one ENTER instead of two in the standard 12C version. Is the Platinum actually different in this regard?

Dieter

1) Yes, my blindly copying and pasting my own code :-) That CHS + sequence (steps 134 and 135) made sense following g x<=y (step 133), but obviously not here. Thanks for spotting that!

Fast and Accurate Trigonometric Functions on the HP-12C Platinum (Virtual version here)

2) There are some issues regarding stack-lift when comparing both calculators. This appears to be one of them. Others have been mentioned here and here, for instance.

Gerson.
Find all posts by this user
Quote this message in a reply
03-05-2015, 08:56 PM
Post: #35
RE: 4-level stack manipulation on 12c
(03-05-2015 03:34 PM)Gerson W. Barbosa Wrote:  2) There are some issues regarding stack-lift when comparing both calculators. This appears to be one of them. Others have been mentioned here and here, for instance.

Hmm... I do not find something in these threads that might be related to this missing ENTER in the 12C Platinum version. And I cannot believe that ENTER LastX should copy X both to Y and Z, and LastX then adds that value in X. Are you absolutely sure that the second ENTER can be omitted? This would be absolutely unusual for an RPN calculator: it's one of the RPN basics that ENTER disables stack lift so that here LastX overwrites X.

Dieter
Find all posts by this user
Quote this message in a reply
03-05-2015, 09:28 PM
Post: #36
RE: 4-level stack manipulation on 12c
(03-05-2015 08:56 PM)Dieter Wrote:  
(03-05-2015 03:34 PM)Gerson W. Barbosa Wrote:  2) There are some issues regarding stack-lift when comparing both calculators. This appears to be one of them. Others have been mentioned here and here, for instance.

Hmm... I do not find something in these threads that might be related to this missing ENTER in the 12C Platinum version.

I should have written "This appears to be another one", that is, a new kind of issue.

(03-05-2015 08:56 PM)Dieter Wrote:  And I cannot believe that ENTER LastX should copy X both to Y and Z, and LastX then adds that value in X. Are you absolutely sure that the second ENTER can be omitted? This would be absolutely unusual for an RPN calculator: it's one of the RPN basics that ENTER disables stack lift so that here LastX overwrites X.

Yet the second ENTER is necessary on the HP-12C. I tried it on two units (CN04808261 and CNA 83816873). Really strange, I agree.

Best regards,

Gerson.
Find all posts by this user
Quote this message in a reply
03-05-2015, 09:57 PM
Post: #37
RE: 4-level stack manipulation on 12c
(03-05-2015 09:28 PM)Gerson W. Barbosa Wrote:  Yet the second ENTER is necessary on the HP-12C. I tried it on two units (CN04808261 and CNA 83816873). Really strange, I agree.

Best regards,

Gerson.

Confirmed on a 1987-vintage 12C. I was wondering if the problem was unique to the newer (different cpu. etc.) model 12C machines since both of those mentioned are of Chinese manufacture.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
03-05-2015, 10:11 PM (This post was last modified: 03-05-2015 10:19 PM by Dieter.)
Post: #38
RE: 4-level stack manipulation on 12c
(03-05-2015 09:28 PM)Gerson W. Barbosa Wrote:  Yet the second ENTER is necessary on the HP-12C. I tried it on two units (CN04808261 and CNA 83816873). Really strange, I agree.

?!? – that's exactly what I would have expected! The idea is to save X in LastX and copy Y to two (!) higher stack levels. On any classic HP calculator I can imagine this requires two ENTERs. My question was why the 12C Platinum should be different and one single ENTER should so. *That* would be strange indeed. ;-)

(03-05-2015 09:57 PM)rprosperi Wrote:  Confirmed on a 1987-vintage 12C. I was wondering if the problem was unique to the newer (different cpu. etc.) model 12C machines since both of those mentioned are of Chinese manufacture.

I do not see a problem. The two ENTERs are exactly how very classic HP is supposed to work in this situation. The question was why the 12C Platinum version would require just one single ENTER to generate two (!) copies of x – cf. the stack diagram below.

In other words, I think that both versions require two ENTERs. If the user input is y ENTER x, the stack should look like this after the LastX command:
Code:
T      ...
Z       y
Y       y
X       x

LastX   x

And this is why the second ENTER is required. IMHO in both cases.
If the 12C Platinum version actually runs correctly with a single ENTER, now, that would be strange indeed.

Dieter
Find all posts by this user
Quote this message in a reply
03-05-2015, 10:26 PM (This post was last modified: 03-05-2015 10:27 PM by Gerson W. Barbosa.)
Post: #39
RE: 4-level stack manipulation on 12c
(03-05-2015 10:11 PM)Dieter Wrote:  If the 12C Platinum version actually runs correctly with a single ENTER, now, that would be strange indeed.

It does. Actually an HP 12c Prestige here (CNA 62932140), but I assume it to be equivalent to the HP 12c Platinum.

Gerson.
Find all posts by this user
Quote this message in a reply
03-05-2015, 10:51 PM
Post: #40
RE: 4-level stack manipulation on 12c
(03-05-2015 10:26 PM)Gerson W. Barbosa Wrote:  It does. Actually an HP 12c Prestige here (CNA 62932140), but I assume it to be equivalent to the HP 12c Platinum.

Gerson.

Hey, wanna sell that Prestige?? Oh, uh... sorry, don't know what came over me.

Sorry, I misunderstood Dieter's comments to mean he thought the 2nd ENTER was not necessary on the 12C . While I have full confidence in Gerson, this gives me a reason to check this on a lowly non-Prestige Platinum tonite. Of course, there are at least 2 different Platinum s/w versions, before and after adding the UNDO and BKSPC. Guess I'll check both.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 4 Guest(s)