22 Program on Addition of 10 BCD numbers in Series in 8086 Microprocessor

Code:

; Addition of 10 BCD numbers in Series
.MODEL SMALL
.STACK 100
.DATA
  ARRAY   DB 1,2,3,4,5,6,7,8,9,10
  SUM_LSB DB 0
  SUM_MSB DB 0
.CODE
    MOV AX , @DATA ; Intializing data segment
    MOV DS , AX

    MOV CX , 10 ; Initialize byte counter
    MOV SI , OFFSET ARRAY  ; INITIALIZE MEMORY POINTER
       
 UP:
    MOV AL , [SI]     ; Read byte from memory
    ADD SUM_LSB , AL  ; Add with sum
    DAA
    JNC NEXT
     INC SUM_MSB
 NEXT:
     INC SI           ; Increment memory pointer
     LOOP UP          ; Decrement byte counter
                      ; If byte counter==0 then exit 
                      ; else read next number
    MOV DL , SUM_MSB
    MOV AH , 2
    INT 21H

    MOV DL , SUM_LSB
    MOV AH , 2
    INT 21H

    MOV AH , 4CH
    INT 21H
END





Ouput:


Debugger:


Previous
Next Post »

1 Comments:

Click here for Comments
Unknown
admin
November 9, 2021 at 11:02 AM ×

I need n bit BCD NUMBERS ADDITION

Thank You Unknown For Comment.
Reply
avatar