News for hackers. Stuff that matters.
Re:“C is quirky, flawed, and an enormous success” – Dennis R... by zabzonk on Sunday July 09, 2023 @06:10AM (#36653177)
bits are not addressable in C and are thus not directly accessible.
Re:“C is quirky, flawed, and an enormous success” – Dennis R... by jacquesm on Sunday July 09, 2023 @06:13AM (#36653189)
They are also not normally directly addressable by the CPU, you'll have to do some combining and splitting with separate instructions. Some CPUs are better at this than others.
Re:“C is quirky, flawed, and an enormous success” – Dennis R... by messe on Sunday July 09, 2023 @06:33AM (#36653301)
I wouldn’t quite count it as bit-addressing, but x86, for example, can load bits directly into the carry flag using the BT instruction which can take a register or memory address as it’s first argument, with the bit being given as the second.
Re:“C is quirky, flawed, and an enormous success” – Dennis R... by jacquesm on Sunday July 09, 2023 @07:40AM (#36653663)
There have been all kinds of variations on that theme. One of the nicest is 'bit test and set' as an atomic instruction, that one enables a whole raft of nice stuff.
Re:“C is quirky, flawed, and an enormous success” – Dennis R... by pm215 on Sunday July 09, 2023 @06:59AM (#36653436)
Tangent: some Arm Cortex-M class CPUs had a feature called "bit-banding" where you could do byte accesses to an area of the address map and the CPU would turn these into bit accesses to a different part of memory. So the alias word at 0x23FFFFFC maps to bit [7] of the byte at of RAM at 0x200FFFFF, for example, and you can do a word write to 0x23FFFFFC to change just that bit 7, saving having to do it by hand (which is particularly awkward if you need to ensure the atomicity of the bit update).

https://developer.arm.com/documentation/100165/0201/Programm...