 This time we're going to be looking at logical operations. The MIPS architecture provides a series of useful logical operations to us. We have AND, OR, XOR, and each of those has an immediate complement as well. It also provides the NOR instruction. We only have a NOT pseudo instruction because we can actually build a NOT instruction using the NOR instruction where one of the inputs is zero. Once we have zero in a register, that's actually really easy to do. Logical operations, as you're probably familiar with them, take two bits as inputs, one from each of your sources, and produce one bit as an output. So one and one produces one. But all of our registers have 32 bits to them. It probably doesn't make too much sense to say what is 376 and 429. So what we're going to do instead is to perform the same logical operation to each pair of bits. So we'll compare, say, the first two bits in each of our sources, produce a result bit. That will be the first result bit. Then we'd compare the next pair of bits and produce another result bit. That will make these bitwise logical operations. They're only looking at one pair of bits at a time. They're not doing something global over the entire number. So for example, if I have these two values for t0 and t1, then I can apply a bitwise logical and or xor to them. And if you just read down one of the columns, you'll see that the operations pretty much make sense. One and zero is zero, but one or zero is one. One xor one is also one. So the first column is really just all about that one and the zero there. The second column has zero and zero in it. So zero and zero is zero, zero or zero is zero, and zero xor zero is zero. All of these operations, too, is performed the same logical operation over each pair of bits. So it will walk down each of the columns, make the comparisons, and there won't be any interaction between the columns. These may not seem terribly useful at first, but there are a couple of common uses for them. They're often used when you're interested in working with flags, when you have a series of binary values where you just want to know if something has been enabled or not, but you don't want to take up an entire 32-bit block of memory just for that. You've got a whole bunch of them. You want to stuff them all into one space. So you can stuff 32 of them into one word-size block of memory, but you need to be able to pull out individual bits. Using an AND immediate, that's really easy. You can say, oh, I'm only interested in bit three or bit seven. I can read that bit off and know what I should do in this case. They're also really popular for pseudo-random number generators because they allow you to manipulate the bits in odd ways that aren't immediately obvious from the numbers that we're looking at. What should you get if you have 327xOrd with 496? It's not immediately obvious. You have to look at each pair of bits and you're likely to end up with something that looks completely unrelated to what you started out with. So there are a few other uses for these, but these are the two most common ones that you're likely to see.