You are on page 1of 29

Programming V

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

numbers the result should be in BCD.

2.

Write a program to add ten 16-bit


numbers.

24.08.10

3.

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.
Write a program to convert a decimal

24.08.10

4.

31.08.10

number to a binary number.

5.

Write a program to find number of even,

7.09.10

odd, negative and positive numbers in


series of twenty 16-bit numbers.

6.
7.

Write a program to find the factorial of a


number.
Write a program to find the largest

21.09.10
28.09.10

number from a given unordered array.

8.

Write a program to multiply two 32-bit.

19.10.10

9.

Write a program to sort an unordered

26.10.10

array of 10 elements in ascending


order.

10.

Write a program to find the parity of a


32-Bit number.

2.11.10

Signature

EXPERIMENT NO. 1
AIM: Write a program to add two 32-bit BCD numbers the result
should be in BCD.

APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.


PROGRAM:

ADDRESS CODE LABEL MNEMONICS


0100

0103
0105
0106

0109

010C

010F

0112
0114

COMMENTS

B9
00
50
8E
D8
F8

MOV AX,5000H

Copy immediate data to AX

MOV DS,AX

Copy contents of AX to DS

CLC

Clear carry flag

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

Address the data(source)

MOV DI,0700H

Address the data(source)

MOV BX,0900H

Address the data(result)

MOV AL,[SI]

Get data in AL pointed by SI

ADC AL,[DI]

L1

0118

46

INC SI

Add with carry data in AL and


pointed by DI
Copy contents of AL to
memory location pointed by
BX
Increment contents of SI by 1

0119

47

INC DI

Increment contents of DI by 1

0116

MOV [BX],AL

ADDRESS CODE LABEL MNEMONICS


011A

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

CODE LABEL MNEMONICS

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

Copy base address to AX

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

Address the data(source)

MOV AX,[SI]

Get data in AX pointed by


SI

L2

0515

03
44
22
73
01
43

0518

46

L1

051A

46

0512

COMMENTS

ADD AX,[SI+2]

JNC L1

Add the contents of


memory location pointed
by SI with AX
Jump if no carry to 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

Get back to L2 till CX not


zero
Copy contents of AX to
memory
Copy contents of BX to
memory

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

Lower byte of result

0122H

A2H

Upper byte of result

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

APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.


PROGRAM:

ADDRESS CODE LABEL MNEMONICS


0500

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

Address the data(source)

MOV AL,93H

Move immediate data to AL.

REPNE SCASB

Scan the 0A0 bytes till a


match to the byte is found
Decrement DI
Move the immediate data
with AX.

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

Move the contents of DI to


AX.
Move the contents of AX to
memory.
End of the program

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.

APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.


PROGRAM:

ADDRESS CODE LABEL MNEMONICS


0500

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

Copy base address to AX

MOV DS,AX

Copy contents of AX to DS

MOV SI,100H

Address the data(source)

MOV AX,35H

Get immediate data in AX

SHR AX,01H

Shift logical right

RCR BX,01H

Rotate right through carry

LOOP L1

Get back to L1 till CX not


zero
End of program

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.

APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.


PROGRAM:
ADDRESS

CODE LABEL MNEMONICS

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

Copy base address to AX

MOV DS,AX

Copy contents of AX to
DS
Copy immediate data to

MOV BX,0000H

BX
MOV DX,0000H

Copy immediate data to


DX

L2

MOV CX,13H

Initialize counter

MOV SI,100H

Address the data(source)

MOV AX,[SI]

Get data in AX pointed by


SI

RCR AX,01H

Rotate right through carry

JNC L1

Jump if no carry to L1

JMP L5

Jump to L5

L1

INC BL

Increment BL

L5

INC SI

Increment SI

ADDRESS

CODE LABEL MNEMONICS

COMMENTS

051C

46

INC SI

Increment SI

051D

E2
F2
B9
13
00
BE
00
01
8B
04

LOOP L2
MOV CX,13H

Get back to L2 till CX not


zero
Initialize counter

MOV SI,100H

Address the data(source)

MOV AX,[SI]

Get data in AX pointed by

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

Get back to L3 till CX not


zero
Move immediate data to
AL
Subtract DL from AL

0529
052B
052D

0533
0535
0537
0539
053B
053D
053F

RCL AX,01H

Rotate left through carry

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

Move the contents of AL


to DH
Move immediate data to
AL
Subtract BL from AL
Move the contents of AL
to BH.
End of the program.

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

CODE LABEL MNEMONICS

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

Copy base address to AX

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

Move immediate data in


AX
Move the number whose
factorial is to be taken in
CX
Multiply the contents of
CX with AX
Get back to L1 till CX not
zero
Move the contents of DX
to the memory location
102H
Move the contents of DX
to the memory location
100H
End of the program.

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.

APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.


PROGRAM:
ADDRESS CODE LABEL MNEMONICS
0700

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

Copy base address to AX

MOV DS,AX

Copy contents of AX to DS

MOV SI,0100H

Address the data(source)

MOV AX,[SI]

Get data in AX pointed by


SI
Compare the contents of
memory location pointed by
SI+2 with AX
Jump if no carry to LI

CMP AX,[SI+2]

JNC LI
MOV AX,[SI+2]

LI

COMMENTS

MOV
[0121H],AX

Move the contents of AX to


the memory location
pointed by SI+2
Increment SI
Increment SI
Get back to L2 till CX not
zero
Move the contents of AX to
memory address

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.

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
54H
0122H
87H

EXPERIMENT NO. 8
AIM: Write a program to multiply two 32-bit.
APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.
PROGRAM:

ADDRESS CODE LABEL

MNEMONICS

COMMENTS

1712

BE
00
03
BF
00
05
8B
04

MOV SI,0300H

Address the data(source)

MOV DI,0500H

Address the data(source)

MOV AX,[SI]

Get data in AX pointed by

171A

F7
25

MUL WORD PTR[DI]

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

Copy the contents of


memory location pointed by
[SI+2] to AX
Multiplies 16-bit content of
memory location pointed by
DI with AX
Copy contents of DX to BX

ADD CX,AX

Add AX with CX.

ADC BX,00H

Add with carry data in BX


with immediate data

1715

1718

171F
1721

1724

1726
1728
172A

SI

MOV CX,DX
MOV AX,[SI+2]

MUL WORD PTR[DI]

Multiplies 16-bit content of


memory location pointed by
DI with AX
Copy the contents of AX to
the memory location pointed
by [DI+4]
Copy contents of DX to CX

ADDRESS CODE LABEL

MNEMONICS

COMMENTS

172D

8B
04

MOV AX,[SI]

Get data in AX pointed by


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

MUL WORD PTR[DI+2]

Multiplies 16-bit content of


memory location pointed by
DI+2 with AX
Add AX with CX

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

Add with carry data in BX


with DX
Copy the contents of CX to
the memory location pointed
by [DI+6]
Move immediate data to
CX.

ADC CX,00H

Add with carry data in CX


with immediate data

MOV AX,[SI+2]

Get data in AX pointed by


SI+2

MUL WORD PTR[DI+2]

Multiplies 16-bit content of


memory location pointed by
DI+2 with AX
Add AX with BX

ADD AX,BX
ADC DX,CX
MOV [DI+8],AX

MOV [DI+0A],DX

HLT

DATA:
ADDRESS
0300H

DATA
28H

Add with carry data in CX


with DX
Copy the contents of AX to
the memory location pointed
by [DI+6]
Copy the contents of DX to
the memory location pointed
by [DI+6]
End of program

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.

APPARATUS: Intel 8086 Microprocessor kit and 8086 emulator.


PROGRAM:

ADDRESS CODE LABEL MNEMONICS


0700

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

Copy base address to AX

MOV DS,AX

Copy contents of AX to DS

MOV SI,100H

Address the data(source)

L3

MOV DX,CX

Move contents of DX to CX

L2

MOV AL,[SI]

Get data in AL pointed by SI

CMP AL,[SI+1]

Compare the contents of


memory location pointed by
SI+1 with AL
Jump if carry to LI

JC LI

LI

XCHG AL,[SI+1] Exchange the contents of


AL with the memory
location pointed by SI+1
MOV [SI],AL
Move the contents of AL to
memory location pointed by
SI
INC SI
Increment SI
LOOP L2
Get back to L2 till CX not
zero

ADDRESS CODE LABEL MNEMONICS


071C
071D
072F

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

CODE LABEL MNEMONICS

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

Copy base address to AX

MOV DS,AX
MOV SI,500H

Copy contents of AX to
DS
Address the data(source)

MOV CX,04H

Move the count to CX

MOV DX,00H

Move immediate data to


DX

XOR AL,[SI]

JNP L2

XOR the contents of AL


register with the contents
of memory location
pointed by SI
Increment SI
Get back to L1 till CX not
zero
Jump if no parity to 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

You might also like