While I am familiar with bitwise operations, its been about a year since ive done any work with them and im trying to break apart the operations for the set/unset functions for the memory map.
For example: The "void mmap_set (int bit)":
Code: Select all
inline void mmap_set (int bit)
{
_mmngr_memory_map[bit / 32] |= (1 << (bit % 32));
}
Code: Select all
map[0] = 1111 1111 0011 1100 0000 0000 0000 0000 0000
bit = 23
i = 0 (map array index (23 / 32) )
map[0] |= (1 << (bit % 32 ) )
map[0] |= (1 << (23) )
Now, This is where I get confused.
(1 << 23) = 0000 0000 1000 0000 0000 0000 0000 0000 0000
but if you OR that with map[0]
Code: Select all
0000 0000 0100 0000 0000 0000 0000 0000
1111 1111 0011 1100 0000 0000 0000 0000
Could someone explain where I am misunderstanding this please?
By my understanding it should be a right shift (1 >> 23) to get
Code: Select all
(1 >> 23) = 0000 0000 0000 0000 0000 0010 0000 0000
Thanks for your time in reading.
Andy