bit manips on WP 34S  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: bit manips on WP 34S (/thread252162.html) 
bit manips on WP 34S  Kiyoshi Akima  10042013 First, I apologize for interjecting RPN into a Prime forum :) I'm porting some of my old 16C programs to the 34S. Most of it is going smoothly but I've hit a couple of speed bumps involving MASKR and RLn. While the 34S has these functions, they have the bit count hardcoded into the instructions while the 16C takes the count from X. This means that on the 34S the counts have to be known at the time the program is written while the 16C defers this until the program is run. I can simulate the 16C's MASKR with "#002" ; "x<>y" ; "y^x" ; "DEC X" but is there a better way? The only way I've come up with to simulate RLn is with a loop. Is there a better way? While I'm at it, was making SDL/SDR work in integer mode ever considered? There are many times when multiplying/dividing by ten is useful.
And I suppose storage register logic is out of the question. Still, it be nice to be able to write something like "STO AND 02" or "RCL XOR 01".
Re: bit manips on WP 34S  Walter B  10052013
Quote:I recommend indirect addressing. E.g. store n in R00 and enter RL > 00 then. Quote:You can do the same on the 34S via indirect addressing: 2I admit that's a bit complicated. I had long discussions with Pauli about those trailing parameters in the command design phase. d:) Edited to correct a misunderstanding.
Edited: 5 Oct 2013, 9:42 a.m.
Re: bit manips on WP 34S  Marcus von Cube, Germany  10052013 You can likewise put the count on the stack and use the stack register for indirect addressing such as in MASKR > Y.
Re: bit manips on WP 34S  Kiyoshi Akima  10052013 Thanx to both Walter and Marcus.
I guess I'm still learning how to read the manual. I just saw the "n" and thought the counts had to be hardcoded into the instruction. I didn't see the underline indicating indirect capability.
Re: bit manips on WP 34S  Paul Dale  10062013 The arguments were added to the various bit manipulation commands because they were more powerful that way. We did consider 16C compatibility. We had all the 16C commands at one point then the argument versions were added and finally the now redundant 16C commands were removed. At the time, I came up with an alternative to support the 16C commands via library routines but it got lost somewhere along the way. Using RLn as an example, define this function and save it to library flash space:
LBL'RLn' In your program, XEQ'RLn' and goodness will follow. I intended DROPY instead of x<>y and DROP here but that command was removed. Subsequently, local registers were added so the fragment could also be:
LBL'RLn' This is the same number of steps and uses more stack space although it extends more easily. If you define all the required 16C functions that are missing similarly and save them into a library, porting your old programs will be a breeze. We should probably have included something like this in the 34S's standard library.
Re: bit manips on WP 34S  Didier Lachieze  10062013 Quote:You can also save a step with:
LBL'RLn' Re: bit manips on WP 34S  Paul Dale  10062013 This doesn't work with a stack size of 8 :)
 Pauli
Re: bit manips on WP 34S  Paul Dale  10062013 Quote: The 2^{x} function is better here: 2^{x} DEC X :) Last X isn't set correctly however.
Re: bit manips on WP 34S  Didier Lachieze  10062013 Yes, I'm so used to the standard RPN 4level stack that I always forget the 8level option on the WP 34s.
