English

Write an assembly language program to get Binary Coded Decimal (BCD) sum of series of 1-byte numbers stored at locations beginning 2600 H. Length of series is at 25FF H. Store the 1-byte result - Computer Science 2

Advertisements
Advertisements

Question

Write an assembly language program to get Binary Coded Decimal (BCD) sum of series of 1-byte numbers stored at locations beginning 2600 H. Length of series is at 25FF H. Store the 1-byte result in 2700 H.

Short Answer

Solution

Label Mnemonics code Comments
  LXI H, 25FF H ; Load addr of block
  ; Length in HL pair
; Memory value in M
MOV B, M ; Copy block length in B
SUB A ; Clear (A) to 00H
Back: INX H ; Go to next memory
  ADD M ; Add data into A
DA A ; Convert into BCD
DCR B ; decrease B by 1
JNZ Back ; check z flag if z = 0
  ; then jump back to
; loop, i.e. B ≠ 0
STA 2700H ; Store final 1-byte
  ; Sum from A into memory
HLT ; Halt the process
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×