←back to thread

154 points rbanffy | 1 comments | | HN request time: 0.215s | source
Show context
dlcarrier ◴[] No.45075524[source]
It's interesting that a high-performance computing core has added instructions for bit manipulation. They're really common on low-power embedded cores, where bit manipulating inputs and outputs is more common. They can save a lot of instructions when needed, though. For example, clearing a bit in a variable, without an express instruction, requires raising two to the power of the bit, inverting the result, anding that with the variable, then writing the result back to the variable. Depending on the language, it looks something like this:

    Variable &=~(2^Bit)
The series of bitwise operators looks more grawlix (https://en.wikipedia.org/wiki/Grawlix) than instructions, as though yelling pejoratives at the bit is what clears it.
replies(4): >>45075580 #>>45075627 #>>45075809 #>>45075920 #
1. Findecanor ◴[] No.45075809[source]
M68K also had single-bit instructions. Way back when I wrote M68K assembly, I used them a lot.

I'd think there are quite a few data structures and algorithms where there can be benefits of using powers of two, or to count bits in a word.

RISC-V without the B(itmanip) extension is otherwise quite spartan. B also contains many instructions that other ISAs have in their base set, such as address calculation, and/or/xor not, rol/ror, and even some zero/sign-extension ops.