Shop OBEX P1 Docs P2 Docs Learn Events
Actual behavior of SEUSSF and SEUSSR — Parallax Forums

Actual behavior of SEUSSF and SEUSSR

moonymoony Posts: 27
edited 2021-01-14 00:29 in Propeller 2
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.

Comments

  • 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.
  • I'm fairly certain I saw a diagram of what these do at some point... Can't seem to find it right now.
  • @Kaio my Propeller 2 has not yet arrived. If this isn't answered when it arrives, I'll document it myself.
  • 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;
    }
    
  • KaioKaio Posts: 253
    edited 2021-01-14 14:34
    Thank you @Wuerfel_21. It looks like that these instructions can be used to encode and decode a value.
  • 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
  • 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.
  • roglohrogloh Posts: 5,122
    edited 2021-01-14 22:08
    That diagram was probably the one shown in one of my threads here....

    https://forums.parallax.com/discussion/comment/1479691/#Comment_1479691
  • TubularTubular Posts: 4,620
    edited 2021-01-14 22:33
    Yes!! Collective forumista-brain beats google search once again
  • Wuerfel_21Wuerfel_21 Posts: 4,374
    edited 2021-01-14 22:33
    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:
    P2_instruction_SEUSSF_SEUSSR.png
Sign In or Register to comment.