8086 Programing
8086 Programing
EC 410
By,
Shruti Verma
97/EC/07
INDEX
S.No.
1.
Topic
Write a program to add two 32-bit BCD
Date
3.08.10
2.
24.08.10
3.
24.08.10
4.
31.08.10
5.
7.09.10
6.
7.
21.09.10
28.09.10
8.
19.10.10
9.
26.10.10
10.
2.11.10
Signature
EXPERIMENT NO. 1
AIM: Write a program to add two 32-bit BCD numbers the result
should be in BCD.
0103
0105
0106
0109
010C
010F
0112
0114
COMMENTS
B9
00
50
8E
D8
F8
MOV AX,5000H
MOV DS,AX
Copy contents of AX to DS
CLC
B9
04
00
BE
00
05
BF
00
07
BB
00
09
8A
04
12
05
88
07
MOV CX,04
Initialize Counter
MOV SI,0500H
MOV DI,0700H
MOV BX,0900H
MOV AL,[SI]
ADC AL,[DI]
L1
0118
46
INC SI
0119
47
INC DI
Increment contents of DI by 1
0116
MOV [BX],AL
43
INC BX
011B
E2
F5
80
D2
00
88
17
LOOP L1
F4
HLT
011D
0120
0122
ADC DL,00H
MOV [BX],DL
COMMENTS
Increment contents of BX by
1
Get back to L1 till CX not
zero
Add with carry data in DL
with immediate data
Copy contents of DL to
memory location pointed by
BX
End of program
DATA:
ADDRESS
0500
0501
0502
0503
0700
0701
0702
0703
DATA
28H
37H
34H
58H
31H
94H
30H
72H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
ADDRESS DATA
0700
59H
0701
CBH
0702
64H
0703
CAH
COMMENTS
Result of 28H+31H
Result of 37H+94H
Result of 34H+30H
Result of 58H+72H
EXPERIMENT NO. 2
AIM: Write a program to add ten 16-bit numbers.
APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.
PROGRAM:
Data 1024h,8754h,2437h,2A87h,49FBh,7349h,1943h,3BACh,7584h,3497h
ADDRESS
0500
B9
00
00
8E
D8
BB
00
00
B9
09
00
BE
00
01
8B
04
0503
0505
0506
0509
050C
050F
MOV AX,0000H
MOV DS,AX
Copy contents of AX to
DS
Copy immediate data to
MOV BX,00H
BL
MOV CX,09H
Initialize counter
MOV SI,0100H
MOV AX,[SI]
L2
0515
03
44
22
73
01
43
0518
46
L1
051A
46
0512
COMMENTS
ADD AX,[SI+2]
JNC L1
INC BX
Increment BX
INC SI
Increment SI
INC SI
Increment SI
051C
051D
051F
0520
E2
F6
A3
21
01
89
1E
23
01
F4
LOOP L2
MOV [121H],AX
MOV [123H],BX
HLT
DATA:
ADDRESS
0100H
0101H
0102H
0103H
0104H
0105H
0106H
0107H
0108H
0109H
010AH
010BH
010CH
010DH
010EH
010FH
0110H
0111H
0112H
0113H
DATA
24H
10H
54H
87H
37H
24H
87H
2AH
FBH
49H
49H
73H
43H
19H
ACH
3BH
84H
75H
97H
34H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
ADDRESS DATA COMMENTS
0121H
84H
0122H
A2H
0123H
02H
Carry
EXPERIMENT NO. 3
AIM: Write a program to find out whether a given byte is in the string
or not. If it is in the string then find out the address of the byte
0503
0506
050A
050F
0510
0513
0515
0518
B9
0A
00
BF
00
01
B0
38
F2
AE
4F
B8
00
00
03
CF
A3
21
01
F4
COMMENTS
MOV CX,0AH
Initialize counter
MOV DI,100H
MOV AL,93H
REPNE SCASB
DEC DI
MOV AX,0000H
ADD AX,DI
MOV [121H],AX
HLT
Data 42H,67H,84H,64H,93H,34H,28H,46H,55H,72H
DATA:
ADDRESS DATA
0100H
42H
0101H
ADDRESS
0102H
0103H
0104H
0105H
0106H
0107H
0108H
0109H
67H
DATA
84H
64H
93H
34H
28H
46H
55H
72H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
ADDRESS DATA
0121H
04H
0122H
01H
EXPERIMENT NO. 4
AIM: Write a program to convert a decimal number to a binary
number.
0503
0506
0508
050B
050E
0510
0512
0514
B9
09
00
B8
00
20
8E
D8
BE
00
01
B8
00
35
D1
E8
D1
DB
E2
FA
F4
L1
COMMENTS
MOV CX,08H
Initialize counter
MOV AX,2000H
MOV DS,AX
Copy contents of AX to DS
MOV SI,100H
MOV AX,35H
SHR AX,01H
RCR BX,01H
LOOP L1
HLT
DATA:
REGISTER DATA
AX
35H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
REGISTER DATA
BX
35H
EXPERIMENT NO. 5
AIM: Write a program to find number of even, odd, negative and
positive numbers in series of twenty 16-bit numbers.
0500
B9
00
10
8E
D8
BB
00
00
BA
00
00
B9
09
00
BE
00
01
8B
04
0503
0505
0508
050B
050E
0511
0513
0515
0517
0519
051B
D1
D8
73
02
EB
02
FE
C3
46
COMMENTS
MOV AX,1000H
MOV DS,AX
Copy contents of AX to
DS
Copy immediate data to
MOV BX,0000H
BX
MOV DX,0000H
L2
MOV CX,13H
Initialize counter
MOV SI,100H
MOV AX,[SI]
RCR AX,01H
JNC L1
Jump if no carry to L1
JMP L5
Jump to L5
L1
INC BL
Increment BL
L5
INC SI
Increment SI
ADDRESS
COMMENTS
051C
46
INC SI
Increment SI
051D
E2
F2
B9
13
00
BE
00
01
8B
04
LOOP L2
MOV CX,13H
MOV SI,100H
MOV AX,[SI]
051F
0522
0525
0527
L3
SI
052F
D1
D0
73
02
EB
02
FE
C2
46
0530
46
INC SI
Increment SI
0531
E2
F2
B0
14
2A
C2
8A
F0
B0
14
2A
C3
8A
F8
F4
LOOP L3
0529
052B
052D
0533
0535
0537
0539
053B
053D
053F
RCL AX,01H
JNC L4
Jump if no carry to L4
JMP L6
Jump to L6
L4
INC DL
Increment DL
L6
INC SI
Increment SI
MOV AL,14H
SUB AL,DL
MOV DH,AL
MOV AL,14H
SUB AL,BL
MOV BH,AL
HLT
DATA:
ADDRESS DATA
0100H
0101H
0102H
0103H
0104H
0105H
0106H
0107H
0108H
0109H
010AH
010BH
010CH
010DH
010EH
010FH
0110H
0111H
0112H
0113H
0114H
0115H
0116H
0117H
0118H
0119H
011AH
011BH
011CH
011DH
011EH
011FH
0120H
0121H
0122H
ADDRESS
0123H
0124H
0125H
24H
10H
54H
87H
37H
24H
87H
2AH
FBH
49H
49H
73H
43H
19H
ACH
3BH
84H
75H
97H
34H
98H
25H
AFH
57H
31H
62H
80H
17H
A9H
95H
91H
33H
92H
19H
05H
DATA
20H
05H
51H
0126H
0127H
67H
72H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
REGISTER CODE COMMENTS
BL
07 H Even numbers
BH
0D H Odd numbers
DL
12 H Positive numbers
DH
02 H Negative numbers
EXPERIMENT NO. 6
AIM: Write a program to find the factorial of a number.
APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.
PROGRAM:
ADDRES
S
0700
B9
00
50
8E
D8
BE
00
01
8B
04
B9
00
05
D1
D8
73
02
EB
02
0703
0705
0708
070A
070D
070F
0711
MOV AX,5000H
MOV DS,AX
Copy contents of AX to
DS
Address the data(source)
MOV SI,100H
MOV AX,01H
MOV CX,05H
L1
COMMENTS
MUL CX
LOOP L1
MOV [102H],DX
0713
FE
C3
MOV [100H],AX
0715
F4
HLT
DATA:
REGISTER DATA
CX
05H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
ADDRESS
DATA
0100H
78 H
0102H
00 H
EXPERIMENT NO. 7
AIM: Write a program to find the largest number from a given
unordered array.
0703
0706
0708
070B
070D
0711
0713
0716
0717
0718
071A
071D
B9
09
00
B8
00
50
8E
D8
BE
00
01
8B
04
3B
44
01
73
03
8B
44
02
46
46
E2
F4
A3
21
01
F4
L2
MOV CX,09H
Initialize counter
MOV AX,5000H
MOV DS,AX
Copy contents of AX to DS
MOV SI,0100H
MOV AX,[SI]
CMP AX,[SI+2]
JNC LI
MOV AX,[SI+2]
LI
COMMENTS
MOV
[0121H],AX
HLT
End of program
INC SI
INC SI
LOOP L2
Data 1024H,8754H,2437H,2A87H,49FBH,7349H,1943H,3BACH,7584H,3497H
DATA:
ADDRESS
0100H
0101H
0102H
0103H
0104H
0105H
0106H
0107H
0108H
0109H
010AH
010BH
010CH
010DH
010EH
010FH
0110H
0111H
0112H
0113H
DATA
24H
10H
54H
87H
37H
24H
87H
2AH
FBH
49H
49H
73H
43H
19H
ACH
3BH
84H
75H
97H
34H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
RESULT:
ADDRESS DATA
0121H
54H
0122H
87H
EXPERIMENT NO. 8
AIM: Write a program to multiply two 32-bit.
APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.
PROGRAM:
MNEMONICS
COMMENTS
1712
BE
00
03
BF
00
05
8B
04
MOV SI,0300H
MOV DI,0500H
MOV AX,[SI]
171A
F7
25
171C
89
45
04
8B
CA
8B
44
02
F7
25
MOV [DI+4],AX
8B
DA
03
C8
83
D3
00
MOV BX,DX
ADD CX,AX
ADC BX,00H
1715
1718
171F
1721
1724
1726
1728
172A
SI
MOV CX,DX
MOV AX,[SI+2]
MNEMONICS
COMMENTS
172D
8B
04
MOV AX,[SI]
172F
F7
65
02
03
C8
13
DA
89
45
06
B9
00
00
83
D1
00
8B
44
02
F7
65
02
03
C3
13
D1
89
45
08
89
55
0A
F4
1732
1734
1736
1739
173C
173F
1742
1745
1747
1749
174C
174F
ADD CX,AX
ADC BX,DX
MOV [DI+6],CX
MOV CX,00H
ADC CX,00H
MOV AX,[SI+2]
ADD AX,BX
ADC DX,CX
MOV [DI+8],AX
MOV [DI+0A],DX
HLT
DATA:
ADDRESS
0300H
DATA
28H
ADDRESS
0301H
0302H
0303H
0500H
0501H
0502H
0503H
DATA
37H
34H
58H
31H
94H
30H
72H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
ADDRESS
0504H
0505H
0506H
0507H
0508H
0509H
050AH
050BH
DATA
A8H
AEH
61H
39H
69H
FDH
57H
27H
EXPERIMENT NO. 9
AIM: Write a program to sort an unordered array of 10 elements in
ascending order.
0703
0706
0708
070B
070D
070F
0712
0714
0717
0719
071A
B9
09
00
B8
00
50
8E
D8
BE
00
01
8B
D1
8A
04
3A
44
01
72
05
86
44
01
88
04
46
E2
F1
COMMENTS
MOV CX,09H
Initialize counter
MOV AX,5000H
MOV DS,AX
Copy contents of AX to DS
MOV SI,100H
L3
MOV DX,CX
Move contents of DX to CX
L2
MOV AL,[SI]
CMP AL,[SI+1]
JC LI
LI
4A
75
E5
F4
DEC DX
JNZ L3
COMMENTS
Decrement DX
Jump if not zero to L3
HLT
Data 42H,67H,84H,64H,93H,34H,28H,46H,55H,72H
DATA:
ADDRESS
0100H
0101H
0102H
0103H
0104H
0105H
0106H
0107H
0108H
0109H
DATA
42H
67H
84H
64H
93H
34H
28H
46H
55H
72H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
ADDRESS
0100H
0101H
0102H
0103H
0104H
0105H
0106H
0107H
0108H
0109H
DATA
28H
34H
42H
46H
55H
64H
67H
72H
84H
93H
EXPERIMENT NO. 10
AIM: Write a program to find the parity of a multi-byte number.
APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.
PROGRAM:
ADDRESS
0500
B9
00
20
8E
D8
BE
00
05
B9
04
00
BA
00
00
32
04
0503
0505
050A
050D
050F
0511
0513
0515
46
E2
FB
7B
01
42
F4
L1
MOV AX,2000H
MOV DS,AX
MOV SI,500H
Copy contents of AX to
DS
Address the data(source)
MOV CX,04H
MOV DX,00H
XOR AL,[SI]
JNP L2
INC DX
HLT
Increment DX
End of the program.
INC SI
LOOP L1
L2
COMMENTS
DATA:
ADDRESS
500
502
CODE
0101H
0101H
PROCEDURE:
For MPU EMU-8086 EMULATOR:
1. First open 8086 EMULATOR software.
2. Open a new .com file by clicking new file in File menu.
3. Write the program in mnemonics.
4. Save the program and assign some name.
5. Click the emulate icon in toolbar.
6. A new window will open and click on RUN icon.
7. Check the results.
RESULT:
REGISTER CODE COMMENTS
DX
01 Even parity