A particular processor can perform the AND, OR, and XOR operators on two 8-bit o
ID: 656444 • Letter: A
Question
A particular processor can perform the AND, OR, and XOR operators on two 8-bit operands. The first operand is contained in a register, while the second is a literal, or constant value. The processor then stores the result in a destination register. For example, the notation shown below ANDs the contents of register Rl (whatever they might be) with the binary value 00110011 and places the result into R2. AND (Rl, 00110011, R2) Using notation similar to that shown above, indicate how a user might carry out the following tasks: Register Rl contains a value. We wish to place the value into register R2 so that we may operate upon it, but the only relevant bits are in bit positions 6, 5, I, and 0 of Rl. Thus, we want to clear the other bits when placing the value into R2. We need to move the value in register R3 to register R4 so that we can use the value to enable a peripheral. To correctly enable the device, we must set the bits in positions 7, 6, I, and 0; the bits in the remaining positions must remain unchanged. With the value already in R4, we most now change the status of certain aspects of the peripheral. Thus, we must toggle the values in bit positions 5, 3, 2, and I; the bits in the remaining positions must remain unchanged. The value should be returned to R4. In each case, you don't know what value is in the register operand acting as the source. You only know that it needs to be changed in the way described in each part of this problem.Explanation / Answer
a.
R1 is the source register and contains first operand.
R2 is the destination register.
The second operand is 00110011.
The destination register should contain the value in a way the bit positions 6, 5, 1 and 0 of R1 should remain unchanged and the other bit positions should be cleared.
Using the specified notation it is written as,
AND (R1, 00110011, R2).
The AND operation is used to obtain the result. The AND operation is performed between R1 and 00110011. The AND operation results 1 when both the bit values are 1 and 0 otherwise.
The value of source register is 10101111. The AND operation between these two operands is as follows:
The result is 00100011 and consists of the same bits at positions 6, 5, 1 and 0. The result is stored in R2.
b.
R3 is the source register and contains first operand.
R4 is the destination register.
The second operand is 00110011.
The destination register should contain the value in a way the bit positions 7, 6, 1 and 0 of R1 should remain unchanged and the other bit positions should be cleared.
Using the specified notation it is written as,
XOR (R3, 00110011, R4).
The XOR operation is used to obtain the result. The AND operation is performed between R1 and 00110011. The XOR operation results 1 when both the bit values are equal otherwise it results 0.
The value of source register is 00000011. The XOR operation between these two operands is as follows:
The result is 11000011 and consists of the same bits at positions 7, 6, 1 and 0. The result is stored in R4.
c.
R4 is the source register with the value 11000011 and destination register.
The second operand is 00110011.
The value stored in register R4 must be toggle at bit positions 5, 3, 2 and 1. Thus the source contains the value should contain 11101101.
Using the specified notation it is written as,
OR (R4, 00110011, R4).
The OR operation is used to obtain the result. The OR operation is performed between R4 and 00110011. The OR operation results 0 when both the bit values are 0 and otherwise it results 1.
The value of source register is11101101. The OR operation between these two operands is as follows:
The result is 11111111 and is stored in R4.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.