8051 Multi Byte Addition
by
eees.in
·
Published
· Updated
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:
ADDRESS | OPCODES | MNEMONICS | COMMENDS |
8500 | C3 | CLR C | |
8501 | 7C 03 | MOV R4,#03 | |
8503 | 90 86 00 | MOV DPTR,#8600 | |
8506 | A8 82 | MOV R0,DPL | |
8508 | A9 83 | MOV R1,DPH | |
850A | 90 8610 | MOV DPTR,#8610 | |
850D | AA 82 | MOV R2,DPL | |
850F | AB 83 | MOV R3,DPH | |
8511 | 90 87 00 | MOV DPTR,#8700 | |
8514 | C0 82 | LOOP: PUSH DPL | |
8516 | C0 83 | PUSH DPH | |
8518 | 88 82 | MOV DPL,R0 | |
851A | 89 83 | MOV DPH,R1 | |
851C | E0 | MOVX A,@DPTR | |
851D | F5 F0 | MOV F0,A | |
851F | A3 | INC DPTR | |
8520 | A8 82 | MOV R0,DPL | |
8522 | A9 83 | MOV R1,DPH | |
8524 | 8A 82 | MOV DPL,R2 | |
8526 | 8B 83 | MOV DPH,R3 | |
8528 | E0 | MOVX A,@DPTR | |
8529 | 35 F0 | ADDC A,B | |
852B | A3 | INC DPTR | |
852C | AA 82 | MOV R2,DPL | |
852E | AB 83 | MOV R3,DPH | |
8530 | D0 83 | POP DPH | |
8532 | D0 82 | POP DPL | |
8534 | F0 | MOVX @DPTR,A | |
8535 | A3 | INC DPTR | |
8536 | DC DC | DJNZ R4,LOOP | |
8538 | 80 FE | HERE: SJMP HERE | |
Recent Comments