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:
; 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
Debugger:
1 Comments:
Click here for CommentsI need n bit BCD NUMBERS ADDITION