This is for my computer architecture class and we have a lab for ARMv8, and for one of the parts of the code we're supposed to figure out is setting the least significant 2 bits of a register, I'm confused as to what this means? If anyone has an example that would be great.
-
3pretty much a duplicate of [How do you set, clear, and toggle a single bit?](https://stackoverflow.com/q/47981). – Peter Cordes Apr 11 '20 at 01:47
-
1Are you asking how to do it, or do you really not know what bits are or what setting a bit means? https://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html is probably relevant. – Peter Cordes Apr 11 '20 at 02:01
1 Answers
Assuming a register is 64 bits, base 2 (binary), then how is that different then say the decimal number 12345678. If I want to change the lower two numbers (base 10 in this case) I change the 7 and 8. If I want to zero then then I get 12345600 then if I want to make them something else I put those numbers in there 12345632.
If you want to set them in the sense turn on in binary, set vs reset, then you want to change those two bits to ones.
Very unclear what you are asking so is this how do I do this programmitically, is this the above what does it mean? No need to know the architecture as all usable ones will have a way to AND and OR. On wikipedia you can look for "OR gate" and "AND gate" and they have truth tables for those operations. Then you can look those instructions up in the instruction set if this is assembly language or if C or python or java or whatever look up how to do those operations in those languages, and the description of what those operations mean.
Hint, one operation can force a bit to one no matter what it was. One operation can force a bit to zero no matter what it was. And both operations have a way to leave a bit the way it was unmodified.
Please improve your question so it is understandable.
- 69,149
- 8
- 89
- 168