WP 34S: missing vector cross product « Next Oldest | Next Newest »

 ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 07-23-2011, 05:34 AM I saw that the cross product is still missing in the vector library, so that's a good chance to write my first WP34s program. ;-) Here's the pure code which fulfills all conditions required in vectors.txt (at least I hope so) - you just have to give it a label of your choice: ```STO C RCL* B RCL T RCL* T - x<>y STO I RCL* T RCL A RCL* D - x<>z STO J RCL* A RCL B RCL* I - R^ STO L Rv ``` Just 20 steps, not so bad for my first program ... :-) Franz ▼ Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 07-23-2011, 06:39 AM Give me a break, I only added vectors.txt yesterday. I'll add your code instead of writing my own :-) - Pauli Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 07-23-2011, 06:52 AM The vectors.txt file is updated. vectors.wp34s will be in due course I expect. I think that 112 steps is pretty lean for this lot :-) Thank to Franz for the final piece. - Pauli ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 07-23-2011, 07:18 AM I must say that writing this cross product was really a nightmare: taking care of where all those stack values are moves during the calculation, avoiding stack overflows and finally fulfilling your conditions about storing the 2nd vector to L,I,J (and keeping the 1st one on the stack) increased the number of my grey hairs. ;-) And with all these troubles I had an idea which would greatly simplify such calculations (with so many parameters on the stack): What about having a 2nd copy of the 8 stack registers? One command could duplicate the original stack into this 2nd copy, and then you could just do all calculations with these '2nd-stack' registers on the usual stack: since the order (and naming) of the 2nd-stack won't change, it would be much easier to adress the stackregister names. Maybe this 2nd stack registers could be named with a dot preceding the names (.X, .Y, .... .C, .D) and adressed with the sequence RCL XEQ (because XEQ is almost the only key which is still free to use after a STO/RCL), which would then display "RCL .__" and wait for any stackregister name (X to D). Of course this should also work with STO XEQ, and there should be 2 commands to copy (or backup) the normal stack to this 2nd stack and vice versa (maybe STO STO and RCL RCL). Well, just a dream of me - but it would indeed make programming much easier ... Franz PS: I know this could be done with the usual registers Rxx (and STOS), but I also know that you don't like changing any registers during 'usual' calculations within a program. Edited: 23 July 2011, 7:22 a.m. ▼ Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 07-23-2011, 07:22 AM Not possible: no RAM left. We do have save and restore stack operations: STOS & RCLS. They save/restore the stack to the numbered registers only. - Pauli ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 07-23-2011, 07:44 AM Quote: Not possible: no RAM left. Ok, and what about a few more stack manipulation commands? It would be nice to have something like Rv and R^ not for the whole stack but just for a part of it (e.g. only do a roll-down/up on the first 3 registers X,Y,Z). Edited: 23 July 2011, 8:43 a.m. ▼ Gene Wright Unregistered Posts: 1,545 Threads: 168 Joined: Jul 2005 07-23-2011, 09:35 AM While we are thinking of stack commands :-) how about something like these? Y <> Z Y <> T Z <> T ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 07-23-2011, 10:33 AM Quote: While we are thinking of stack commands :-) how about something like these? Yes, not a bad idea - my HP-48GX has much more (useful!) stack manipulation commands than are available on the WP34S. But the major problem is certainly the limited space on the WP34S, wheras the 48GX doesn't suffer from such space restrictions. ;-) Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 07-23-2011, 07:43 PM And the other four stack levels?? - Pauli ▼ Gene Wright Unregistered Posts: 1,545 Threads: 168 Joined: Jul 2005 07-23-2011, 07:51 PM True true... but I do think at least these for the standard 4 levels would be useful. How about a general <> function? Is that possible? X<> already prompts for the other location. Is it possible to code for both? :-) ▼ Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 07-23-2011, 08:00 PM It isn't possible. The op-codes used for commands don't have enough space to hold two register addresses. So it would have to be a separate command for each at about eighty bytes per -- even supporting just swaps of Y, Z and T with anything will eat into our feeble memory reserve. It is possible I could streamline things and reduce the space use a little by reusing code profusely. I don't think supporting the specific individual functions will be any smaller. I did have a general rearrange the (4 level) stack plus last X in a completely general manner instruction but it was lost. It replaced a lot of the traditional stack operations rather nicely but would have been really confusing for users. There is hope however, define them yourself and stash them in a flash segment. For example: ``` LBL'Z<>T' X<> Z X<> T X<> Z RTN ``` or ``` LBL'Z<>T' cpx Rv x<>y cpx R^ RTN ``` - Pauli htom trites jr Unregistered Posts: 66 Threads: 2 Joined: Aug 2007 07-23-2011, 07:55 PM Cleanest is to implement "stack-dup and stack-pop". Upon entry, your code does a stack-dup; this gives you a copy of the current stack and status. Do what you will (including calling other program segments.) When you're done, you explicitly write results into the lower stack and status registers, and then execute a stack-pop, which throws away all of your unsaved values, leaving the calling code with your results. Stack-pop gets really messy if you modify the structure of the "top stack". ▼ Marcus von Cube, Germany Unregistered Posts: 3,283 Threads: 104 Joined: Jul 2005 07-24-2011, 02:16 AM You will need a register area from the numerical registers for this. DUP is already there: STOS. Recalling only part of the stack can be done with R-CPY. R-CPY needs X for its argument so you need to take care of this in an extra step. Pauli, a command ROLLv with an argument for the number of rolls might be helpful. ▼ Paul Dale Unregistered Posts: 3,229 Threads: 42 Joined: Jul 2006 07-24-2011, 05:08 AM Quote:Pauli, a command ROLLv with an argument for the number of rolls might be helpful. Number of rolls as in the number of times Rv is executed or the number of registers being rolled? I suspect this suggestion will upset the RPL haters :-) To be honest, I've never needed either nor even wanted the capability and I've done more than a little RPL programming in my time. - Pauli ▼ Marcus von Cube, Germany Unregistered Posts: 3,283 Threads: 104 Joined: Jul 2005 07-24-2011, 03:19 PM Pauli, I meant the number of rolls to perform. ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 07-24-2011, 03:54 PM Quote: I meant the number of rolls to perform. Well, I would say Rv and R^ only the first n stack-registers is more important. Performing n rolls (as you suggest) needs just pressing the same key (Rv or R^) n-times, but imagine the following situation: You need the value from stack-register A during your calculation, and after that it's not needed anymore. In this case a "R^ A" would be very comfortable, wheras you would have to key in the following sequence to achieve the same: ```x<>y x<> Z x<> T x<> A ``` And you know how many keystrokes this would need (especially the "x<> _") ... :-( Franz Edited: 24 July 2011, 3:56 p.m.

 Possibly Related Threads… Thread Author Replies Views Last Post [WP-34S] Unfortunate key damage with update to V3 :( svisvanatha 5 3,234 12-10-2013, 11:37 PM Last Post: Les Bell WP-34S (Emulator Program Load/Save) Barry Mead 1 1,821 12-09-2013, 05:29 PM Last Post: Marcus von Cube, Germany DIY HP 30b WP 34s serial flash/programming cable Richard Wahl 2 2,554 12-04-2013, 11:14 AM Last Post: Barry Mead HP Prime: adding an entry to a vector Alberto Candel 12 4,073 12-02-2013, 01:18 PM Last Post: Alberto Candel HP Prime - vector question bluesun08 3 1,812 11-18-2013, 07:26 PM Last Post: Han [HP-Prime] - Missing confirmation before deletion Jean-Michel 11 3,692 11-14-2013, 05:47 AM Last Post: Thomas Radtke WP 34S/43 ?'s Richard Berler 3 2,083 11-10-2013, 02:27 AM Last Post: Walter B My FrankenCulator (wp-34s) FORTIN Pascal 4 2,190 11-09-2013, 06:18 PM Last Post: FORTIN Pascal WP 34S Owner's Handbook Walter B 5 2,705 11-09-2013, 05:34 PM Last Post: Harald wp 34s overlay and programming. FORTIN Pascal 6 2,931 11-08-2013, 01:28 PM Last Post: Nick_S

Forum Jump: