CPI
Syntax: CPI 8-bit
Where 8-bit is an immediate data.
Byte: 2 byte
Addressing Mode: Immediate Addressing
Working:
1. This is Two byte instruction.
2. microprocessor will allocate First byte for opcode CPI and Second byte for immediate operand.
3. This instruction compares the content of the register R with content of the Accumulator.
The comparison is done using subtraction of the content of register from the Accumulator.
The content of Accumulator remains unchanged.
Conditions of Comarison:
1. If [A] < [R] then Cy flag is set i.e. Cy =1.
2. If [A] = [R] then Z flag is set i.e Z=1.
3. If [A] > [R] then Cy and Z flags are reset. i.e Cy = 0 and Z = 0
4. Flag
Example: CPI 22H
where [A]= 11H
After execution of CPI 22H
[A] = 11H
2's complement subtraction:
A= 11 = 0001 0001
= 22 = 0010 0010
1's complement of 22 = 1101 1101
2's complement of 22 = 1101 1110
1
A = 0001 0001
2's copm.22= 1101 1110
0 1110 1111
Cy = 1..............[complement the carry (according to 2's complement subtrsction)]
Z = 0
Comments
Post a Comment