Welcome to the Parallax Discussion Forums, sign-up to participate.

# Actual behavior of SEUSSF and SEUSSR

Posts: 18
edited 2021-01-14 (12:29 AM)
These instructions are documented to relocate and periodically invert the bits of their argument, but their actual behavior is undocumented. Anyone know what algorithm they follow?
If not, posting how they both behave with the attached inputs (which are given in binary) is also welcome.

EDIT: Oop- the inputs are 16bit. You should be able to see how to extend them to 32-bit, though, it's a pretty simple pattern.

• Posts: 224
It's a pity that the documentation is still not complete. But I think you could figure it out by writing some code using PNut and debug. It would be appreciated if you would share your result with others here.
• Posts: 1,099
I'm fairly certain I saw a diagram of what these do at some point... Can't seem to find it right now.
• Posts: 18
@Kaio my Propeller 2 has not yet arrived. If this isn't answered when it arrives, I'll document it myself.
• Posts: 1,099
Well, I found something. spinsim source code tells us that
``````static int32_t seuss(int32_t value, int32_t forward)
{
uint32_t i, x;
uint8_t bitnum[32] = {
11,  5, 18, 24, 27, 19, 20, 30, 28, 26, 21, 25,  3,  8,  7, 23,
13, 12, 16,  2, 15,  1,  9, 31,  0, 29, 17, 10, 14,  4,  6, 22};

if (forward)
{
x = 0x354dae51;
for (i = 0; i < 32; i++)
{
if (value & (1 << i))
x ^= (1 << bitnum[i]);
}
}
else
{
x = 0xeb55032d;
for (i = 0; i < 32; i++)
{
if (value & (1 << bitnum[i]))
x ^= (1 << i);
}
}
return x;
}
``````
• Posts: 224
edited 2021-01-14 (2:34 PM)
Thank you @Wuerfel_21. It looks like that these instructions can be used to encode and decode a value.
• Posts: 4,223
Wuerfel_21 wrote: »
I'm fairly certain I saw a diagram of what these do at some point... Can't seem to find it right now.

I remember it too, i think maybe @cgracey used it in one of his online video presentations?

I think it had red and green lines showing which bits were inverted and which not, and mapped their source and destination bits
• Posts: 1,099
Tubular wrote: »
I think it had red and green lines showing which bits were inverted and which not, and mapped their source and destination bits

yes, that one.
• Posts: 2,835
edited 2021-01-14 (10:08 PM)
That diagram was probably the one shown in one of my threads here....

https://forums.parallax.com/discussion/comment/1479691/#Comment_1479691
• Posts: 4,223
edited 2021-01-14 (10:33 PM)
Yes!! Collective forumista-brain beats google search once again
• Posts: 1,099
edited 2021-01-14 (10:33 PM)
Oh, rogloh-sensei, master of the ancient art of ForumSearch-Fu, I see that I still have much to learn from you.....

Oh well, let's repost it here: