The 8085 microprocessor has five flags that we can access, and one of them is the Parity flag located at D2 data bus.
The Parity flag is said to be set when there are even numbers of 1’s and gets reset if there are an odd number of 1’s.
So in this program, we are basically going to load an 8-bit hexadecimal number and will check whether the parity flag is set or reset.
However, there is a twist we are going to perform an addition operation between two 8-bit hexadecimal number and then we will check out whether the parity flag is set or reset.
We are going to use three memory locations; starting from 2000H to 2003H, in the 2000H and 2001H memory locations, we are going to store the 8-bit hexadecimal numbers A0H and 12H.
In 2002H memory location, we are going to store the result and in the 2003H memory location, we are going to display EE if the parity flag is set or OO in case the parity flag is reset.
LXI H, 2000 // using LXI we are going to load HL register pair to point at the content of 2000H memory location
MOV A, M // the content of 2000H will be copied to the accumulator
INX H // the HL register pair will be incremented by 1
ADD M // add operation is performed between the content of accumulator and with the content of 2001H memory location
STA 2002H // the result of addition currently stored in the accumulator will be stored at the 2002H memory location
LXI H, 2002H //using LXI we are going to load the HL register pair again to point at the 2002H memory location
MOV A, M // using MOV we are going to copy the content of 2002H to the accumulator
ORA A //using ORA we are going perform OR operation
JPO ODD //JPO jump instruction will jump in case the parity flag is reset
INR L //now if Parity flag is set then using INR we are going to increment the L register by 1
MVI M, EE // EE will be copied to 2003H memory location
Label INR L //if parity flag is reset then the jump instruction will get executed
MVI M, 00 //OO will be copied to 2003H memory location
|Memory Location||OPCODE||Operand||Label||Hex Code|