Hey folks! I just started learning C and I have a conceptual question that I'd love your insights on. I've noticed that C has bitwise operators, including bit shifting, and it seems like I can use registers without diving into inline assembly. Why can I do this if only assembly directly interacts with specific registers to perform those bit shifts? I appreciate any detailed explanations! Thanks a lot!
2 Answers
Great question! In C, you don't directly interact with registers, but the compiler translates those bitwise operations into the appropriate assembly instructions that do. This means you can handle shifts in C without manually writing inline assembly. It's all done under the hood!
When you use the 'register' keyword in C, you're telling the compiler, "Hey, try to keep this variable in a register if possible." It’s merely a suggestion—unlike inline assembly, where you directly instruct the compiler about how to handle specific registers.

Exactly! The 'register' keyword is more of a gentle nudge than a command. If you really need direct control over a register, inline assembly is the way to go.