Saturday, August 27, 2011

WAP in 8051 to add block of data stored in internal/external memory location


; FOR INTERNAL MEMORY
MOV R0, #30H ; STORE INTERNAL MEMORY ADDRESS IN RO
MOV A, #00H ; CLEAR ACCUMULATOR
MOV R7, #07H ; COUNTER REGISTER
BACK : ADD A,@R0 ;
INC R0 ; NEXT VALUE
DJNZ R7, BACK ;
END




; FOR EXTERNAL MEMORY
MOV DPTR, #0200H; STORE EXTERNAL MEMORY ADDRESS IN R0
MOV A, #00H ; CLEAR ACCUMULATOR
MOV R7, #00H ; SUM REGISTER
MOV R6, #07 ; COUNTER REGISTER
BACK : MOVX A, @DPTR ;
ADD A, R7 ;
MOV R7, A ;
INC DPTR ;
DJNZ R6, BACK ;
END

No comments:

Post a Comment