Monday, August 8, 2011

Assembly language program for sum of data in Array

; ADDING DATA IN ARRAY
; IN SIMPLE TERMS SUM OF ARRAY
; STORING ARRAY IN ROM
ORG 300H        ;
DB 1,4,5,6,7    ;
; ARRAY OF 5
ORG 0000H       ;
; INITIALIZE DATA POINTER
MOV DPTR, #0300H;
; FIRST COUNTER
MOV R7, #05H    ;
; RESETING A
MOV A, #00H     ;
; COUNTER REGISTER FOR ROM ACCESS
MOV R0, #00H    ;
; SUM VARIABLE
MOV R6,#00H     ; 
LOOP:
MOV A, R0       ;
MOVC A,@A+DPTR  ;
ADD A, R6       ;
MOV R6,A        ;
INC R0          ;
DJNZ R7, LOOP   ;
END

1 comment: