8085 programs to find 2's complement with carry | Set 2
Last Updated : 11 Jul, 2025
Problem-1: Find 2's complement of an 8 bit number stored at address 2050. Result is stored at address 3050 and 3051. Starting address of program is taken as 2000.
We are taking complement of the number using CMA instruction.
Then adding 01 to the result.
The carry generated while adding 01 is stored at 3051.
Program -
Memory Address
Mnemonics
Comment
2000
LDA 2050
A←2050
2003
CMA
A←complement of A
2004
INR A
A←A+01
2005
MOV L, A
L←A
2006
MVI A 00
A←00
2008
ADC A
A←A+A+Carry
2009
MOV H, A
H←A
200A
SHLD 3050
L→3050, H→3051
200D
HLT
Explanation - Registers used: A, H, L
LDA 2050 loads content of 2050 in A
CMA complements the contents of A
INR A increases A by 01
MOV L, A copies contents of A in L
MVI A 00 moves 00 in A
ADC A adds A, A, Carry and assigns it to A
MOV H, A copies contents of A in H
SHLD 3050 stores value of H at memory location 3051 and L at 3050
HLT stops executing the program and halts any further execution
Problem-2: Find 2's complement of a 16 bit number stored at address 2050 and 2051. Result is stored at address 3050, 3051 and 3052. Starting address of program is taken as 2000.