In this program we will see how to find 2's complement of the content of flag register.
Write 8085 Assembly language program to find 2's complement of the content of flag register.
We cannot access the total flag register directly. To use them we have to push the PSW(Accumulator-Flag) into stack, and then pop it to another register pair, then after complementing the LS byte of that register pair, we have to push it again into the stack, and then pop it to PSW to get it into Flag bits.
Here we are not putting any input directly. If the flag bits are (0100 0001), then the program will generate the complement of it.
|F000||31, 00, 90||LXI SP,9000H||Initialize the stack pointer|
|F003||F5||PUSH PSW||Push A and F content to Stack|
|F004||C1||POP B||Pop from stack and store to BC|
|F005||79||MOV A,C||Take the number from C to A|
|F006||2F||CMA||Complement the accumulator|
|F007||4F||MOV C,A||Store A to C|
|F008||0C||INR C||Increase C by1 to get 2's complement|
|F009||C5||PUSH B||Push BC into stack|
|F00A||F1||POP PSW||Pop stack content to A and F|
|F00B||76||HLT||Terminate the program|
After executing the program, the flag content will be (1011 1111)