8085 programs to find 2’s compliment with carry | Set 2


Here we will see how to find 2’s complement with carry.

Problem Statement

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.

Discussion

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.

Input

Address
Data


F100
08


 

Flow Diagram

 

Program

Address
HEX Codes
Labels
Mnemonics
Comments
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

 

Output

Address
Data


F150
F8
F151
00


raja
Published on 17-Jun-2019 10:56:24
Advertisements