Advertisements
Advertisements
Question
A 16 bit number beginning with lower order byte is stored from memory location 7000H. Write an assembly language program to find its two’s (2’s) compliment and stare the result beginning with lower order byte from memory location 7500H.
Code Writing
Advertisements
Solution
; 8085 Program to find 2's complement of a 16-bit number ; Input: 16-bit number at 7000H ; Output: 2's complement at 7500H and 7501H
Label Instructions Comments
LHLD 7000H ; Load HL to 7000H
MOV A,L ; Move L to Acc
CMA ; Complement Acc.
ADI 014 ; Add 1 to Acc.
STA 7500H ; Store A to 7500 H
MOV A, H ; Move H to A
CMA ; Complement Acc.
ACT 00H ; Add 00H with carry
STA >501H ; Store A to 7501H
HLT ; Stopshaalaa.com
Is there an error in this question or solution?
