English

Write an Assembly Language Program to find out 2’s complements of five numbers which are stored in memory locations starting from 4100H and stored the result in memory location starting from 4200H. - Computer Science 2

Advertisements
Advertisements

Question

Write an Assembly Language Program to find out 2’s complements of five numbers which are stored in memory locations starting from 4100H and stored the result in memory location starting from 4200H.

Long Answer
Advertisements

Solution

Label Instructions Comments
  MVI B, 05 ; Store counts 05 H in Reg. B
  LXI H, 4100H ; Set HL pair to 4100Н
LXI D, 4200H ; Set DE pair to 4200H
CYCLE MOV A, M ; Get number from M to Acc
  CMA; ; Obtain 1st complement of Acc.
  ADI 01 H ; Add 01H to Acc to get 2’s complement
STAX D ; Store 2’s complement of Acc
INX H ; increment Reg. pair HL by one
INX D ; Increment Reg. pair DE by 1
DCR B ; Decrement Reg. B by 1
JNZ-cycle ; If B ≠ 0, go to CYCLE
HLT ; Stop
shaalaa.com
  Is there an error in this question or solution?
2024-2025 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×