This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How long bitfields on which ARM?

I need to be able to handle long bitfields as effectively as possible. Right now I need up to 64 bits in length.

Are there instructions to set, clear and test individual bits in one cycle available for some of the architectures? Which? Particularly, will the M0+ handle it (which only does reduced thumb2)? If not, which comparable?

What I find confuses me. In a thumb2 ref card I found that "Width of bitfield. <width> + <lsb> must be <= 32." But some 5 years ago I programmed some on a STR91xF ARM9 processor, and there was some talk about l-o-n-g bit arrays that could be handled in one cycle, but there was some 1024 bytes of microcoded table for this. (See, I am already long afloat, in deep water! Maybe this was for all kind of masks?)

Also, what would happen if I need to set or clear (like) bit 27 and bit 60 in one instruction? Will compilers (which?) then treat a full 32 bits word times two, a 64 bits word, or will it handle only byte 3 and byte 7 (starting at byte 0) and do the trick on them? Is the barrel shifter part of this?

Aclassifier

Øyvind Teig | Some of my blog notes

Parents
  • Thank you, guys! Your answers have been very helpful! I need to learn more than I think I need to know.

    I have a CSP-type channel based scheduler (Publication details by Øyvind Teig) where signalling on a channel is done by setting a bit in a bitfield. Right now I have 39 channels (synchronous with data, asynch without data=signal and finally timeout signals).

    Also, the selective choice (ALT) implementation for each CSP process needs a bitfield that bit-by-bit matches the channel bitfield. This holds the set of channels that's present in the ALT set and then contains a mask that's used to clear all those bits when one guard of the ALT is taken.

    With an 8 bit processor I have used byte_8, int_16, long_32 or long_long_64 (all used as unsigned), automatically handled with width dependent macros. For single bit handling there are several combinations of setting, testing and clearing with dynamic index and several with constant bit index. Then there is masking with dynamic or constant mask. Then our compiler on some of these cases shoots directly on the bit, which I have studied, and for some cases a small dynamic bit handling library was written. And some times it takes all 8 bytes in, clears one bit of them and writes all 8 bytes back!-(

    When recompiling this system for the ARM I am sure there would be special cases too. What I learn from you is that I should disregard byte_8 and int_16 (with 39 channels those cases wouldn't have been seen anyhow). I have not done any assembly coding for this (sorry, I forgot to tell), so I would basically rely on the compiler. Also I think I have learned that there would be differences with regard to processors.

    None of you triggered on the mask(?)-array that I think was present on the STR91xF ARM9?

    May I ask what your gut feeling on M0+ vs M3/M4 architectures would be?

    Best regards

    Øyvind Teig, Trondheim, Norway

Reply
  • Thank you, guys! Your answers have been very helpful! I need to learn more than I think I need to know.

    I have a CSP-type channel based scheduler (Publication details by Øyvind Teig) where signalling on a channel is done by setting a bit in a bitfield. Right now I have 39 channels (synchronous with data, asynch without data=signal and finally timeout signals).

    Also, the selective choice (ALT) implementation for each CSP process needs a bitfield that bit-by-bit matches the channel bitfield. This holds the set of channels that's present in the ALT set and then contains a mask that's used to clear all those bits when one guard of the ALT is taken.

    With an 8 bit processor I have used byte_8, int_16, long_32 or long_long_64 (all used as unsigned), automatically handled with width dependent macros. For single bit handling there are several combinations of setting, testing and clearing with dynamic index and several with constant bit index. Then there is masking with dynamic or constant mask. Then our compiler on some of these cases shoots directly on the bit, which I have studied, and for some cases a small dynamic bit handling library was written. And some times it takes all 8 bytes in, clears one bit of them and writes all 8 bytes back!-(

    When recompiling this system for the ARM I am sure there would be special cases too. What I learn from you is that I should disregard byte_8 and int_16 (with 39 channels those cases wouldn't have been seen anyhow). I have not done any assembly coding for this (sorry, I forgot to tell), so I would basically rely on the compiler. Also I think I have learned that there would be differences with regard to processors.

    None of you triggered on the mask(?)-array that I think was present on the STR91xF ARM9?

    May I ask what your gut feeling on M0+ vs M3/M4 architectures would be?

    Best regards

    Øyvind Teig, Trondheim, Norway

Children