8051 Multi Byte Addition

Multi Byte Addition

THEORY:

  • The multi-byte addition program adds only in sets of 8-bits.
  • The LSD of the two numbers is added first. Now, the next set of 8-bits is added,
  • Taking into consideration the status of carry due to the previous addition.
  • Addition is done till the length of the number specified becomes zero.

INPUT:

  • 8600      02H       
  • 8601      03H       (FIRST INPUT)
  • 8602      04H
  • 8610      02H       
  • 8611      03H       (SECOND INPUT)
  • 8612      04H

OUTPUT:

  • 8700      04H       
  • 8701      06H      
  • 8702      08H

PROGRAM:

ADDRESSOPCODESMNEMONICSCOMMENDS
8500C3             CLR C 
85017C 03             MOV R4,#03 
850390 86 00             MOV DPTR,#8600 
8506A8 82             MOV R0,DPL 
8508A9 83             MOV R1,DPH 
850A90 8610             MOV DPTR,#8610 
850DAA 82             MOV R2,DPL 
850FAB 83             MOV R3,DPH 
851190 87 00             MOV DPTR,#8700 
8514C0 82LOOP:       PUSH DPL 
8516C0 83PUSH DPH 
851888 82MOV DPL,R0 
851A89 83MOV DPH,R1 
851CE0MOVX A,@DPTR 
851DF5 F0MOV F0,A 
851FA3INC DPTR 
8520A8 82MOV R0,DPL 
8522A9 83MOV R1,DPH 
85248A 82MOV DPL,R2 
85268B 83MOV DPH,R3 
8528E0MOVX A,@DPTR 
852935 F0ADDC A,B 
852BA3INC DPTR 
852CAA 82MOV R2,DPL 
852EAB 83MOV R3,DPH 
8530D0 83POP DPH 
8532D0 82POP DPL 
8534F0MOVX @DPTR,A 
8535A3INC DPTR 
8536DC DCDJNZ R4,LOOP 
853880 FEHERE:      SJMP HERE 

You may also like...

error: Content is protected !!