Bit Manipulation Questions
Hello everyone, i've been reading many tutorials on bit manipulation and advanced bit manipulation. As seeing im new these may seem like funny questions but have in mind I am serious.
When working with the bit wise operators (^, |, &, ~) what are you exactly doing? Comparing the two bytes or individual bits and if so for what purpose. I have seen this done for encryption programs exspecially using the exclusive or because it automatically flips every bit around, but in that case do certain bit patterns represent certain characters or (I do know integers of course, its binary). I have seen that many decryption programs use direct bit manipulation to find encapsulated data and there it is again, are certain characters programmed represented by certain digits? say 0001 = a? Im still pretty much a poor sappy newbie but help is appreciated =D. Also much explanation one what bits are used for today helps and how it relates to data.
Hardware, Firmware, Embedded Systems.
All data inside the computer is in binary format. Most of the time, the compiler and operating system take care of the conversion, so neither the programmer or user really cares about that. I was amazed when I discovered that there is no binary "built-into" C, or C++.
I mostly work with hardware... I use binary in my test programs for troubleshooting the hardware. A single bit might indicate the state of a switch, or a single bit might turn-on an LED. You can use an oscilloscope to see the high/low (1 or 0) state of a port. (The data on the data bus is always changing, so the 'scope won't tell you anything, unless the signal is stuck high or low.)
Programmers who write "firmware"* for embedded systems, or who write drivers, often deal in binary. Bytes and single-bits in a "register"* often indicate the status of something, or come configuration setting.
All of this bitwise programming is done using hexadecimal, because it is easy (for us humans) to convert between hex and binary.
*FIRMWARE: Software that is semi-permanently stored in an EPROM or flash.
*REGISTER: One or more bytes of fixed-address memory, reserved for a particular use, often located physically on a daughter-card, in a peripheral device, or inside a microprocessor. Not part of the regular RAM... Not part of the heap.