Is the following instruction correct? What does it do?

andi $8,$0,0xFFFF

A good answer might be:

It is correct, but not very sensible. It ANDs the contents of the zero register (all zeros) with the immediate operand and puts the result in register $8. Of course, the result is all zeros, regardless of the immediate operand.

Exclusive Or Immediate

  XOR Operation on Bits
  first operand 0011
  second operand 0101
    ________
  result 0110

Filling a register with all zero bits is called clearing the register. Clearing a register is common, but the above instruction is not the best way to do it.

An exclusive OR is nearly the same as the more common OR (the inclusive OR) except that the result is zero when both operands are one.


Here is a description of the assembly language instruction. The machine language for the instruction looks much the same as the ori and the andi instruction.

xori d,s,const     # register d <-- bitwise XOR of immediate operand const
                   #                and the contents of register $s.
                   #                const is a 16-bit pattern, so
                   #                0x0000 ... const ... 0xFFFF

The three operands of the instruction must appear in the correct order, and const must be within the specified range. If the immediate operand in a source instruction is less than sixteen bits (such as 0x2) the assembler expands it to sixteen. If it is more than sixteen bits the assembler writes an error message.


QUESTION 12:

Here are the two patterns, written both in bit patterns and in hex. Perform the bitwise XOR operation. (Do it with the bits, then re-write the answer in hex).

0000 1111 1010 0101  0FA5
0011 0110 1000 1111  368F
---- ---- ---- ----  ----