Post Reply 
INPUT stack lift: 32S vs. 42S
10-11-2019, 01:49 PM
Post: #1
INPUT stack lift: 32S vs. 42S
I spent some time last night adapting the triangle solver from the 32S Engineering Applications book to my 42S, and after about an hour of trying to figure out why I was getting incorrect results, I discovered that INPUT behaves differently on the two models.

On the 32S, INPUT first recalls the variable to X, obeying the current stack lift mode. Then it disables stack lift, so the user's entry overwrites whatever was recalled to X. When entry is complete and the program continues, INPUT enables stack lift.

On the 42S, it's a bit different. INPUT recalls the variable to X, while obeying the current stack lift mode as the 32S does. But then it enables stack lift, so if the user enters a value, the old value of the variable gets pushed to Y. When INPUT is complete, it enables stack lift, as on the 32S.

Is there a clean, clever way to reconcile this difference? I'm not sure what the rationale is behind having the 42S enable stack lift so the old value gets preserved in Y (aside, perhaps, from 41C compatibility). Ideally I'd want it to behave like the 32S, where the old value in X is overwritten by the new entry. The best I could think up was something gross like checking flag 30, saving Z and/or T, calling INPUT, checking flag 22, and restoring Z/T. Is it better to just analyze the intent of the surrounding program code and modify it to accommodate the difference?

This is the code in question:

Code:
LBL E
CF 2
INPUT A
INPUT C
RCL A
RCL C
x>y?
SF 2
INPUT D
SIN
RCL/ A
*

On the 32S, the steps after INPUT D will calculate C*sin(D)/A regardless of whether a new value is entered into D. On the 42S, they end up calculating D*sin(D)/A if a new value is entered (and the RCL A certainly doesn't stay where the program subsequently expects it to be either).
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
INPUT stack lift: 32S vs. 42S - Dave Britten - 10-11-2019 01:49 PM



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