The Museum of HP Calculators

HP Forum Archive 17

 hp42s ROT XY functionMessage #1 Posted by joe santavicca on 26 Sept 2007, 6:56 p.m. How does the function work - I've recently come across a need for performing binary math. This is one of the rare instances where my intuition has failed when using my hp. The manual is a bit thin on the subject. Help if you know.

 Re: hp42s ROT XY functionMessage #2 Posted by Raymond Del Tondo on 27 Sept 2007, 4:18 a.m.,in response to message #1 by joe santavicca ROTXY - Rotate Y by X bits. Simply works as expected;-) HTH Raymond

 Re: hp42s ROT XY functionMessage #3 Posted by John Limpert on 27 Sept 2007, 4:30 a.m.,in response to message #1 by joe santavicca What are you having trouble with? I looked it up in the manual and it does a standard rotate left or rotate right on a 36-bit number. If you look at the y-register as an array of 36 bits, where index 0 is the least-significant-bit and index 35 is the most significant bit, and the x-register contains 1, then: ```t = y[0] y[0] = y[1] y[1] = y[2] ... y[33] = y[34] y[34] = y[35] y[35] = t ``` That was a rotate right by one bit. You can think of it as a circular shift-register where the most-significant-bit is connected to the least-significant-bit.

 Re: hp42s ROT XY functionMessage #4 Posted by Thomas Okken on 27 Sept 2007, 6:19 a.m.,in response to message #3 by John Limpert Also note that the sign of X indicates the direction of the rotation: 2 means rotate right by 2 bits, -3 means rotate left by 3 bits, etc. Edited: 27 Sept 2007, 6:21 a.m.

 Re: hp42s ROT XY functionMessage #5 Posted by Doug on 27 Sept 2007, 7:47 a.m.,in response to message #3 by John Limpert On the 41C, ROTXY uses 32 bits but I will assume it works the same. Assign HEXIN and HEXVIEW (or the equivalents) to keys to get a better feel for what is going on. Assign the AND/OR/NOT functions as well. Wish I had a 42s. Best Edited: 27 Sept 2007, 7:53 a.m.

 Re: hp42s ROT XY functionMessage #6 Posted by Walter B on 27 Sept 2007, 9:32 a.m.,in response to message #1 by joe santavicca The shortest & easiest explanation of binary rotation commands is found on the back label of the HP 16C. HTH Walter Edited: 27 Sept 2007, 9:36 a.m.

Go back to the main exhibit hall