Find 1’s complement of a number

 

Algorithm for finding 1’s Complement

 

Step I : Initialize the data memory.

Step II : Load the number in AX.

Step III : Initialize counter = 16.

Step IV : Rotate number by 1 bit position to left with carry.


Step V : Complement carry.

Step VI : Decrement counter.

Step VII : Check if count = 0. If yes, go to step VIII else goto Step IV.

Step VIII : Rotate number by 1 bit position to left with carry to restore original carry back.

Step IX : Display 1’s complement.

Step X : Stop.

Program Code 1’s complement of a number: