The bit manipulation stuff this evening reminded me of something I learned about as a teen.
On the CDC Cyber mainframe I used back then, the data registers were 60-bit, and it used 6-bit bytes. They would cram 10 6-bit characters into a single machine register. One interesting thing was that there was an assembly macro to convert any 00 bytes in a word to spaces (which were 55 in octal). The neat thing is that there was no looping, it was just a series of instructions that operated on the whole register each time.
A while back I dug up the original Cyber code for it and made a C program that did the same operations so I could study how it worked. Here is the output of the C program. Basically, x1 contains the initial 10-character value, where you can see some bytes are 00. It also stores
37373737373737373737 (octal) into x3. In the end, it puts the final result in x6, which is exactly
what was in x1, but each 00 bytes has been changed to 55.
x1 = 61007700223300440001
x3 = 37373737373737373737
x6 = x3 & x1 x6 = 21003700223300040001
x7 = ~x3 & x1 x7 = 40004000000000400000
x6 = x6 + x3 x6 = 60377637617237433740
x6 = x6 | x7 x6 = 60377637617237433740
x7 = ~x3 & x6 x7 = 40004000404000400040
X3 = spaces x3 = 55555555555555555555
x6 = x7 x6 = 40004000404000400040
x7 = lsr x7 5 x7 = 01000100010100010001 (lsr = logical shift right)
x7 = x6 - x7 x7 = 37003700373700370037
x7 = x6 | x7 x7 = 77007700777700770077
x3 = ~x7 & x3 x3 = 00550055000055005500
Final result into x6
x6 = x1 | x3 x6 = 61557755223355445501