Friday 9 December 2016

Program for the sum of all the numbers stored in RAM locations

the BCD numbers are stored in RAM locations from 40h

  that are 40 = 71
              41 = 11
              42 = 65
              43 = 59
             44 = 37
Now program for addition of these numbers

                      MOV R0, #40H ; load painter
                      MOV R2, #5      ; load counter
                      CLR A               ; a=0
                      MOV R7, A      ; clear r7
AGAIN:         ADD A, @R0   ; add byte painter by r0
                      DA  A               ; adjust for bcd
                      JNC NXT         ; if c=0 dont accumlate carry
                      INC R7             ;
NXT :            INC R0             ;
                     DJNZ R2, AGAIN ; repeat all untill r2 zero

No comments:

Post a Comment