Toggle search
Search
Toggle menu
notifications
Toggle personal menu
Editing
Basic Assembly Programming
(section)
From Turing Complete
Views
Read
Edit
Edit source
View history
associated-pages
Page
Discussion
More actions
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===== XOR As a Bit Toggle ===== Remember the level Bit Inverter? We can use a bitwise XOR (written <code>^</code>) to selectively invert bits. The operation <code>m ^ w</code> “toggles” all the bits in <code>w</code> that match up with the ones in <code>m</code>, and leave the rest unchanged. We call <code>w</code> the “word” or “argument” and <code>m</code> the “mask.” Note that these names are specific to this use case and do not apply to all uses of XOR. So if we want to completely invert a byte, we want to XOR it with a mask which is all ones. To do that, we’ll need to construct the mask. We can’t simply <code>loadi</code>, because our mask has the value <code>255</code> and immediates must be less than 64. <span id="multi-purpose-subtraction"></span>
Summary:
Please note that all contributions to Turing Complete are considered to be released under the Creative Commons Attribution-ShareAlike (see
TuringComplete:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)