Is the following instruction correct? What does it do?
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
Of course, the result is all zeros,
regardless of the immediate operand.
|XOR operation on Bits|
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
ori and the
xori d,s,const # register d is assigned # the bitwise XOR of immediate # operand
const# and the contents of register $s. #
constis a 16-bit pattern, so # 0x0000 ...
The three operands of the instruction must appear in the correct order,
const must be within the specified range.
If the immediate operand in the assembly program 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.
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).