ALU 101 Instruction Set and Operations 2 — Questions and Answers
Question 1: What does the NOP instruction do in an ALU-based processor?
- Negates the accumulator
- Performs no operation and advances the program counter (Correct answer)
- Clears all flags
- Resets the ALU
Correct answer: Performs no operation and advances the program counter
NOP (No Operation) causes the processor to do nothing and simply advance to the next instruction, used for timing, alignment, or placeholder purposes.
Question 2: The INC instruction in an ALU increments a value by:
- The value in the accumulator
- 2
- 1 (Correct answer)
- A specified immediate value
Correct answer: 1
The INC instruction adds 1 to its operand, incrementing the value by exactly one.
Question 3: Which operation clears (sets to 0) a specific bit in a register using the ALU?
- OR with a mask of 0s in target positions
- AND with a mask of 0s in target positions (Correct answer)
- XOR with the register itself
- NOT the register value
Correct answer: AND with a mask of 0s in target positions
AND-ing with a mask that has 0s in the target bit positions clears those bits, as AND with 0 always produces 0.
Question 4: A rotate-right-through-carry operation moves bits to the right and:
- Discards the LSB
- Moves the LSB into the carry flag and the carry flag into the MSB (Correct answer)
- Fills vacated positions with zeros
- Copies the MSB to all positions
Correct answer: Moves the LSB into the carry flag and the carry flag into the MSB
Rotate right through carry shifts bits right, placing the outgoing LSB into the carry flag and the previous carry flag value into the MSB.
Question 5: What is the result of XOR-ing a register value with itself (A XOR A)?
- The value A unchanged
- All 1s (0xFF...)
- All 0s (zero) (Correct answer)
- The inverse of A
Correct answer: All 0s (zero)
XOR-ing any value with itself produces all zeros, because each bit XOR'd with itself yields 0.
Question 6: Which ALU instruction is typically used to toggle specific bits in a register?
- AND
- OR
- XOR (Correct answer)
- NOT
Correct answer: XOR
XOR-ing with a mask toggles (flips) the bits in positions where the mask has 1s, while leaving other bits unchanged.
What does the NOP instruction do in an ALU-based processor?