8085 program to find 2’s complement of the contents of Flag Register
Problem – Write an assembly language program in 8085 microprocessor to find 2’s complement of the contents of Flag Register.
- Initialize the value of Stack Pointer (SP) to 3999
- Push the contents of PSW (Register pair formed by Accumulator and Flag Register) into the memory stack
- Pop the contents from the stack into register pair BC
- Move the contents of register C to A
- Take 1’s complement of the contents of A
- Increment the contents of A by 1
- Move the contents of A to C
- Push the contents of register pair BC into the stack
- Pop the contents of stack into PSW
||LXI SP 3999
||SP <- 3999
||PUSH value of Accumulator and Flag into the stack
||POP value from Top of stack into register pair BC
||MOV A, C
||A <- C
||A = 1’S complement of A
||A = A + 1
||MOV C, A
||C <- A
||PUSH value of register pair BC into stack
||POP value from Top of stack into Accumulator and Flag
- LXI SP 3999 is used to initialize the value of Stack Pointer(SP) to 3999.
- PUSH PSW is used to push the contents of PSW into the memory stack.
- POP B is used to pop the contents from the top of stack into register pair BC.
- MOV A, C moves the contents of register C to A.
- CMA takes 1’s complement of the contents of A.
- INR A increments the contents of A by 1.
- MOV C, A moves the contents of A to C.
- PUSH B is used to push the contents of register pair BC into the stack.
- POP PSW is used to pop the contents of stack into PSW.
- HLT is used to end the program.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!