You are on page 1of 160

1

1.1 BASIC ARITHMETIC OPERATIONS

AIM:

To write an Assembly Language Program (ALP) for 16 bit Arithmetic operations using 8086.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

ALGORITHM:

(i)16-bit addition:

a) Start the program.

b) Load the augend to the accumulator.

c) Load the addend to any other general purpose register.

d) Add these two register contents.

e) Store the result in required memory location.

f) Stop the program.

(ii) 16-bit subtraction:

a) Start the program.


b) Load the minuend to the accumulator.
c) Load the subtrahend to any other general purpose register.
d) Subtract these two register contents.
e) Store the result in required memory locations.
f) Stop the program.

2
3
(iii)Multiplication of 16-bit numbers:

a) Start the program.


b) Load the multiplicand to the accumulator.
c) Load the multiplier to any other general purpose register.
d) Add the multiplicand, multiplier times.
e) Store the result in required memory location.
f) Stop the program.

(iv)Division of 16-bit numbers:

a) Start the program.


b) Load the dividend to the accumulator.
c) Load the divisor to any other general purpose register.
d) Subtract the dividend, divisor times.
e) Store the result in required memory location.
f) Stop the program.

(v)Double precision Addition:

a) Start the program.


b) Load the 16 bit augend to the accumulator.
c) Load the 16 bit addend to any other general purpose register.
d) Add these two register contents with carry.
e) Store the result in required memory location.
f) Stop the program

(vi)Double precision subtraction:

a) Start the program.


b) Load the 16 bit minuend to the accumulator.
c) Load the 16 bit subtrahend to any other general purpose register.
d) Subtract these two register contents with borrow.
e) Store the result in required memory locations.
f) Stop the program.

4
TABULATION:

ADDITION OF TWO 16-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102

1103

SUBTRACTION OF TWO 16-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102

1103

5
PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)

A-ADDITION OF TWO 16-BIT NUMBERS

COMMANDS
ADDRESS MNEMONICS OP-CODE

1000 MOV AX,[1100] A1,00,11 MOVE THE DATA


TO
ACCUMULATOR
ADD MEMORY
CONTENT
1003 ADD AX,[1102] 03,06,02,11 WITH
ACCUMULATOR

MOVE
ACCUMULATOR
1007 MOV [1200],AX A3,00,12 CONTENT TO
MEMORY

100A HLT F4 STOP

B-SUBTRACTION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS


MOVE THE DATA
TO
1000 MOV AX[1100] A1,00,11
ACCUMULATOR

SUBTRACT
1003 SUB AX[1102] 2B,06,02,11 MEMORY CONTENT
WITH
ACCUMULATOR

MOVE
1007 MOV [1200],AX A3,00,12 ACCUMULATOR
CONTENT TO
MEMORY

100A HLT F4 STOP

6
TABULATION

MULTIPLICATION OF TWO 16-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102 1202

1103 1203

7
C-MULTIPLICATION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS


MOVE THE DATA
TO
1000 MOV AX[1100] A1,00,11
ACCUMULATOR
MULTIPLY
MEMORY
1003 MUL[1102] F7,26,02,11 CONTENT
WITH
ACCUMULATOR

MOVE
1007 MOV [1200],DX 87,16,00,12 ACCUMULATOR
CONTENT TO AX
REGISTER

100B MOV[1202],AX A3,02,12 MOVE


ACCUMULATOR
CONTENT TO DX
REGISTER

100E HLT F4
STOP

8
TABULATION

DIVISION OF TWO 16-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102 1202

1103 1203

9
D-DIVISION OF TWO 16-BIT NUMBERS
ADDRESS MNEMONICS OP-CODE COMMANDS
1000 MOV AX[1100] A1,00,11 MOVE THE DATA
TO
ACCUMULATOR
1003 DIV[1102]
F7,36,02,11 DIVIDE MEMORY
CONTENT
WITH
ACCUMULATOR
1007 MOV [1200],DX 87,16,00,12 MOVE
ACCUMULATOR
CONTENT TO DX
REGISTER

100B
MOV[1202],AX A3,02,12 MOVE CONTENT
OF AX
REGISTER TO
MEMORY
100E HLT F4 STOP

10
TABULATION

DOUBLE PRECISION ADDITION

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1200

1101 1201

1102 1202

1103 1203

1104 1204

1105

1106

1107

11
E-DOUBLE PRECISION ADDITION
ADDRESS MNEMONICS OP-CODE COMMANDS
MOVE THE DATA
TO
ACCUMULATOR
1000 MOV AX,[1100] A1,00,11
ADD MEMORY
CONTENT WITH
ACCUMULATOR
1003 ADD AX,[1104] 03,06,04,11

MOVE DATA IN
MEMORY
1007 MOV [1200],AX A3,00,12 TO ACCUMULATOR
MOVE
ACCUMULATOR
VALUE TO
MEMORY
100A MOV AX,[1102] A1,02,11
ADD
ACCUMULATOR
VALUE WITH
100D ADC AX,[1106] 13,06,06,11 CARRY
MOVE
ACCUMULATOR
VALUE TO
1011 MOV[1202],AH A3,02,12 MEMORY
MOVE HIGHER
VALUE TO
1014 LAHF 9F MEMORY
MOVE
ACCUMULATOR
VALUE TO
1015 MOV[1204],AH 88,26,04,12 MEMORY

1019 HLT F4 STOP

12
TABULATION

DOUBLE PRECISION SUBTRACTION

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1200

1101 1201

1102 1202

1103 1203

1104

1105

1106

1107

13
F-DOUBLE PRECISION SUBTRACTION

ADDRESS MNEMONICS OP-CODE COMMANDS


1000 MOV AX,[1100] A1,00,11
MOVE THE DATA TO
ACCUMULATOR

SUBTRACT MEMORY
CONTENT WITH
ACCUMULATOR
1003 SUB AX,[1104] 2B,06,04,11

1007 MOV [1200],AX A3,00,12 MOVE DATA IN


MEMORY TO
ACCUMULATOR
100A MOV AX,[1102] A1,02,11 MOVE
ACCUMULATOR
VALUE TO MEMORY
100D SBB AX,[1106] 2B,06,06,11 SUBTRACT MEMORY
CONTENT WITH
ACCUMULATOR
1011 MOV[1202],AX A3,02,12 MOVE ACCUMULATOR
VALUE TO MEMORY
1014 HLT F4 STOP

RESULT:
Thus an Assembly Language Program (ALP) for 16 bit Arithmetic operations using
8086 has been written and executed successfully.

14
15
1.2 ARITHMETIC OPERATIONS USING MASM SOFTWARE

AIM:
To perform arithmetic operations such as addition, subtraction, multiplication division
operations using MASM software.

APPARATUS:
SL.NO ITEM

1. PC

2. Keyboard

3 MASM SOFTWARE

ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the CRT.

PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
0PR1 EQU 98H
0PR2 EQU 49H
SUM DW 01 DUP(00)
SUBT DW 01 DUP(00)
PROD DW 01 DUP(00)
DWS DW 01 DUP(00)
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV BL,0PR2
XOR AL,AL
MOV AL,0PR1
ADD AL,BL

16
17
DAA
MOV BYTE PTR SUM,AL
JNC MSB0
INC [SUM+1]
MSB0:XOR AL,AL
MOV AL,0PR1
SUB AL,BL
DAS
MOV BYTE PTR SUBT,AL
JNB MSB1
INC [SUBT+1]
MSB1:XOR AL,AL
MOV AL,0PR1
MUL BL
MOV WORD PTR PROD,AX
XOR AH,AH
MOV AL,0PR1
DIV BL
MOV WORD PTR DWS,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START

RESULT:

Thus an arithmetic operations such as addition, subtraction, multiplication


division operations using MASM software has been written and executed successfully.

18
19
1.3 BASIC LOGICAL OPERATIONS

AIM:

To write an Assembly Language Program (ALP) for 16 bit logical operations using 8086

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

ALGORITHM:

(i) ONE’S COMPLEMENT OF A 16 BIT NUMBERS:


a) Start the program.
b) Load the input data to the Accumulator.
c) Perform negation on Accumulator.
d) Store the result in required memory location.
e) Stop the program.

(ii) MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER:


a) Start the program.
b) Load the first input data to the Accumulator.
c) Perform AND operation with AX and second data
d) Store the result in required memory location.
e) Stop the program.
f)
(iii) SETTING OF BITS SELECTIVELY:
a) Start the program.
b) Load the first input data to the Accumulator.
c) Perform OR operation with AX and second data
d) Store the result in required memory location.
e) Stop the program.

20
TABULATION

A-ONE’S COMPLEMENT OF A 16-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1001 1400

1002 1401

B-MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1200 1400

1201 1401

1004

1005

21
PROGRAMS FOR 16 BIT LOGICAL OPERATIONS (USING 8086)
A-ONE’S COMPLEMENT OF A 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS


1000 MOV AX 1234 B8,34,12 MOVE THE DATA
TO
ACCUMULATOR
1003 NOT AX F7,D0 NOT OPERATION
WITH
ACCUMULATOR

1007 MOV [1400],AX A3,00,14 MOVE DATA IN


MEMORY
TO
ACCUMULATOR
1009 HLT F4 STOP

B-MASKING OFF BITS SELECTIVELY IN 16-BIT NUMBER

ADDRESS MNEMONICS OP-CODE COMMANDS


1000 MOV AX, [1200] A1,00,12 MOVE THE DATA
TO
ACCUMULATOR
1003 AND AX, 0F0F 25,0F,0F AND OPERATION
WITH
ACCUMULATOR

1007 MOV [1400],AX A3,00,14 MOVE DATA IN


MEMORY
TO
ACCUMULATOR
1009 HLT F4 STOP

22
TABULATION

C- SETTING OFF BITS SELECTIVELY IN 16-BIT NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1001

1002

1004

1005

23
C- SETTING OFF BITS SELECTIVELY IN 16-BIT NUMBER
ADDRESS MNEMONICS OP-CODE COMMANDS
1000 MOV AX ,0000 B8,00,00 CLEAR
ACCUMULATOR

1003 OR AX, 0F0F 0D,0F,0F OR OPERATION


WITH
ACCUMULATOR

1007 MOV [1400],AX A3,00,14 MOVE DATA IN


MEMORY
TO
ACCUMULATOR
1009 HLT F4 STOP

RESULT:

Thus an Assembly Language Program (ALP) for 16 bit logical operations using 8086 has been
written and executed successfully.

24
25
2. MOVE A DATA BLOCK WITHOUT OVERLAP

AIM:
To convert a given Move a data block without overlap
.
ALGORITHM:
1. Initialize the memory location to the data pointer.
2. Increment B register.
3. Increment accumulator by 1 and adjust it to decimal every time.
4. Compare the given decimal number with accumulator value.
5. When both matches, the equivalent hexadecimal value is in B register.
6. Store the resultant in memory location.

PROGRAM:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ARRAY1 DW 1111H, 222H, 3333H,4444H,5555H
ARRAY2 DW 5 DUP (0)
COUNT DW 0005H
DATA ENDS
CODE SEGMENT
START: MOVAX, DATA
MOV DS, AX
LEA SI, ARRAY1
LEA DI, ARRAY2
MOV CX, COUNT
NEXT: MOV AX, [SI]
MOV [DI], AX
ADD SI, 02H
ADD DI, 02H
LOOP NEXT
MOV AH, 4CH
INT 21H
CODE ENDS
END START

RESULT:
The program to Move a data block without overlap has been written and executed
successfully.

26
TABULATION

BCD TO HEXADECIMAL:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1101

27
3. CODE CONVERSION, DECIMAL ARITHMETIC AND

MATRIX OPERATIONS

AIM:

To write an Assembly Language Program (ALP) for Code conversion, decimal arithmetic and
Matrix operations using 8086.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

PROGRAM:

BCD TO HEXADECIMAL:

ADDRESS LOOP MNEMONICS OPCODE

1000 MOV BX, 1100H C7,C3,00,11

1004 MOV AL, [BX] 8A,07

1006 MOV DL, AL 88,C2

1008 AND DL, 0FH 80,E2,0F

100B AND AL, F0H 80,E0,F0

100E MOV CL, 04H C6,C1,04

1011 ROR AL, CL D2,C8

1013 MOV DH, 0AH C6,C6,0A

1016 MUL DH F6,E6

1018 ADD AL, DL 00,D0

101A MOV [BX+1], AL 88,47,01

101D HLT F4

28
TABULATION

HEXADECIMAL TO BCD:

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1101

1102

29
HEXADECIMAL TO BCD:

ADDRESS LOOP MNEMONICS OPCODE

1000 MOV BX, 1100H C7,C3,00,11

1004 MOV AL, [BX] 8A,07

1006 MOV DX, 0000H C7,C2,00,00

100A HUND CMP AL, 64H 80,F8,64

100D JC TEN 72,08

100F SUB AL, 64H 80,E8,64

1012 INC DL FE,C2

1014 JMP HUND E9,F3,FF

1017 TEN CMP AL, 0AH 80,F8,0A

101A JC UNIT 72,08

101C SUB AL, 0AH 80,E8,0A

101F INC DH FE,C6

1021 JMP TEN E9,F3,FF

1024 UNIT MOV CL, 04H C6,C1,04

1027 ROL DH, CL D2,C6

1029 ADD AL, DH 00,F0

102B MOV [BX+1], AL 88,47,01

102E MOV [BX+2], DL 88,57,02

1031 HLT F4

30
ASCII TO HEXADECIMAL

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1100 1400

1101 1401

1102

31
ASCII TO HEXADECIMAL

ADDRESS LOOP MNEMONICS OPCODE

1000 MOV SI, 1100H C7,C6,00,11

1004 MOV DI, 1400H C7,C7,00,14

1008 CLD FC

1009 MOV BL, 20H C6,C3,20

100C NEXT: LODSB AC

100D CMP AL, BL 38,D8

100F JE EXIT 74,0F

1011 SUB AL, 30H 80,E8,30

1014 CMP AL, 0AH 80,F8,0A

1017 JC STORE 72,03

1019 SUB AL, 07H 80,E8,07

101C STORE: STOSB AA

101D JMP NEXT E9,EC,FF

1020 EXIT: HLT F4

32
HEXADECIMAL TO ASCII

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1400

1101 1401

33
HEXADECIMAL TO ASCII

ADDRESS LOOP MNEMONICS OPCODE

1000 MOV SI, 1100H C7,C6,00,11

1004 MOV DI, 1400H C7,C7,00,14

1008 CLD FC

1009 MOV BL, 20H C6,C3,20

100C NEXT: LODSB AC

100D CMP AL, BL 38,D8

100F JE EXIT 74,2A

1011 MOV BH, AL 88,C7

1013 AND AL, 0FH 80,E0,0F

1016 CMP AL, 0AH 80,F8,0A

1019 JL SKIP1 7C,03

101B ADD AL, 07H 80,C0,07

101E SKIP1: ADD AL, 30H 80,C0,30

1021 STOSB AA

1022 MOV AL, BH 88,F8

1024 AND AL, 0F0 H 80,E0,F0

1027 MOV CL, 04H C6,C1,04

102A ROR AL, CL D2,C8

102C CMP AL, 0AH 80,F8,0A

102F JL SKIP2 7C,03

1031 ADD AL, 07H 80,C0,07

1034 SKIP2: ADD AL, 30H 80,C0,30

1037 STOSB AA

1038 JMP NEXT E9,D1,FF

103B EXIT: HLT F4

34
MATRIX OPERATIONS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

2000 3000

2001 3001

2002 3002

2003 3003

3000

3001

3002

3003

35
MATRIX OPERATIONS

ADDRESS LOOP MNEMONICS OPCODE

1000 MOV CL, 04H (COUNT) C6,C1,04

1003 MOV SI, 2000H C7,C6,00,20

1007 MOV DI, 3000H C7,C7,00,30

100B LOOP: MOV AL, [SI] 8A,04

100D MOV BL, [DI] 8A,1D

100F ADD AL, BL / SUB AL, BL 28,D8

1011 MOV [DI], AL 88,05

1013 INC DI 47

1014 INC SI 46

1015 DEC CL FE,C9

1017 JNZ LOOP 75,F2

1019 HLT F4

36
BCD ADDITION

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1104

1101 1105

1102 1106

1103

37
BCD ADDITION

ADDRESS LOOP MNEMONICS OPCODE

1000 MOV SI, 1100 C7,C6,00,11

1004 MOV CL, 00 C6,C1,00

1007 MOV AX, [SI] 8B,04

1009 MOV BX, [SI+2] 8B,5C,02

100C ADD AL, BL 00,D8

100E DAA 27

100F MOV DL, AL 88,C2

1011 MOV AL, AH 88,E0

1013 ADC AL, BH 10,F8

1015 DAA 27

1016 MOV DH, AL 88,C6

1018 JNC AHEAD 73,02

101A INC CL FE,C1

101C AHEAD MOV [SI+4], DX 89,54,04

101F MOV [SI+6], CL 88,4C,06

1022 HLT F4

38
BCD SUBTRACTION

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1100 1104

1101 1105

1102 1106

1103

39
BCD SUBTRACTION

ADDRESS LABEL MNEMONICS OPCODE

1000 MOV SI, 1100 C7,C6,00,11

1004 MOV CL, 00 C6,C1,00

1007 MOV AX, [SI] 8B,04

1009 MOV BX, [SI+2] 8B,5C,02

100C SUB AL, BL 28,D8

100E DAS 2F

100F MOV DL, AL 88,C2

1011 MOV AL, AH 88,E0

1013 SBB AL, BH 18,F8

1015 DAS 2F

1016 MOV DH, AL 88,C6

1018 JNC AHEAD 73,02

101A INC CL FE,C1

101C AHEAD MOV [SI+4], DX 89,54,04

101F MOV [SI+6], CL 88,4C,06

1022 HLT F4

RESULT:

Thus an Assembly Language Program (ALP) for Code conversion, decimal


arithmetic and Matrix operations using 8086 has been written and executed successfully.

40
41
4.1 SORTING AND SEARCHING

AIM:

To write an Assembly Language Program (ALP) for sorting and searching operations using
8086.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

ALGORITHM:

(i) DESCENDING ORDER OF AN ARRAY:


a) Start the program.
b) Store the total number of elements in c register.
c) Store the data in accumulator.
d) Compare the first element with the second element, which is placed after two
bytes.
e) If second elements are lesser, continue comparison with next data else exchange
both the elements.
f) Decrement the count value.
g) Continue until count value becomes zero.
h) Store the contents in memory location.
i) Stop the program.

(ii) ASCENDING ORDER OF AN ARRAY:


a) Start the program.
b) Get the numbers to be stored from the memory locations.
c) Compare the first two numbers and if the first number is larger than second then
interchange the number.
d) If the first number is smaller, go to step d.
e) Repeat steps b and c until the numbers are in required order.
f) Stop the program.

(iii) LARGEST NUMBER IN AN ARRAY:


a) Start the program.

42
43
b) Place all the elements of an array in the consecutive memory locations.
c) Fetch the first element from the memory location and load it in the accumulator.
d) Initialize a counter (register) with the total number of elements in an array.
e) Decrement the counter by 1.
f) Increment the memory pointer to point to the next element.
g) Compare the accumulator content with the memory content (next element).
h) If the accumulator content is larger, then move the memory content (largest
element) to the accumulator. Else continue.
i) Decrement the counter by 1.
j) Repeat steps e to h until the counter reaches zero.
k) Store the result (accumulator content) in the specified memory location.
l) Stop the program.

(iv) SMALLEST NUMBER IN AN ARRAY:


a) Start the program.
b) Place all the elements of an array in the consecutive memory locations.
c) Fetch the first element from the memory location and load it in the accumulator.
d) Initialize a counter (register) with the total number of elements in an array.
e) Decrement the counter by 1.
f) Increment the memory pointer to point to the next element.
g) Compare the accumulator content with the memory content (next element).
h) If the accumulator content is smaller, then move the memory content (largest
element) to the accumulator. Else continue.
i) Decrement the counter by 1.
j) Repeat steps e to h until the counter reaches zero.
k) Store the result (accumulator content) in the specified memory location.
l) Stop the program.

(v) SEARCH A NUMBER IN AN ARRAY:


a) Start the program.
b) Load the input address in the source index.
c) Load the output address in the destination index.
d) Store the count value.
e) Increment source index.
f) Load the source index to the accumulator.
g) Increment source index.
h) Compare the present value stored in the accumulator and next value stored in the
source index.
i) If zero, then end else repeat from step e to g.
j) Store the result in the specified memory location.
k) Stop the program.

44
TABULATION

ASCENDING ORDER OF AN ARRAY

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA
1200 1200

1201 1201

1202 1202

1203 1203

1204 1204

45
PROGRAM:

ASCENDING ORDER OF AN ARRAY

ADDRESS LABEL MNEMONICS OP- COMMAND


CODE
1000 START MOV BL,00 B3 00 COUNT THE VALUE OF ARRAY
1002 MOV SI,1200 BE 00 12 MOVE THE DATA TO SOURCE INDEX
1005 MOV CL,[SI] 8A 0C MOVE THE MEMORY CONTENT TO COUNT
REGISTER
1007 DEC CL FE C9 DECREMENT COUNT REGISTER
1009 INC SI 46 INCREMENT SOURCE INDEX
100A LOOP MOV AL,[SI] 8A 04 MOVE THE MEMORY CONTENT SOURCE
INDEX TO ACCUMULATOR
100C INC SI 46 INCREMENT SOUREC INDEX
100D CMP AL,[SI] 3A 04 COMPARE THE MEMORY CONTENT OF
SOURCE INDEX WITH ACCUMULATOR
100F JC LOOP L1 72 0A JUMP ON CARRY
1011 MOV DL,[SI] 8A 14 MOVE THE MEMORY CONTENT OF
SOURCE INDEX TO DATA REGISTER
1013 MOV [SI],AL 88 04 MOVE THE CONTENT OF ACCUMULATOR
TO ADDRESS OF SOURCE INDEX
1015 DEC SI 4E DECREMENT SOURCE INDEX
1016 MOV [SI],DL 88 14 MOVE THE CONTENT OF DATA REGISTER
TO ADDRESS OF SOURCE INDEX
1018 INC SI 46 INCREMENT SOURCE INDEX
1019 MOV BL,01 B3 01 MOVE THE DATA TO BASE REGISTER
101B L1 DEC CL FE C9 DECREMENT COUNT REGISTER
101D JNZ LOOP 75 EB JUMP ON NO ZERO
101F DEC BL FE CB DECREMENT BASE REGISTER
1021 JZ START 74 DD JUMP ON ZERO
1023 HLT F4 STOP

46
DESCENDING ORDER OF AN ARRAY

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

47
DESCENDING ORDER OF AN ARRAY

ADDRESS LABEL MNEMONICS OP- COMMAND


CODE
1000 START MOV BL,00 B3 00 COUNT THE VALUE OF ARRAY
1002 MOV SI,1200 BE 00 12 MOVE THE DATA TO SOURCE INDEX
1005 MOV CL,[SI] 8A 0C MOVE THE MEMORY CONTENT TO COUNT
REGISTER
1007 DEC CL FE C9 DECREMENT COUNT REGISTER
1009 INC SI 46 INCREMENT SOURCE INDEX
100A LOOP MOV AL,[SI] 8A 04 MOVE THE MEMORY CONTENT SOURCE
INDEX TO ACCUMULATOR
100C INC SI 46 INCREMENT SOUREC INDEX
100D CMP AL,[SI] 3A 04 COMPARE THE MEMORY CONTENT OF
SOURCE INDEX WITH ACCUMULATOR
100F JNC LOOP L1 73 0A JUMP ON NO CARRY
1011 MOV DL,[SI] 8A 14 MOVE THE MEMORY CONTENT OF SOURCE
INDEX TO DATA REGISTER
1013 MOV [SI],AL 88 04 MOVE THE CONTENT OF ACCUMULATOR
TO ADDRESS OF SOURCE INDEX
1015 DEC SI 4E DECREMENT SOURCE INDEX
1016 MOV [SI],DL 88 14 MOVE THE CONTENT OF DATA REGISTER
TO ADDRESS OF SOURCE INDEX
1018 INC SI 46 INCREMENT SOURCE INDEX
1019 MOV BL,01 B3 01 MOVE THE DATA TO BASE REGISTER
101B L1 DEC CL FE C9 DECREMENT COUNT REGISTER
101D JNZ LOOP 75 EB JUMP ON NO ZERO
101F DEC BL FE CB DECREMENT BASE REGISTER
1021 JZ START 74 DD JUMP ON ZERO
1023 HLT F4 STOP

48
LARGEST NUMBER IN AN ARRAY

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

SMALLEST NUMBER IN AN ARRAY

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

49
LARGEST NUMBER IN AN ARRAY

ADDRESS LABEL MNEMONICS OP- COMMANDS


CODE
1000 MOV BX,0005 BB 05 00 COUNT THE VALUE OF ARRAY
1003 DEC BX 4B DECREMENT BX REGISTER
1004 L1 MOV CX,BX 8B CB MOVE THE CONTENT OF BX TO CX
REGISTER
1006 MOV SI,1100 BE 00 11 MOVE THE DATA TO SI
1009 L2 MOV AL,[SI] 8A 04 MOVE THE MEMORY CONTENT OF SI
TO AL
100B INC SI 46
100C CMP AL,[SI] 3A 04 COMPARE AL AND MEMORY
CONTENT OF SI
100E JNC L3 73 05 JUMP NO CARRY TO LOOP L3
1010 XCHG AL,[SI] 86 04 EXCHANGE AL WITH MEMORY
CONTENT OF SI
1012 MOV[SI-1],AL 88 44 FF MOVE THE CONTENT OF AL TO SI
1015 L3 LOOP L2 E2 F2 MOVE TO LOOP L2
1017 DEC BX 4B DECREMENT BX REGISTER
1018 JNZ L1 75 EA JUMP ON NO ZERO TO LOOP L1
101A MOV[1200],AL A2 00 12 MOVE THE CONTENT OF AL TO
OUTPUT MEMORY
101D HLT F4 STOP THE PROGRAM

SMALLEST NUMBER IN AN ARRAY

ADDRESS LABEL MNEMONICS OP- COMMANDS


CODE
1000 MOV BX,0005 BB 05 00 COUNT THE VALUE OF ARRAY
1003 DEC BX 4B DECREMENT BX REGISTER
1004 L1 MOV CX,BX 8B CB MOVE THE CONTENT OF BX TO CX
REGISTER
1006 MOV SI,1100 BE 00 11 MOVE THE DATA TO SI
1009 L2 MOV AL,[SI] 8A 04 MOVE THE MEMORY CONTENT OF SI
TO AL
100B INC SI 46
100C CMP AL,[SI] 3A 04 COMPARE AL AND MEMORY
CONTENT OF SI
100E JC L3 72 05 JUMP ON CARRY TO LOOP L3
1010 XCHG AL,[SI] 86 04 EXCHANGE AL WITH MEMORY
CONTENT OF SI
1012 MOV[SI-1],AL 88 44 FF MOVE THE CONTENT OF AL TO SI
1015 L3 LOOP L2 E2 F2 MOVE TO LOOP L2
1017 DEC BX 4B DECREMENT BX REGISTER
1018 JNZ L1 75 EA JUMP ON NO ZERO TO LOOP L1
101A MOV[1200],AL A2 00 12 MOVE THE CONTENT OF AL TO
OUTPUT MEMORY
101D HLT F4 STOP THE PROGRAM

50
SEARCH A NUMBER IN AN ARRAY

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

51
SEARCH A NUMBER IN AN ARRAY

ADDRESS LABEL MNEMONICS OP- COMMAND


CODE
1000 MOV SI,1200 BE 00 12 MOVE THE DATA TO SI
1003 MOV DI,1500 BF 00 15 MOVE THE DATA TO DI
1006 MOV CL,[SI] 8A 0C MOVE THE MEMORY CONTENTS
OF SI TO CL
1008 INC SI 46 INCREMENT SI
1009 MOV AL,[SI] 8A 04 MOVE THE MEMORY CONTENTS
OF SI TO AL
100B INC SI 46 INCREMENT SI
100C LOOP CMP AL,[SI] 3A 04 COMPARE THE MEMORY
CONTENT OF SI WITH AL
100E JZ END 74 09 IF JUMP ON ZERO THEN END
1010 INC SI 46 INCREMENT SI
1011 DEC CL FE C9 DECREMENT CL
1013 JNZ LOOP 75 F7 JUMP ON NO ZERO
1015 MOV AL,0FFH B0 FF MOVE THE DATA TO AL
1017 MOV [SI],AL 88 04 MOVE THE CONTENT OF AL TO SI
1019 END MOV BL,[SI] 8A 1C MOVE THE MEMORY CONTENT OF
SI TO BL
101B MOV [DI],BL 88 1D MOVE THE CONTENT OF BL TO DI
101D INT 02H CD 02 IN
101F HLT F4 STOP

RESULT:

Thus an Assembly Language Program (ALP) for sorting and searching operations using 8086 has
been written and executed successfully.

52
53
4.2 STRING MANIPULATION

AIM:

To write an Assembly Language Program (ALP) for string manipulation operations using
8086

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

ALGORITHM:

(i) PROGRAM FOR STRING PRIMITIVE:


a) Start the program.
b) Get the number of count to be made.
c) Load the output address in the destination index.
d) Load the input value to the accumulator.
e) Store the result in required memory locations using STO.
f) Stop the program.
(ii) STRING MANIPULATION:
a) Start the program.
b) Load the input address in the source index.
c) Load the output address in the destination index.
d) Get the number of count to be made.
e) Store the result in required memory location.
f) Stop the program.
(iii) CALCULATING THE LENGTH OF THE STRING:
a) Start the program.
b) Load the input address to the source index.
c) Load the data to any other general purpose register.
d) Load the data to accumulator.
e) Compare the accumulator higher and lower bit.
f) Store the result in required memory location.
g) Stop the program.

54
STRING PRIMITIVE

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

STRING MANIPULATION

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

55
PROGRAM:

A-PROGRAM FOR STRING PRIMITIVE (USING 8086)

ADDRESS LABEL MNEMONICS OPCODE COMMENTS

1000 MOV CX, 0010 B9 10 00 Count the value of


array
1003 MOV DI,[1100] BF 00 11 Declare destination
index
1006 MOV AX, 0034 B8 34 00 Move the data to
accumulator
1009 CLD FC Clear direction

100A L1 STOSB AA Store byte till


assigned address
100B LOOP L1 E2 FD Move to loop L1

100D HLT F4 Stop

B-STRING MANIPULATION USING 8086

ADDRESS LABEL MNEMONICS OP-CODE COMMAND


1000 MOV SI [1100] BE 00 11 MOVE ADDRESS
TO SOURCE
INDEX
1003 MOV DI [1200] BF 00 12 MOVE ADDRESS
TO DESTINATION
INDEX

1006 MOV CX ,0005 B9 05 00 DECLARE THE


SIZE OF ARRAY
ELEMENT

1009 CLD FC CLEAR


DIRECTION FLAG
MOVE DATA BYTES
100A L1 MOV SB A4

100B LOOP L1 E2 FD MOVE TO LOOP


L1
100D HLT F4 STOP THE
PROGRAM

56
LENGTH OF STRING

INPUT OUTPUT
ADDRESS DATA ADDRESS DATA

57
C-CALCULATING THE LENGTH OF STRING

ADDRESS LABEL MNEMONICS OP-CODE COMMAND


1000 MOV SI [1100] BE 00 11 MOVE ADDRESS
TO SOURCE
INDEX
1003 MOV DX,FFFF BA FF FF MOVE DATA TO
REGISTER
1006 MOV AH ,FF B4 FF MOVE DATA TO
ACCUMULATOR
HIGHER BIT
1008 L1 INC DX 42 INCREMENT ON
DX
1009 MOV AL,[SI] 8A 04 MOVE SOURCE
INDEX TO ACC.
LOWER
100B INC SI 46 INCREMENT ON
SI
100C CMP AH ,AL 38 C4 COMPARE ACC.
HIGHER AND
LOWER
100E JNZ L1 75 F8 JUMP NO ZERO
MOVE TO L1
1010 MOV [1200], 89 16 00 12 MOVE
DX REGISTER TO
1200
1014 HLT F4 STOP THE
PROGRAM

RESULT:

Thus an Assembly Language Program (ALP) for string manipulation operations using
8086 has been written and executed successfully.

58
59
4.3 SORTING IN DESCENDING ORDER USING MASM

AIM:

To write the program using MASM software for sorting the numbers in descending order and verify
the output.

APPARATUS:
SL.NO ITEM

1. PC

2. Keyboard

3 MASM SOFTWARE

ALGORITHM:

1. Initialize the data segment and the message to bedisplayed.


2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the CRT.

PROGRAM:

ASSUME CS:CODE,DS:DATA

DATA SEGMENT

LIST DW 02H,19H,25H,53H

COUNT EQU 04H

DATA ENDS

CODE SEGMENT

START:MOV AX,DATA

MOV DS,AX

MOV DX,COUNT-1

AGAIN 0:MOV CX,DX

MOV SI,OFFSET LIST

60
61
AGAIN 1:MOV AX,[SI]

CMP AX,[SI+2]

JNL PR1

XCHG [SI+2],AX

XCHG [SI],AX

PR1:ADD SI,02

LOOP AGAIN1

DEC DX

JNZ AGAIN0

MOV AH,4CH

INT 21H

CODE ENDS

END START

RESULT:

Thus an program using MASM software for sorting the numbers in descending order
and verify the output has been written and executed successfully

62
63
4.4 LARGEST NUMBER IN AN ARRAY USING MASM SOFTWARE

AIM:

To find the largest number in an array using MASM software.

ALGORITHM:

i. Initialize the data segment and the message to be displayed.


ii. Set function value for display.
iii. Point to the message and run the interrupt to display the message in the CRT
PROGRAM:

ASSUME CS:CODE,DS:DATA

DATA SEGMENT

LIST DW 23H,56H,45H,52H

COUNT EQU 04

LARGEST DB 01H DUP(?)

DATA ENDS

CODE SEGMENT

START:MOV AX,DATA

MOV DS,AX

MOV SI,OFFSET LIST

MOV CL,COUNT

MOV AL,[SI]

AGAIN:CMP AL,[SI+1]

JNL NEXT

MOV AL,[SI+1]

NEXT:INC SI

DEC CL

JNZ AGAIN

MOV SI,OFFSET LARGEST

MOV [SI],AL

64
65
MOV AH,4CH

INT 21H

CODE ENDS

END START

RESULT:

Thus to find the largest number in an array using MASM software has been written
and executed successfully.

66
67
5. PASSWORD CHECKING, PRINT RAM SIZE AND SYSTEM DATE

AIM:

To write an MASM program for password checking, print RAM size and system date using MASM
software.

APPARATUS REQUIRED:

SL.NO ITEM

1. PC

2. Keyboard

3 MASM SOFTWARE

PROGRAM:

; PASSWORD CHECKING

DATA SEGMENT
PASSWORD DB 'MASM1234'
LEN EQU ($-PASSWORD)
MSG1 DB 10,13,'ENTER YOUR PASSWORD: $'
MSG2 DB 10,13,'WELCOME TO ELECTRONICS WORLD!!$'
MSG3 DB 10,13,'INCORRECT PASSWORD!$'
NEW DB 10,13,'$'
INST DB 10 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,09H
INT 21H
MOV SI,00
UP1:
MOV AH,08H
INT 21H
CMP AL,0DH
JE DOWN
MOV [INST+SI],AL
MOV DL,'*'
MOV AH,02H
INT 21H

68
69
INC SI
JMP UP1
DOWN:
MOV BX,00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOV DL,[PASSWORD+BX]
CMP AL,DL
JNE FAIL
INC BX
LOOP CHECK
LEA DX,MSG2
MOV AH,09H
INT 21H
JMP FINISH
FAIL:
LEA DX,MSG3
MOV AH,009H
INT 21H
FINISH:
INT 3
CODE ENDS
END START
END

PRINT RAM SIZE

.DATA
MSG DB 'MEMORY SIZE IN KILO BYTES='
ASCRES DB 4 DUP(?),'HEX',0CH,0AH,'$'
DUP(?),'HEX',0CH,0AH,'$'
RES DW ?
HEXCODE DB '0123456789ABCDEF'
.CODE
HEX_ASC PROC
MOV DL,10H
MOV AH,0
MOV BX,0
DIV DL
MOV BL,AL
MOV DH,HEXCODE[BX]
MOV BL,AH
MOV DL,HEXCODE[BX]
RET
HEX_ASC ENDP
MAIN:
MOV AX,@DATA
MOV DS,AX
INT 12H
MOV RES,AX
MOV AL, BYTE PTR RES
CALL HEX_ASC

70
71
MOV ASCRES+2,DH
MOV ASCRES+3,DL
MOV AL,BYTE PTR RES+1
CALL HEX_ASC
MOV ASCRES,DH
MOV ASCRES+1,DL
MOV DX,OFFSET MSG
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
ALIGN 16
END MAIN

SYSTEM DATE

Display month/day/year.

.MODEL small
.STACK 100h
.DATA
mess1 DB 10, 13, 'Today is $' ; 10=LF, 13=CR
.CODE
Today PROC
MOV AX, @data
MOV DS, AX
MOV DX, OFFSET mess1 ; Move string to DX
MOV AH, 09h; 09h call to display string (DX > AH > DOS)
INT 21H; Send to DOS
; CX year, DH month, DL day
MOV AH, 2AH; Get the date (appendix D)
INT 21H; Send to DOS
PUSH CX; Move year to the stack
MOV CX, 0; Clear CX
MOV CL, DL
PUSH CX; Move day to stack
MOV CL, DH; Move month > CL
PUSH CX; Move month to stack
MOV DH, 0; Clear DH

; ************************** DISPLAY MONTH ************************


; Set up for division
; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0; Clear DX
POP AX; Remove month from stack into AX
MOV CX, 0; Initialize the counter
MOV BX, 10; Set up the divisor
dividem:
DIV BX; Divide (will be word sized)
PUSH DX; Save remainder to stack

72
73
ADD CX, 1; Add one to counter
MOV DX, 0; Clear the remainder
CMP AX, 0; Compare quotient to zero
JNE dividem; If quoient is not zero, go to "dividem:"
divdispm:
POP DX; Remove top of stack into DX
ADD DL, 30h; ADD 30h (2) to DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS
LOOP divdispm; If more to do, divdispm again
; LOOP subtracts 1 from CX. If non-zero, loop.
MOV DL, '/'; Character to display goes in DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS
; ************************** DISPLAY DAY ************************
; Set up for division
; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0; Clear DX
POP AX; Remove day from stack into AX
MOV CX, 0; Initialize the counter
MOV BX, 10; Set up the divisor
divided:
DIV BX; Divide (will be word sized)
PUSH DX; Save remainder to stack
; LOOP subtracts 1 from CX. If non-zero, loop
MOV DL, '/'; Character to display goes in DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS

; ************************** DISPLAY YEAR ************************


; Set up for division
; Dividend will be in DX/AX pair (4 bytes)
; Quotient will be in AX
; Remainder will be in DX
MOV DX, 0; Clear DX
POP AX; Remove month from stack into AX
MOV CX, 0; Initialize the counter
MOV BX, 10; Set up the divisor
dividey:
DIV BX; Divide (will be word sized)
PUSH DX; Save remainder to stack
ADD CX, 1; Add one to counter
MOV DX, 0; Clear the remainder
CMP AX, 0; Compare quotient to zero
JNE dividey; If quoient is not zero, go to "dividey:"
divdispy:
POP DX; Remove top of stack into DX
ADD DL, 30h; ADD 30h (2) to DL
MOV AH, 02h; 02h to display AH (DL)
INT 21H; Send to DOS
LOOP divdispy; If more to do, divdisp again
; LOOP subtracts 1 from CX. If non-zero, loop.
MOV al, 0; Use 0 as return code

74
75
MOV AH, 4ch; Send return code to AH
INT 21H; Send return code to DOS to exit.
Today ENDP; End procedure
END Today; End code. Start using "Today" procedure.
MVI A, 80H: Initialize 8255, port A and port B
OUT 83H (CR): in output mode
START: MVI A, 09H
OUT 80H (PA): Send data on PA to glow R1 and R2
MVI A, 24H
OUT 81H (PB): Send data on PB to glow G3 and G4
MVI C, 28H: Load multiplier count (40ıο) for delay
CALL DELAY: Call delay subroutine
MVI A, 12H
OUT (81H) PA: Send data on Port A to glow Y1 and Y2
OUT (81H) PB: Send data on port B to glow Y3 and Y4
MVI C, 0AH: Load multiplier count (10ıο) for delay
CALL: DELAY: Call delay subroutine
MVI A, 24H
OUT (80H) PA: Send data on port A to glow G1 and G2
MVI A, 09H
OUT (81H) PB: Send data on port B to glow R3 and R4
MVI C, 28H: Load multiplier count (40ıο) for delay
CALL DELAY: Call delay subroutine
MVI A, 12H
OUT PA: Send data on port A to glow Y1 and Y2
OUT PB: Send data on port B to glow Y3 and Y4
MVI C, 0AH: Load multiplier count (10ıο) for delay
CALL DELAY: Call delay subroutine
JMP START
Delay Subroutine:
DELAY: LXI D, Count: Load count to give 0.5 sec delay
BACK: DCX D: Decrement counter
MOV A, D
ORA E: Check whether count is 0
JNZ BACK: If not zero, repeat
DCR C: Check if multiplier zero, otherwise repeat
JNZ DELAY
RET: Return to main program

RESULT:

Thus an MASM program for password checking, print RAM size and system date
using MASM software

76
77
6. COUNTERS AND TIME DELAY

AIM:

To write an Assembly Language Program (ALP) for string manipulation operations using
8086.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

ALGORITHM:

1. Initialize the data segment and the message to be displayed.

2. Set function value for display.

3. Point to the message and run the interrupt to display the message in the CRT.

PROGRAM:
.MODEL SMALL
.DATA
MSGIN DB 'Enter delay duration (0-50): $'
MSG1 DB 'This is Microprocessor!$'
DELAYTIME DW 0000H
CODE
MOV DX,@DATA
MOV DS,DX
LEA DX,MSGIN
MOV AH,09H
INT 21H
IN1:
MOV AH,01H
INT 21H
CMP AL,0DH ;
JE NXT
SUB AL,30H
MOV DL,AL
MOV AX,BX

78
79
MOV CL,0AH
MUL CL
MOV BX,AX
AND DX,00FFH
ADD BX,DX
MOV DELAYTIME,BX
LOOP IN1
NXT:MOV CX,DELAYTIME
MOV DL,10
MOV AH,02H
INT 21H
LEA SI,MSG1
LP: PUSH DX
MOV DL,[SI]
Jnz repe
CMP DL,'$'
JE NXT2
MOV AH,02H
INT 21H
ADD SI,1
POP DX
MOV DI,DELAYTIME
MOV AH, 0
INT 1Ah
MOV BX, DX
Delay:
MOV AH, 0
INT 1Ah
SUB DX, BX
CMP DI, DX
JA Delay
LOOP LP
NXT2: MOV AH,4CH
INT 21H
END

RESULT:

Thus an MASM program for Counters and Time Delay using MASM software has been written and
executed successfully.

80
81
7. TRAFFIC LIGHT CONTROL

AIM

To write an assembly language program to interface traffic light controller with 8086 using
8255.

APPARATUS REQUIRED

1. 8086 Microprocessor kit,

2. Power chord,

3. Traffic light interface board

4. 26 channel bus

ALGORITHM

1. Find the control word for 8255 and data corresponding to the given condition’s and load
this data in to the memory location.
2. Get the number of conditions in the C-register.
3. Move the control word to accumulator and place in 8255.
4. Move the first data to accumulator and place in port-A.
5. Move the next data to accumulator and place in port-B.
6. Move the next data to accumulator and place in port-C.
7. Call the delay routine.
8. Decrement the C-register. If C=’0’ then go to next step else go to step 3.
9. Go to step 1 and Stop

82
83
TRAFFIC CONTROL DIAGRAM:

THEORY:
The 8086 micro processor announced by Intel in 1978 was Intel„s first 16-bit micro
processor and the first in the family it is sub-divided into two principle units. The
execution unit EU, including the ALU eight 160bit general register, a 16-bit flag
register and register unit. The bus interface unit, includes an address for adder
calculation for 16-bit segment register a 16-bit instruction pointer {ip}6 bytes
instruction queue and bus control logic, The 8086 chip has 40-pins including 16data
pin and 20 address pins, the 8086 microprocessor is used in various applications. In
our program use 8086 in traffic light controller using 8086 LCD display

PROCEDURE:
1. Enter the program
2. Execute the program
3. Check the output.

84
85
PROGRAM

MEMORY
ADDRESS LABEL MNEMONICS OP CODE
MOV
1000 START: BX,1100H BB 00 11
MOV
1003 CX,000CH B9 00 0C
1006 MOV AL,[BX] 8A 07
OUT
1008 CONTRL,AL E6 0F
100A INC BX 43
100B NEXT: MOV AL,[BX] 8A 07
100D OUT
PORTA,AL E6 0C
100F INC BX 43
1010 MOV AL,[BX] 8A 07
OUT
1012 PORTB,AL E6 0D
1014 INC BX 43
1017 MOV AL,[BX] 8A 07
OUT
1019 PORTC,AL E6 0E
101B CALL DELAY E8 07 00
101E INC BX 43
1021 LOOP NEXT: E2 ED
1023 JMP START EB DF
1024 DELAY: PUSH CX 51
MOV
1025 CX,0005H B9 00 05
MOV
1028 REPEAT: DX,0FFFFH BA FF FF
103B LOOP2: DEC DX 4A
103C JNZ LOOP2 75 FD
LOOP
103E REPEAT E2 F8
103F POP CX 59
1040 RET C3

INPUT DATA
1100 80, 84, 2E, 4C
1104 84, 9D, 90, 93
1107 2B, 10, 64, 27, 12

86
87
PORT A [ {D0 - D20}………0 - OFF & 1 – ON ]

D8 D7 D6 D5 D4 D3 D2 D1

POSITION 1 1 0 0 0 0 1 0 0 84H

POSITION 2 1 0 0 0 0 1 0 0 84H

POSITION 3 1 0 0 1 0 0 1 1 93H

POSITION 4 0 1 1 0 0 1 0 0 64H

PORT B [ {DL1 - DL8}………0 - GREEN & 1 – RED ]

D20 D19 D18 D17 DL78 DL56 DL34 DL12


POSITION 2EH
0 0 1 0 1 1 1 0
1
POSITION 9DH
1 0 0 1 1 1 0 1
2
POSITION 2BH
0 0 1 0 1 0 1 1
3
POSITION 27H
0 0 1 0 0 1 1 1
4
PORT C [ {D0 - D20}………0 - OFF & 1 – ON ]

D16 D15 D14 D13 D12 D11 D10 D9

POSITION 1 0 1 0 0 1 1 0 0 4CH

POSITION 2 1 0 0 1 0 0 0 0 90H

POSITION 3 0 0 0 1 0 0 0 0 10H

POSITION 4 0 0 0 1 0 0 1 0 12H

RESULT:

Thus an program for traffic light controller by interfacing with 8086 microprocessor has been written
and executed successfully

88
89
8. STEPPER MOTOR CONTROL

AIM:

To write an assembly language program to interface stepper motor with 8086.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3. Power chord 1

4. Stepper motor 1

5. Interface board Stepper motor 1

6. 50 Channel Bus

THEORY:

A motor in which the rotor is able to assume only discrete stationary angular position is a
stepper motor. The rotary motion occurs in a step-wise manner from one equilibrium position to the
next. Stepper Motors are used very wisely in position control systems like printers, disk drives,
process control machine tools, etc.

The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles
has its own winding. The excitation of any one winding generates a North Pole. A South Pole gets
induced at the diametrically opposite side. The rotor magnetic system has two end faces. It is a
permanent magnet with one face as South Pole and the other as North Pole.

The Stepper Motor windings A1, A2, B1, B2 are cyclically excited with a DC current to run
the motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise
stepping can be obtained.

2-PHASE SWITCHING SCHEME

In this scheme, any two adjacent stator windings are energized. The switching scheme is
shown in the table given below. This scheme produces more torque.

90
91
ANTICLOCKWISE CLOCKWISE

STE A A2 B B2 DATA STE A A B B2 DATA

P 1 1 P 1 2 1

1 1 0 0 1 9h 1 1 0 1 0 Ah

2 0 1 0 1 5h 2 0 1 1 0 6h

3 0 1 1 0 6h 3 0 1 0 1 5h

4 1 0 1 0 Ah 4 1 0 0 1 9h

ADDRESS DECODING LOGIC

The 74138 chip is used for generating the address decoding logic to generate the device
select pulses, CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the
stepper motor driving circuitry.

Stepper Motor requires logic signals of relatively high power. Therefore, the interface
circuitry that generates the driving pulses uses silicon Darlington pair transistors. The inputs for
the interface circuit are TTL pulses generated under software control using the Microcontroller
Kit. The TTL levels of pulse sequence from the data bus are translated to high voltage output
pulses using a buffer 7407 with open collector.

92
93
PROGRAM:

TO RUN STEPPER MOTOR AT DIFFERENT SPEEDS

ADDRESS LABEL MNEMONICS OPCODE


1000 START: MOV BL,20H B3 20
MOV DI,OFFSET
1002 FORWD: FORW BF 37 10
1005 CALL ROTATE E8 1800
1008 DEC BL FE CB
100A JNZ FORWD 75 F6
100C CALL DELAY E8 21 00
100F MOV BL,20H B3 20
MOV DI,OFFSET
1011 REVER: REV BF 3B 10
1014 CALL ROTATE E8 09 00
1017 DEC BL FE CB
1019 JNZ REVER 75 F6
101B CALL DELAY E8 12 00
101E JMP START EB E0

1020 ROTATE: MOV CL,04 B1 04


1022 REPT: MOV AL,[DI] 8A 05
1024 OUT PORT1,AL E6 C0
1026 MOV DX,1010H BA 1010
1029 LOOP1: DEC DX 4A
102A JNZ LOOP1 75 FD
102C INC DI 47
102D LOOP REPT E2 F3
102F RET C3
1030 MOV DX,0FFFFH BA FFFF
1033 DELAY: DEC DX 4A
1034 75 FD JNZ DELAY
1036 RET C3
09 05 06
1037 FORW: 9,5,6,0AH 0A
0A 06 05
103B REV: 0AH,6,5,9 09

94
95
A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED

MEMORY LABEL MNEMONICS OPCODE


ADDRESS
1000 START MOV D1 offset BF,14,10
table (1014)

1003 MOV CL, 04 B1,04

1005 LOOP1 MOV AL,[D1] 8A,05

1007 OUT E6,C0


PORT1,AL

1009 MOV DX,1010 BA,10,10

100C DELAY DEC DX 4A

100D JNZ DELAY 75,FD

100F INC D1 47

1010 LOOP LOOP1 E2,F3

1012 JMP START EB,EC

1014 TABLE DB 09,05,06,0A

RESULT:
Thus an assembly language program to interface stepper motor with 8086 has
been written and executed successfully.

96
97
9. DIGITAL CLOCK

AIM:

To write an Assembly Language Program (ALP) to display the Computer’s real-time clock on
the screen as in digital clock.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Macro assembler Software 1

2. PC 1

THEORY:

CLOCK DISPLAY:

Every PC is equipped with a real-time clock operated by a small battery. Even when the computer is
switched off, this clock continues to function to maintain the clock in its CMOS registers. When the
PC is on, the Operating System software reads this clock and stores the value in memory. User
programs can access this data. The OS software provides facilities for the programmer to read this
clock value using Software Interrupts. The IBM PC system BIOS also provides interrupt services to
access this real time clock. The BIOS services provide the hours, minutes and seconds in CPU
registers as BCD data. Hence they can be converted easily into ASCII value for displaying on screen

ALGORITHM:

CLOCK DISPLAY PROGRAM:

a) Initialize data segment to hold the clock data as hours, minutes and seconds.
b) Display a message on screen for the user.
c) Call the procedure to get the time from PC’s real-time clock using BIOS interrupt.
d) Call the procedure to convert the clock data into ASCII and display it on the screen.
e) Check for user key press using BIOS interrupt service.
f) If no key is pressed continue updating the clock on screen.
g) If a key is pressed terminate the program.

Procedure Get Time:

a) Use Function 02 in Interrupt 1Ah service to read the PC’s real-time clock. This function
returns hours in CH, minutes in CL and seconds in DH registers.
b) Divide each of these registers by 10h to separate the BCD digits.

98
99
c) Convert each separated digit into ASCII by adding 30h with it.
d) Store each digit in the appropriate location in the memory.
e) Return from the procedure.

Procedure ShowTime:

a) Use BIOS interrupt 10h function 02h to set video cursor at desired location on the screen.
b) Use DOS interrupt 21h function 09h to display the stored clock data from Data segment
memory as a string terminated by ‘$’.
c) Call a procedure to delay for few milliseconds doing nothing.
d) Return from the procedure.

Procedure Delay:

a) Load a value in CX register.


b) Do nothing.
c) Decrement CX register by one.
d) Loop until CX register is zero.
e) Return from the procedure.

PROGRAM:

.MODEL SMALL
.STACK
.DATA
MESSAGE DB 0AH,0DH
MESSAGE1 DB 0AH,0DH
PROMPT DB “TIMER::”
HOURS1 DB 0
HOURS2 DB 0
SEPERATOR1 DB “:”
MINUTES1 DB 0
MINUTES2 DB 0
SEPERATOR2 DB “:”
SECONDS1 DB 0
SECONDS2 DB 0
LAST DB ‘$’
DIVISOR DB 10H
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AH,09H
LEA DX,MESSAGE
INT 21H
AGAIN:CALL GETTIME
CALL SHOWTIME
MOV AH,01H

100
101
INT 16H
JZ AGAIN
MOV AH,04CH
INT 21H
GET TIME PROC
MOV AH,02H
INT 1AH
MOV AL,CH
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV HOURS1,AL
MOV HOURS2,AH
XOR AX,AX
MOV AL,CL
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV MINUTES1,AL
MOV MINUTES2,AH
XOR AX,AX
MOV AL,DH
DIV DIVISOR
ADD AL,30H
ADD AH,30H
MOV SECONDS1,AL
MOV SECONDS2,AH
RET
GET TIME ENDP
SHOW TIME PROC
MOV AH,02H
MOV BH,0
MOV DH,20D
MOV DL,10D
INT 10H
MOV AH,09H
LEA DX,PROMPT
INT 21H
CALL DELAY
RET
SHOW TIME ENDP
DELAY PROC
PUSH CX
MOV CX,0FFFH
IDLE:NOP
NOP
NOP
NOP

102
103
LOOP IDLE OUT
POP CX
RET
DELAY ENP
END

RESULT:
Thus an Assembly Language Program (ALP) to display the Computer’s real-time
clock on the screen as in digital clock has been written and executed successfully.

104
105
10. KEYBOARD AND DISPLAY

AIM:

To perform interfacing and programming 8279 using 8086.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3. Power chord 1
4. 50 channel bus 3
5. 8279 kit 1

ALGORITHM:

ROLLING DIAPLAY

a) Start the program.


b) Set 8279 for 8-bit character display right entry and a key lock out.
c) Clear the display.
d) Load the data to control register to write to the display.
e) Set the counter value.
f) Initialize the HL register pair and memory pointer.
g) Call the subroutine for delay procedure.
h) Increment H and decrement B register.
i) Repeat the steps e and h
j) Stop the program.

106
107
READ A KEY:

ADDRESS LABEL MNEMONICS OPCODE

1000 MOV BX,1100 BB 00 11

IN AL,C2

1003 LOOP: E4 C2

1005 TEST AL,07 A8 07

1007 JZ LOOP 74 FA

1009 MOV AL,40 B0 40

100B OUT C2,AL E6 C2

100D IN AL,C0 E4 C0

100F MOV [BX],AL 88 07

1011 HLT F4

108
109
ROLLING DISPLAY (DISPLAY MESSAGE IS HELP US)

ADDRESS LOOP MNEMONICS OP-CODE COMMANDS

1000 START MOV SI,1200 BE 00 12 SET MODE COUNT AND


DISPLAY

1003 MOV CX,000F B9 0F 00 MOVE 000F DATA IN CX

1006 MOV AL,10 B0 10 SET ACC DATA

1008 OUT C2,AL E6 C2 CLEAR DISPLAY

100A MOV AL,CC B0 CC MOVE CC DATA IN AL

100C OUT C2,AL E6 C2 SET PORT DATA

100E MOV AL,90 B0 90 WRITE DISPLAY

1010 OUT C2,AL E6,C2 CLEAR DISPLAY IN RAM

1012 NEXT MOV AL,[SI] 8A 04 LOP FOR THE PRESSING OF


KEY

1014 OUT CO,AL E6 C0 SET TO READ FIFO RAM

1016 CALL DELAY E8 E7 04 CALL DISPLAY DATA

1019 INC SI 46 GET THE CORRESPONDING


CODE FORM LOOKUP TABLE

101A LOOP NEXT E2 F6 GO TO NEXT

101C JMP START EB E2 JUMP START

SUB PROGARM:

ADDRESS LOOP MNEMONICS OP- COMMANDS


CODE
1500 DELAY MOV BA FF A0 MOVE THE VALUE TO
DX,A0FF DX REGISTER
1503 DEC DX 4A DECREMENT DX

1504 JNZ LOOP1 75 FD JUMP NO ZERO

1506 RET C3 RETURN

110
111
LOOK-UP TABLE

ADDRESS DATA
1200 FF,FF,FF,FF

1204 FF,FF,FF,FF

1208 98,68,7C,C8
120C FF,1C,29,FF

RESULT:

Thus to perform interfacing and programming for Key board and Display has been written and
executed successfully.

112
113
11.1 SERIAL INTERFACE

AIM:

To perform serial communication between two microprocessor kits using 8251.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3. Power chord 1
4. VXT parallel bus 1
5. Interface board 8251 1
6. Serial connection cable RS232

ALGORITHM:

a) Connect the two serial ports with RS232 cable.


b) First make the receiver end ready and then execute the program at transmitter end.
c) The transmitter transmits the data serially.
d) The receiver data is stored in the memory location given in the program.

114
TABULATION

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

1015 1250

115
PROGRAM

TRANSMITTER PROGRAM

ADDRESS MNEMONICS OP-CODE COMMANDS


1000 MOV AL,36 BO 36 MOVE THE VALUE TO ACCUMULATOR
SEND DATA TO OUTPUT PORT
1002 OUT CE,AL E6 CE

1004 MOV AL,10 B0 10 MOVE THE VALUE TO ACCUMULATOR


SEND DATA TO OUTPUT PORT
1006 OUT C8,AL E6 C8

1008 MOV AL,00 B0 00 MOVE THE VALUE TO ACCUMULATOR


SEND DATA TO OUTPUT PORT
100A OUT C8,AL E6 C8

100C MOV AL,4E B0 4E MOVE THE VALUE TO ACCUMULATOR


SEND DATA TO OUTPUT PORT
100E OUT C2,AL E6 C2

1010 MOV AL,37 B0 37 MOVE THE VALUE TO ACCUMULATOR


SEND DATA TO OUTPUT PORT
1012 OUT C2,AL E6 C2

1014 MOV AL,AA BO AA MOVE THE VALUE TO ACCUMULATOR


SEND DATA TO OUTPUT PORT
1016 OUT CO,AL E6 CO

INTERUPT
1018 INT 02 CD 02

RECEIVER PROGRAM
OP-
ADDRESS MNEMONICS COMMANDS
CODE
INTERUPT
1200 IN AL,C0 E4 C0

MOV MOVE THE VALUE TO


1202 BB 50 12
BX[1250] ADDRESS
MOVE ACCUMULATOR
1205 MOV BX,AL 88 07
DATA TO BX
INTERUPT
1207 INT 02 CD 02

RESULT:

Thus to perform serial communication using 8251 has been written and
executed successfully.

116
117
11.2 PARALLEL INTERFACE

AIM:

To interface programmable peripheral interface 8255 with 8086 and study its characteristics
in mode0

APPARATUS REQUIRED:

1. 8086 p kit
2. 8255 Interface board
3. DC regulated power supply
4. VXT parallel bus
THEORY:

I/O MODES:

Control Word:

118
119
MODE 0 – SIMPLE I/O MODE:

This mode provides simple I/O operations for each of the three ports and is suitable
for synchronous data transfer. In this mode, all the ports can be configured either as input or output
port.

Let us initialize port A as input port

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODES

1000 MOV SI , 1500 BE 00 15

1003 MOV AL,90 B0 90

1005 OUT C6,AL E6 C6

1007 IN AL,C0 E4 C0

1009 MOV [SI], AL 88 04

100B HLT F4

120
121
MODE 0 STROBED I/O MODE:

Let us initialize port A as input port and port B as output port

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODES

1000 MOV AL,90 B0 90

1002 OUT C6,AL E6 C6

1004 IN AL,C0 E4 C0

1006 OUT C2 AL E6 C2

1008 HLT F4

RESULT:

Thus to interface programmable peripheral interface 8255 with 8086 and study
its characteristics in mode0 has been written and executed successfully.

122
123
12. A/D AND D/A INTERFACE AND WAVEFORM GENERATION

AIM:

To write an Assembly Language Program (ALP) to interface ADC and DAC using 8086
microprocessor.

APPARATUS REQUIRED:

SL.NO ITEM SPECIFICATION QUANTITY

1. Microprocessor kit 8086 kit 1

2. Keyboard 1

3 Power chord 1

4. ADC kit 1

5. Multimeter 1

6. DAC kit 1

7. 50 channel Bus 2

8. CRO 1

9. CRO probe 1

THEORY:

ANALOG TO DIGITAL CONVERTER:

ADC-0809 A/D card is an 8bit analog to digital converter with 8 channel multiplexer and
microprocessor compatible control logic. The heart of the car is ADC-0809 monolithic C-MOS
device. Its conversion time is 100 micro sec. it eliminates the need for external zero and full scale
adjustment. The card selects one of the eight unipolar inputs by using the address decoder. ADC-0809
uses successive approximation as conversion techniques. Input is latched to the decoder on the low to
high transition of the address latch enable signal. The conversion starts on the falling edge of the start
of conversion signal. During the process end of conversion signal goes low otherwise it remains high.
Digital output can be read from ADC making output enable signal high.

124
125
Circuit description:

The data line of ADC-0809 d0 to d7 is connected to port-A as input port. SOC is connected to PC0 as
output port; EOC is connected to PC4 as input port & ALE is connected to PC1 as output port. All
eight inputs of 0-5 volts ADC-0809 analog with external clock, external EOC, external SOC signals
are brought to 26 pin connector. A clock input of a specified frequency is required for the operation of
ADC-0809. A counter 74LS93 has been used for this purpose.

Hardware installation:

 Connect ADC-0809 interfacing module to 8255-I of 8086 trainer kit through 26 pin FRC
cable.
 Be sure about the direction of the cable i.e. pin NO.1 of module should be connected to pin
NO.1 of 8255 connector.
 Connect +5v, GND from the trainer kit (+5v & GND signals are available in the 25 & 26 pin
of FRC 8255-I connector)

DIGITAL TO ANALOG CONVERTER:

A digital number can be converted to an analog voltage by selectively adding voltage which is
proportional to the weight of each binary digit. The module finds a great use in feedback system, like
output of a channel is fed to a control circuit to contain output in the form of signal is observed at an
oscilloscope or for a hard copy fed to an X-Y Recorder/X-T Recorder. Different wave forms can be
generated by using this DAC-0800 module.

Circuit description:

Port A & port B are connected to channel 1 and channel 2 respectively. A reference voltage of 8V is
generated using 723 and is given to verify points of the DAC 0800. The standard output voltage will
be 7.98V when FF is outputted and will be 0v when 00 is outputted. The output of DAC-0800 is fed
to the operational amplifier to get the final output as X out and Y out. Several interesting waveforms
can be generated and observed on oscilloscope.

Hardware installation:

 Connect DAC-0800 interfacing module to 8255-I of 8085/8051/80865 trainer kit through 26


pin FRC cable.
 Be sure about the direction of the cable i.e. pin No.1 of module should be connected to pin
No.1 of 8255 connector.
 Connect +12V, -12V & GND from the trainer kit.

126
127
ALGORITHM:

ANALOG TO DIGITAL CONVERTER:

a) Start the program.


b) Enter the control word.
c) Clear the register.
d) Move the register at AL=0.
e) Read EOC from Accumulator.
f) Read 16 bit ADC data.
g) Clear CALL display.
h) CALL display routine.
i) Load CX register as 0F0H.
j) Jump till CX=0.
k) Jump to start.
l) Stop the program.

DIGITAL TO ANALOG CONVERTER:

1) GENERATION OF SAWTOOTH WAVE


a) Start the program
b) Load the input value to the accumulator.
c) Move to C0.
d) Increment AL.
e) If jump on no carry then execute loop L1.
f) Jump on START.
g) Return.
h) Store the output in the required memory location.
i) Stop the program.

2) GENERATION OF SQUARE WAVE


a) Start the program
b) Load the input value to the accumulator.
c) Call the delay.
d) Jump on start.
e) Go to loop L1.
f) Return.
g) Store the output in the required memory location.
h) Stop the program.

128
TABULATION

SL NO ANALOG INPUT DIGITAL OUTPUT

129
3) GENERATION OF TRAINGULAR WAVE
a) Start the program.
b) Load the value in the accumulator.
c) Increment the BL register.
d) Jump on no zero.
e) Decrement the BL register.
f) Jump on no carry.
g) Return.
h) Store the output in the required memory location.
i) Stop the program.

PROGRAM:

ANALOG TO DIGITAL CONVERTER

COMMANDS
ADDRESS LABEL MNEMONICS OP-CODE

MOVE DATA TO
1000 MOV AL,03 B0,03
ACCUMULATOR
MOVE THE
1002 OUT C8,AL E6,C8 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
1004 MOV AL,23 B0,23
ACCUMULATOR
MOVE THE
1006 OUT C8,AL E6,C8 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
1008 MOV AL,03 B0,03
ACCUMULATOR
MOVE THE
100A OUT C8,AL E6,C8 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
100C MOV AL,01 B0,01
ACCUMULATOR

130
131
MOVE THE
100E OUT D0,AL E6,D0 CONTENT OF AL
TO OUTPUT PORT
MOVE DATA TO
1010 MOV AL,00 B0,00
ACCUMULATOR
MOVE THE
1012 OUT D0,AL E6,D0 CONTENT OF AL
TO OUTPUT PORT
MOVE THE
1014 LOOP IN AL,E0 E4,E0 CONTENT OF
INPUT PORT TO AL
PERFORM AND
1016 AND AL,01 24,01 OPERATION WITH
AL AND DATA
COMPARE THE
1018 CMP AL,01 3C,01 VALUE OF AL
WITH DATA
101A JNZ LOOP 75,F8 JUMP ON NO ZERO
MOVE THE
101C IN AL,C0 E4,C0 CONTENT OF
INPUT PORT TO AL
MOVE THE DATA
101E MOV BX,1100 BB,00,11
TO BX
MOVE THE
1021 MOV[BX],AL 88,07 CONTENT OF AL
TO BX
STOP
1023 HLT F4

132
SAWTOOTH WAVE

AMPLITUDE (Volts) TIME PERIOD (Seconds)

133
DIGITAL TO ANALOG CONVERTER

GENERATION OF SAWTOOTH WAVE

ADDRESS LABEL MNEMONICS OP-CODE COMMANDS


1000 START MOV AL,00 B0,00 MOVE THE
DATA TO AL
REGISTER

1002 L1 OUT C0,AL E6,C0 MOVE THE


CONTENT OF
AL TO OUTPUT
PORT C0

1004 INC AL FE,C0 INCREMENT AL


REGISTER

1006 JNZ L1 75,FA JUMP ON NO


ZERO

1008 JMP START EB,F6 JUMP TO START

100A RET C3 RETURN

134
SQUARE WAVE

AMPLITUDE (Volts) TIME PERIOD (Seconds)

135
GENERATION OF SQUARE WAVE

ADDRESS LABEL MNEMONICS OPCODE COMMANDS


1000 START MOV AL,00 B0,00 MOVE THE
DATA TO AL
REGISTER
1002 OUT C0,AL E6,C0 MOVE THE
CONTENT OF
AL TO OUTPUT
PORT C8
1004 CALL DELAY E8,09,00 CALL THE
DELAY
PROGRAM
1007 MOV AL,FF B0,FF MOVE THE
DATA TO AL
REGISTER
1009 OUT C0,AL E6,C0 MOVE THE
CONTENT OF
AL TO OUTPUT
PORT C8
100B CALL DELAY E8,02,00 CALL THE
DELAY
PROGRAM
100E JMP START EB,F0 JUMP TO
START
1010 DELAY MOV CX,05,FF B9,FF,05 DECLARE THE
COUNT VALUE
1013 L1 LOOP L1 E2,FE GO TO LOOP
L1
1015 RET C3 RETURN

136
TRAINGULAR WAVE

AMPLITUDE (Volts) TIME PERIOD (Seconds)

137
GENERATION OF TRAINGULAR WAVE

ADDRESS LABEL MNEMONICS OP-CODE COMMANDS

1000 START MOV BL,00 B3,00 MOVE THE DATA TO BASE


REGISTER
1002 L1 MOV AL,BL 88,D8 MOVE THE CONTENT BL
TO AL REGISTER
1004 OUT C0,AL E6,C0 MOVE THE CONTENT OF
AL TO OUTPUT PORT C8
1006 INC BL FE,C3 INCREMENT THE VALUE
OF BL REGISTER
1008 JNZ L1 75,F8 JUMP ON NO ZERO

100A MOV BL,FF B3,FF MOVE THE DATA TO BL


REGISTER
100C L2 MOV AL,BL 88,D8 MOVE THE CONTENT BL
TO AL REGISTER
100E OUT C0,AL E6,C0 MOVE THE CONTENT OF
AL TO OUTPUT PORT C8
1010 DEC BL FE,CB DECREMENT THE VALUE
OF BL REGISTER
1012 JNC L2 75,F8 JUMP ON NO CARRY

1014 JMP START EB,EA JUMP ON START

1016 RET C3 RETURN

RESULT:

Thus an Assembly Language Program (ALP) to interface ADC and DAC using 8086 microprocessor
ha sbeen written and executed successfully

138
ADDITION OF TWO 8-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6102 6500

6104

139
13. BASIC ARITHMETIC AND LOGICAL OPERATIONS

13.1 ADDITION OF TWO 8-BIT NUMBERS USING 8051

AIM
To write an assembly language program to add the two 8-bit numbers using microcontroller
instruction set.

APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Add the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.

PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 3F
6103 ADD A, #data2 24, 29
6105 MOV DPTR, #6500H 90, 65, 00
6108 MOVX @DPTR, A F0
6109 LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to add the two 8-bit numbers using
microcontroller instruction set has been written and executed successfully.

140
SUBTRACTION OF TWO 8-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6102 6500

6104

141
13.2 SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051

AIM
To write an assembly language program to subtract the two 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Subtract the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 59
6103 SUBB A, #data2 94, 28
6105 MOV DPTR, #6500H 90, 65, 00
6108 MOVX @DPTR, A F0
6109 LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to subtract the two 8-bit numbers


using microcontroller instruction set has been written and executed successfully.

142
MULTIPLICATION OF TWO 8-BIT

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6102 6500

6105 6501

143
13.3 MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051

AIM
To write an assembly language program to multiply the two 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,#data2 75, F0, 02
6106 MUL AB A4
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to multiply the two 8-bit numbers using microcontroller
instruction set has been written and executed successfully.

144
DIVISION OF TWO 8-BIT NUMBERS

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6102 6500

6105 6501

145
13.4 DIVISION OF TWO 8-BIT NUMBERS USING 8051

AIM
To write an assembly language program to divide the two 8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The remainder of the result is in B-register.
6. The quotient of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 08
6103 MOV B,#data2 75, F0, 02
6106 DIV AB 84
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to divide the two 8-bit numbers using microcontroller
instruction set has been written and executed successfully

146
SETTING BITS IN AN 8 BIT NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6101 6500

6103

147
13.5 SETTING BITS IN AN 8 BIT NUMBERS USING 8051

AIM
To write an assembly language program to find the Setting bits an
8-bit number using microcontroller instruction set.

APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.

ALGORITHM
1. Move the data to Accumulator.
2. Perform OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.

PROGRAM

MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data1 74, 2F
6102 ORL A, #data2 44, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to find the Setting bits an 8-bit number using
microcontroller instruction set has been written and executed successfully

148
MASKING BITS IN AN 8 BIT NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6101 6500

6103

149
13.6 MASKING BITS IN AN 8 BIT NUMBERS USING 8051

AIM
To write an assembly language program to find the Masking bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform AND operation with accumulator.
3. Move the accumulator output to the memory 6500H.

PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data1 74, 2F
6102 ANL A, #data2 54, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to find the Masking bits an 8-bit number
using microcontroller instruction sethas been written and executed successfully.

150
1 ‘s and 2’s COMPLEMENT OF A NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6101 6500

6501

151
14. SQUARE AND CUBE PROGRAM, FIND 2’s COMPLEMENT OF A NUMBER

14.1 FIND 2’s COMPLEMENT OF A NUMBER

AIM
To write an assembly language program to find the 1’s and 2’s complement of an 8-bit
number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
2. Move the data to Accumulator.
3. Complement the accumulator.
4. Move the one’s complement output to the memory 6500H.
5. Add 01H with accumulator.
6. Move the two’s complement output to the memory 6501H.
7.
PROGRAM

MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data 74, CC
6102 CPL A F4
6103 MOV DPTR, #6500H 90, 65, 00
6106 MOVX @DPTR, A F0
6107 INC A 04
610A INC DPTR A3
610B MOVX @DPTR, A F0
610C LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to find the 1’s and 2’s complement of an 8-bit
number using microcontroller instruction set has been written and executed successfully.

152
SQUARE OF A 8-BIT NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6102 6500

6501

153
14.2 SQUARE OF A 8-BIT NUMBER USING 8051

AIM
To write an assembly language program to find two the square of a8-bit numbers using
microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the first data to B-register.
4. Multiply the B-register with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,A F5, F0
6105 MUL AB A4
6106 MOV DPTR, #6500H 90, 65, 00
6109 MOVX @DPTR, A F0
610A INC DPTR A3
610B MOV A, B E5, F0
610D MOVX @DPTR, A F0
610E LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to find the square of an 8-bit number using
microcontroller instruction set has been written and executed successfully.

154
CUBE OF A 8-BIT NUMBER

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6102 6500

6501

155
14.3 CUBE OF A 8-BIT NUMBER USING 8051

AIM
To write an assembly language program to find the cube of a 8-bit numbers using
microcontroller instruction set.

APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.

ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the first data to B-register.
4. Multiply the B-register with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.

PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,A F5, F0
6105 MOV R0, A F8
6106 MUL AB A4
6107 MOV F0,R0 A8, F0
6109 MUL AB A4
610A MOV DPTR, #6500H 90, 65, 00
610D MOVX @DPTR, A F0
610E INC DPTR A3
6110 MOV A, B E5, F0
6112 MOVX @DPTR, A F0
6113 LOOP SJMP LOOP 80, FE

156
157
RESULT:

Thus an assembly language program to find the cube of an 8-bit number using
microcontroller instruction set has been written and executed successfully.

158
UNPACKED BCD TO ASCII

INPUT OUTPUT

ADDRESS DATA ADDRESS DATA

6101 6500

159
15. UNPACKED BCD TO ASCII

AIM
To write an assembly language program to convert unpacked BCD to ASCII code using 8051.

APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.

PROGRAM

MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MOV A, #data1 74, 02
6102 ORL A, #30 44, 30
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE

RESULT:

Thus an assembly language program to convert the Unpacked BCD to ASCII thas been
written and executed successfully.

160

You might also like