Here we will see how to find 2’s complement with carry.
Write 8085 Assembly language program to find 2’s complement of a number stored in F100 with the carry, and store at F150 and F151.
In 8085, there is CMA instruction to complement a number. Then we can add 01 with it to make it 2’s complement. While adding 01 with it, the carry may generate. We will store it to F151, and the actual complemented value will be at F150.
|F000||3A, 00, F1|| ||LDA F100H||get number from memory to A|
|F003||2F|| ||CMA||get 1's complement|
|F004||C6, 01|| ||ADI 01||Increase it by 1|
|F006||6F|| ||MOV L,A||Store A into L|
|F007||3E, 00|| ||MVI A,00H||Clear Accumulator|
|F009||8F|| ||ADC A||Add A + A + carry|
|F00A||67|| ||MOV H,A||Load A into H|
|F00B||22, 50, F1|| ||SHLD F150||Store HL into memory|
|F00E||76|| ||HLT||Terminate the program|