0% found this document useful (0 votes)
4K views

Program 3 Multibyte Addition 8086

1) The document describes an assembly language program to add two multibyte numbers. 2) The program uses three registers - SI, DI and BP - to store the starting addresses of the two numbers and result. 3) It loads each byte, adds it to the corresponding byte of the other number along with any previous carry, and stores the sum. 4) It increments the byte pointer and result pointer after each addition, decrements the byte count, and stores the final carry.

Uploaded by

Sisay Deresa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4K views

Program 3 Multibyte Addition 8086

1) The document describes an assembly language program to add two multibyte numbers. 2) The program uses three registers - SI, DI and BP - to store the starting addresses of the two numbers and result. 3) It loads each byte, adds it to the corresponding byte of the other number along with any previous carry, and stores the sum. 4) It increments the byte pointer and result pointer after each addition, decrements the byte count, and stores the final carry.

Uploaded by

Sisay Deresa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Multibyte Addition

8086 Assembly Language Programs

S. Alwyn Rajiv,
Assistant Professor,
Department of ECE,
Kamaraj College of Engineering and Technology
Problem
Write an assembly language program to add two
numbers of multibyte data.
Problem Analysis
The multibyte data can be added either byte by byte or word by word. The number of
bytes in the data can be used for the number of additions. One of the registers is used to
account for the final carry.

To perform addition, we require three address pointers: Two pointers for input data and
one pointer for output data

KCET/SARLC/Program 3 2
Algorithm
1. Load the starting address of 1st data in SI register 10. Store the sum in memory

2. Load the starting address of 2nd data in DI register 11. Increment the byte pointer (BX) and result pointer (BP).

3. Load the starting address of result in BP register 12. Decrement the byte count (CL)

4. Load the byte count in CL register 13. If byte count (CL) is zero, go to the, otherwise go to step 8

5. Let BX register be byte pointer. Initialize byte pointer as


14. Check for Carry. If carry flag is set then go to next step,
zero
otherwise for to step 16.
6. Clear DL register to account for final carry
15. Increment DL register
7. Clear Carry flag
16. Store final carry in memory
8. Load a byte of 1st data in AL register
17. Stop
9. Add the corresponding byte of 2nd data in memory to AL
register along with previous carry.
KCET/SARLC/Program 3 3
Flow Chart
Start Store the Sum in Memory

Increment Byte Pointer


Load Address of 1st data in SI register
Increment Result Pointer
Load Address of 2nd data in DI register
Decrement Byte Count
Load Address of Result in BP register

Load the byte Count in CL register No


Is CL=0?
Clear BX register (Initialize Byte Pointer as Zero) Yes
No
Is CF=1?
Clear DL Register
Yes
Get a byte of 1st data in AL register Increment DL register

Store DL in Memory
Add Corresponding Byte of 2nd Data to AL Register

KCET/SARLC/Program 3
Stop 4
Program
REPEAT:
MOV SI,1000H
MOV AL,[SI+BX]
MOV DI,1011H ADC AL,[DI+BX]
MOV [BP],AL
MOV BP,1021H
INC BX

MOV CL,[SI] INC BP


LOOP REPEAT
INC SI JNC JUMP
INC DL
MOV BX,0000H
JUMP:
MOV DL,0000H MOV [BP],DL
HLT
CLC
KCET/SARLC/Program 3 5
Example

F5C2647217
C265750712
INPUT
Memory INPUT
Content
Address
1000 05
1B827D97929 Memory
Content
Address
1001 17 1011 12
1002 72 1012 07
1003 64 1013 75
1004 C2 1014 65
1005 F5 1015 C2
KCET/SARLC/Program 3 6
Example Initial
SI 1000 CL SI
DI 1011 SI 1001 INC
BP 1021
BX 0000
DL 0000

CF
INPUT
OUTPUT
Memory INPUT
Content Memory
Address Memory Content
Content Address
1000 05 Address
1021
1001 17 1011 12
1022
1002 72 1012 07
1003 64
1023 Sum
1013 75
1024
1004 C2 1014 65
1025
1005 F5 1015 C2
1026 Carry
KCET/SARLC/Program 3 7
Integration 1 CL 5 Memory
Example Address
SI 1001 + BX 0000 1001 AL 17
+
DI 1011 + BX 0000 1011 12

1021 BP AL 29
Memory
Address CF 0

INPUT OUTPUT
Memory INPUT BX 0001 INC
Content Memory
Address Content
Memory Address
Content BP 1022 INC
1000 05 Address 1021 29
1001 17 1011 12 1022
CL 4 DEC
1002 72 1012 07 1023
1003 64 1013 75 1024
1004 C2 1014 65 1025
1005 F5 1015 C2 1026

KCET/SARLC/Program 3 8
Integration 2 CL 4 Memory
Example Address
SI 1001 + BX 0001 1002 AL 72
+
DI 1011 + BX 0001 1012 07

1022 BP AL 79
Memory
Address CF 0

INPUT OUTPUT
Memory INPUT BX 0002 INC
Content Memory
Address Content
Memory Address
Content BP 1023 INC
1000 05 Address 1021 29
1001 17 1011 12 1022 79
CL 3 DEC
1002 72 1012 07 1023
1003 64 1013 75 1024
1004 C2 1014 65 1025
1005 F5 1015 C2 1026

KCET/SARLC/Program 3 9
Integration 3 CL 3 Memory
Example Address
SI 1001 + BX 0002 1003 AL 64
+
DI 1011 + BX 0002 1013 75

1023 BP AL D9
Memory
Address CF 0

INPUT OUTPUT
Memory INPUT BX 0003 INC
Content Memory
Address Content
Memory Address
Content BP 1024 INC
1000 05 Address 1021 29
1001 17 1011 12 1022 79
CL 2 DEC
1002 72 1012 07 1023 D9
1003 64 1013 75 1024
1004 C2 1014 65 1025
1005 F5 1015 C2 1026

KCET/SARLC/Program 3 10
Integration 4 CL 2 Memory
Example Address
SI 1001 + BX 0003 1004 AL C2
+
DI 1011 + BX 0003 1014 65

1024 BP AL 27
Memory
Address CF 1

INPUT OUTPUT
Memory INPUT BX 0004 INC
Content Memory
Address Content
Memory Address
Content BP 1025 INC
1000 05 Address 1021 29
1001 17 1011 12 1022 79
CL 1 DEC
1002 72 1012 07 1023 D9
1003 64 1013 75 1024 27
1004 C2 1014 65 1025
1005 F5 1015 C2 1026

KCET/SARLC/Program 3 11
Integration 5 CL 1 Memory CF 1
Example Address
SI 1001 + BX 0004 1005 AL F5
+
DI 1011 + BX 0004 1015 C2

1025 BP AL B8
Memory
Address CF 1

INPUT OUTPUT
Memory INPUT BX 0005 INC
Content Memory
Address Content
Memory Address
Content BP 1026 INC
1000 05 Address 1021 29
1001 17 1011 12 1022 79
CL 0 DEC
1002 72 1012 07 1023 D9
1003 64 1013 75 1024 27
1004 C2 1014 65 1025 B8
1005 F5 1015 C2 1026

KCET/SARLC/Program 3 12
Final
Example CF 1

DL 01 INC
F5C2647217
C265750712
DL 01 BP 1026
1B827D97929

INPUT OUTPUT
Memory INPUT Memory
Content Content
Address Address
Memory
Content
1000 05 Address 1021 29
1001 17 1011 12 1022 79
1002 72 1012 07 1023 D9 Sum
1003 64 1013 75 1024 27
1004 C2 1014 65 1025 B8
1005 F5 1015 C2 1026 01 Carry
KCET/SARLC/Program 3 13
Thank You…..

KCET/SARLC/Program 3 14

You might also like