You are on page 1of 121

MAAMALLAN

INSTITUTE OF TECHNOLOGY
DEPARTMENT OF
ELECTRONICS AND
COMMUNICATION

EC 6513
MICROPROCESSORS & MICROCONTROLLERS
LAB MANUAL

MAAMALLAN INSTITUTE OF TECHNOLOGY


Vadamangalam, Sriperumpudur, Kanchipuram District

EC 6513
MICROPROCESSORS & MICROCONTROLLERS
LAB MANUAL

Name of the Student

: ______________________

Register Number

: ______________________

Department / Year/ Section

: ______________________

Table of contents :
S. No Date

Name of the Experiment

A
1

Architecture of 8086 & Programs


Addition of Two 16 Bit Datas.
Subtraction of Two 16 Bit Datas.
Multiplication of Two 16 Bit Datas.
Division of Two 16 Bit Datas.
Transfer a Block of Data.
Code Conversions
Largest of n Datas.
Addition of n Data.
Factorial of Data.
Matrix Addition .
String Manipulation Find & Replace
a Data.
Counter and Delay time
MASM Programs
Addition of Two 16 Bit Datas.
Subtraction of Two 16 Bit Datas.
Multiplication of Two 16 Bit Datas.
Division of Two 16 Bit Datas.
Transfer a Block of Data.
Code Conversions
Password Checking
Sorting of an Array of datas
Searching an element in an Array
Square using MASM
Architecture of 8051 & Programs
Addition of Two 8 Bit Datas.
Subtraction of Two 8 Bit Datas.
Multiplication of Two 8 Bit Datas.
Division of Two 8 Bit Datas.
Logical Operations
1's and 2's Complement
Code Conversion
Interfacing Programs
Digital Clock
Analog to Digital Convertor.
Digital to Analog Convertor.
Display Interface Accept a Key.
Display Interface Display a Letter.
Stepper Motor Interface.
Traffic Light Controller.
Printer Status
Parallel Interface

2
3
4
5
6
8
B
1
2
3
4
5
6
7
C
1
2
3
4
5
D
1
2
3
4
5
6
7
8

Page No Date of
Mark Signature
Submission

INTERNAL ARCHITECTURE OF 8086


Intel 8086 is a 16 bit processor, with powerful instruction set. It has 40 pins working in
two different modes, such as, Maximum Mode & Minimum Mode. The 8086 has Pipelined
Architecture with Bus Interface Unit & Execution Unit.

The 8086/8088 architecture can be broadly divided into two groups:


(i) Execution Unit (EU)
(ii) Bus Interface Unit (BIU)
The execution unit contains the Data and Address registers, the Arithmetic and Logic Unit and
the Control Unit. The Bus Interface Unit contains Bus Interface Logic, Segment registers,
Memory addressing logic and a Six byte instruction object code queue (4 - byte instruction
object - code queue in case of 8088 microprocessor).The execution unit and the Bus Interface
unit operate asynchronously. The EU waits for the instruction object code to be fetched from the
memory by the BIU. The BIU fetches or pre - fetches the object code (16 - bits at a time) and
loads it into the six bytes queue.
Whenever the EU is ready to execute a new instruction, it fetches the instruction object code
from the front of the instruction queue and executes the instruction in specified number of clock
periods. If memory or Input/output devices must be accessed in the course of executing an
instruction, then the EU informs the BIU of its needs. The BIU completes its operation code
(opcode) fetch cycle, if in progress, and executes an appropriate external access machine cycle I

n response to the EU demand. The BIU is independent of the EU and attempts to keep the six bytes queue filled with instruction object codes.
If two or more of these six bytes are empty, then the BIU executes instruction fetch machine
cycles as long as the EU does not have an active request for the bus access pending. If the EU
issues a request for the bus access while the BIU is in the middle of an instruction fetch machine
cycle, then the BIU will complete the instruction fetch machine cycle before honor ing the EU
bus access request. The EU does not use machine cycles; it executes instructions in some number
of clock periods that are not subjected to any type of machine cycles. The only time clock
periods are grouped is clock when the bus control logic wishes to access memory or I/O devices.

Execution Unit (EU):


The execution unit consists of
General Registers
Arithmetic Logic Unit
Control unit
Flag Registers
General Registers
The CPU has eight 16 -bit general registers. They are divided into two files of four
registers each.
They are:
(a) The data register file and
(b) The pointer and index register file
AX, BX, CX and DX registers are the data registers. The upper and lower halves of the
data registers are individually addressable. AX register can be addressed as AL and AH
registers, BX register can be addressed as BL and BH register, CX register can be
addressed as CL and CH register, DX register can be addressed as DL and DH.
The data registers can be used in most arithmetic and logic operations. Some instructions
however require these registers for specific use. This implicit register usage allows a
more compact instruction encoding. The index register file consists of the Stack Pointer
(SP), the Base Pointer (BP), Source Index (SI) and Destination Index (DI) registers all are
of 16 - bits. They can also be used in most arithmetic and logic operations. These
registers are usually used to hold offset addresses for addressing within a segment. Offset
addressing reduces program size by eliminating the need for each instruction to specify
frequently used addresses. The pointer and index register files are further divided into the
pointer sub - file (containing the Stack Pointer and the Base Pointer registers) and the
index sub - file (containing the Source index and Destination index registers). The Pointer
registers are used to access the current stack segment. The index registers are used to
access the current data.Unless otherwise specified in the instruction, stack pointer
registers refer to the current stack segment while index register refers to the current data
segment. The BP and SP registers are both used to point to the stack, a linear array in the
memory used for subroutine parameters, subroutine return addresses, and the data
temporarily saved during execution of a program Most microprocessors have a single
stack pointer register called the SP.

8086 / 8088 has an additional pointer into the stack called the BP register. While the SP is
used similar to the stack pointer in other machine
(for pointing to subroutine and interrupt return addresses), the BP register is used to hold
an old stack pointer value, or it can mark a place in the subroutine stack independent of
the SP register. Using the BP register to mark the stack saves the juggling of a single
stack pointer to reference subroutine parameters and addresses. SI and DI are both 16 bits wide and are used by string manipulation instructions and in building some of the
more powerful 8086/8088 data structures and addressing modes. Both the SI and the DI
registers have auto incrementing and auto - decrementing capabilities.
Arithmetic Logic Unit (ALU):
ALU is 16 - bits wide. It can do the following 16 - bits arithmetic operations
(i) Addition
(ii)Subtraction
(iii) Multiplication
(iv) Division
The ALU can also perform logical operations such as
(i) NOT
(ii)AND
(iii) OR
(iv) EXCLUSIVE OR
(v) TEST
Flag Register
The Execution Unit has a 16 - bit flag register which indicates some conditions affected
by the execution of an instruction. Some bits of the flag register control certain operations
of the EU. The flag register in the EU contains nine active flags . Six of the nine flags are
used to indicate some condition produced by an instruction. These condition flags are
also called status flags of 8086/8088 microprocessor. These are the Carry flag, Parity
flag, Auxiliary carry flag, Zero flag, and Sign flag. The other three Control flags are Trap
Flag, Direction Flag and Interrupt flag
Bus Interface Unit (BIU):
The BIU sends out addresses, fetches instructions from memory, reads data from memory
and ports, and writes data to ports and memory. In other words the BIU handles all
transfers of data and addresses on the buses for the execution unit. The BIU has
1. An instruction queue
2. An Instruction pointer
3. Segment registers

Instruction Queue:
To speed up program execution, the BIU fetches as many as 6 insturction bytes ahead of
time from memory. The prefetched instruction bytes are held for the EU in a first - - first out group of register called a queue. The EU decodes an instruction or executes an
instruction which does not require the buses. When the EU is ready for its next
instruction, it simply reads the instruction from the queue in the BIU. Fetching the next
instruction while the current instruction executes, is called pipelining.
Note:
The 8088 microprocessor has only a 4 -byte queue.
Instruction Pointer (IP)
The Instruction Pointer is a 16 - bit register. This register is always used as the effective
memory address, and is added to the Code segment with a displacement of four bits to
obtain the physical address of the opcode. The code segment cannot be changed by the
move instruction. The instruction pointer is incremented after each opcode fetch to point
to the next instruction. Segment Registers The 8086 / 8088 microprocessor has 20 - bit
address lines. All the registers in 8086 / 8088 are 16 - bits in length. Hence to obtain 20 bit addresses from the available 16 - bit registers, all 8086 / 8088 memory addresses are
computed by summing the contents of a segment register and a effective memory
address. The effective memory address is computed via a variety of addressing modes.
The process of adding, to obtain 20 - bit address is as follows:
The selected segment register contents are shifted - left four bits (i.e., the contents are
multiplied by 16 decimal), and then added to the effective memory address to generate
the actual physical address output.

8086 Programs

Expt.No:1 (A) ADDITION OF TWO 16 BIT DATA IN 8086


Date:
AIM:
To add two16 bit numbers stored at consecutive memory locations.
ALGORITHM:
1. Get the First data in Accumulator.
2. Add the Second Data with the Accumulator content
3. Store the Result
FLOWCHART:
START

GET THE FIRST DATA DATA IN


ACCUMALATOR

ADD THE SECOND DATA WITH


ACCUMALATOR CONTENT

STORE THE RESULT

END

PROGRAM :

ADDRESS
1100
1103
1104
1106
1107
1109
110C
110E

OPCODE MNEMONICS
BE 00 15
MOV
AD
LODSW
89 C3
MOV
AD
LODSW
01 C3
ADD
BF 20 15
MOV
89 1D
MOV
CC
INT

OPERAND
SI,1500
BX,AX
BX,AX
DI,1520
[DI],BX
3

OBSERVATION:

INPUT

RESULT:

OUTPUT

COMMENT

Expt.No:1 (B) SUBTRACTION OF TWO 16 BIT DATA IN 8086


Date:
AIM:
To Subtract two16 bit numbers stored at consecutive memory locations.
ALGORITHM:
1. Get the First data in Accumulatar.
2. Subtract the Second Data with the Accumalatar content
3. Store the Result
FLOWCHART:
START

GET THE FIRST DATA DATA IN


ACCUMALATOR

SUBTRACT THE SECOND DATA


WITH ACCUMALATOR CONTENT

STORE THE RESULT

END

PROGRAM :

ADDRESS
1100
1103
1104
1106
1107
1109
110C
110E

OPCODE MNEMONICS
BE 00 15
MOV
AD
LODSW
89 C3
MOV
AD
LODSW
01 C3
SUB
BF 20 15
MOV
89 1D
MOV
CC
INT

OPERAND
SI,1500
BX,AX
BX,AX
DI,1520
[DI],BX
3

OBSERVATION:

INPUT

RESULT:

OUTPUT

COMMENT

Expt.No:2(A)

MULTIPLICATION OF TWO 16 BIT DATA IN 8086

Date:
AIM:
To Multiply two16 bit numbers stored at consecutive memory locations.
ALGORITHM:
1. Get the First data in Accumulatar.
2. Multiply the Second Data with the Accumalatar content
3. Store the Result

FLOWCHART:
START

GET THE FIRST DATA DATA IN


ACCUMALATOR

MULTIPLY THE SECOND DATA


WITH ACCUMALATOR CONTENT

STORE THE RESULT

END

PROGRAM :

ADDRESS
1200
1203
1204
1206
1207
1209
120C
120E
120F
1210
1212

OPCODE MNEMONICS
BE 00 15
MOV
AD
LODSW
89 C3
MOV
AD
LODSW
F7 E3
MUL
BF 05 15
MOV
89 05
MOV
01 C3
INC
BF 20 15
INC
89 1D
MOV
CC
INT

OPERAND
SI,1500
BX,AX
BX
DI,1505
[DI],AX
DI
DI
[DI],DX
3

OBSERVATION:

INPUT

OUTPUT

COMMENT

RESULT:

Expt.No:2(B)

DIVISION OF TWO 16 BIT DATA IN 8086

Date:
AIM:
To Divide two16 bit numbers stored at consecutive memory locations.
ALGORITHM:
1. Get the First data in Accumulatar.
2. Divide the Second Data with the Accumalatar content
3. Store the Result
FLOWCHART
START

GET THE FIRST DATA DATA IN


ACCUMALATOR

DIVIDE THE SECOND DATA WITH


ACCUMALATOR CONTENT

STORE THE RESULT

END

PROGRAM :

ADDRESS
1300
1303
1306
1309
130B
130E
1310
1311
1313
1314
1316

OPCODE
BA 00 00
B8 FD FF
B9 0F 00
F7 F1
BF 00 15
88 05
47
88 25
47
89 15
CC

MNEMONICS
MOV
MOV
MOV
DIV
MOV
MOV
INC
MOV
INC
MOV
INT

OBSERVATION:

INPUT

OUTPUT

OPERAND
DX,0000
AX,FFFD
CX,000F
CX
DI,1500
[DI],AL
DI
[DI],AH
DI
[DI],DX
3

COMMENTS

RESULT:

Expt.No:3
TO
Date:
LOCATION

TRANSFER OF DATA FROM ONE LOCATION


ANOTHER

AIM:
To write an ALP to Transfer n Datas from one memory location to another.

APPARATUS REQUIRED:
8086 Trainer Kit
ALGORITHM:
1.Intilize the Count value.
2.Load the Acc. algorithm
3.Store the datas to the Destination Address.
4. End The Program.

FLOWCHART :

START

INTILIZE MEMORY
POINTER

INTILIZE COUNT VALUE

TRANSFER TO DESIRED
LOCATION

CL = CL-1

IS
COUN

=
0?

STORE

END

PROGRAM :

ADDRESS
1000
1002
1005
1008
1009
100B
100C
100E
1010

OPCODE MNEMONICS
B1 08
MOV
BE 00 04
MOV
BF 50 14
MOV
AC
LODSB
88 05
MOV
47
INC
FE C9
DEC
75 F8
JNZ
CC
INT

OPERAND
CL,08
SI,1400
DI,1450
[DI],AL
DI
CL
1008
3

OBSERVATION:

INPUT

OUTPUT

COMMENT

RESULT:

Expt.No:4(A)

CODE CONVERSIONS

Date:
(A) ASCII TO HEX CODE:
AIM:
To write an ALP to execute ASCII to HEX code conversion using 8086.
ALGORITHM:
1.
2.
3.
4.
5.

Load the data in al register.


Subtract 30 with al.
If data is less than or equal to 16 terminate the program.
Else subtract 7 from al.
Result in al register.

FLOWCHART:

Start

Load al with the data

Subtract with 30

No

yes

AL=al-7

If
AL<=1
0

Exit

PROGRAM:
ADDRESS
1100
1102
1104
1106
1108
110A

OPCODE
B0 31
2C 30
3C 10
72 04
74 02
2C 07

MNEMONICS
MOV
SUB
CMP
JB
JZ
SUB

OPERAND
AL,31
AL,30
AL,10
110C
110C
AL,07

110C

CC

INT

COMMENTS

OBSERVATION:

INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

DATA

RESULT:

(B) HEXA DECIMAL TO ASCII CODE:


AIM:
To write an ALP to execute Hexa decimal to ASCII code conversion using 8086
microprocessor.
ALGORITHM:
1.
2.
3.
4.

Load al with the data.


If(al<=9) add 30.
Else add 7 and 30.
Result in al.

FLOWCHART:

Start
If
AL<=
Exitthe data
Load al9with

AL=al +07+30

PROGRAM:
ADDRESS

OPCODE

MNEMONICS

OPERA
ND

1100

BO OA

MOV

AL,OA

1102

3C 09

CMP

AL,09

1104

74 04

JZ

110A

1106

72 02

JB

110A

1108

04 07

ADD

AL,07

110A

04 30

ADD

AL,30

110C

CC

INT

COMMENTS

OBSERVATION:
INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

DATA

RESULT:

Expt.No:4 (B)

LARGEST OF n NUMBER IN AN ARRAY

Date:
AIM:
To write an ALP to find the Largest of the data given in an array.
APPARATUS REQUIRED:
8086 Trainer Kit
ALGORITHM:
1.Intilize the Count value.
2.Get the First data.
3.Compare with the next data.
4. Decrement the count till count becomes zero.
5.Store the lagest of the Data.
FLOW CHART:
START

GET THE COUNT VALUE

GET THE DATAS TO BE COMPARED

GET LARGEST IN ACC & DEC.


COUNT

IS
COUN
T = 0?

STORE THE LARGEST

END

PROGRAM :

ADDRESS
1000
1003
1005
1006
1008
100A
100B
100D
100F
1011
1013
1015
1018
101A

OPCODE MNEMONICS
BE 00 90
MOV
8A 0C
MOV
46
INC
8A 04
MOV
FE C9
DEC
46
INC
3A 04
CMP
73 02
JMB
8A 04
MOV
FE C9
DEC
75 F5
JNZ
BF 00 95
MOV
88 05
MOV
CCS
INT 3

OPERAND
SI,9000
CL,[SI]
SI
AL,[SI]
CL
SI
AL,[SI]
1011
AL,[SI]
CL
100A
DI, 9500
[DI],AL

OBSERVATION:
INPUT

OUTPUT

COMMENT

RESULT:

Expt.No:5(A)
ARRAY

ADDITION OF n 16 BIT DATAS IN AN

Date:
AIM:
To write an ALP in 8086 to Add n 16 bit Datas stored in an Array.
APPARATUS REQUIRED:
8086 Trainer Kit.
ALGORITHM:
1.
2.
3.
4.

Load the Count value.


Clear the accumalator.
Add two concecutive datas.
Decrement the counter, till it becomes zero, continue adding the concecutives
datas.
5. Store the Result.
FLOW CHART:
START

GET THE COUNT VALUE & CLEAR


ACCUMALATOR

ADD THE DATA WITH ACCUMALATOR

COUNT
-1 =0?

STORE THE RESULT

END
PROGRAM :

ADDRESS
1300
1302
1304
1306
1308
130A
130C
130E
1311
1313

LABEL

LOOP

MNEMONICS
MOV
MOV
MOV
ADD
INC
DEC
JNZ
MOV
MOV
INT

OPERAND
CL, - AL,00
BL,01
AL,BL
BL
CL
LOOP
DI,2000
[DI],AX
3

B1

B2 B3

B4

COMMENT

OBSERVATION:
INPUT

OUT PUT

RESULT:

Expt.No:5(B)

FACTORIAL OF A DATA

Date:
AIM
To write an ALP in 8086 to find the Factorial of the given Data.

APPARATUS REQUIRED:
8086 Trainer Kit.
ALOGORITHMIS:
1. Load the value.

2. Get 01 in the accumulator.


3. Repeatedly multiply the data .
4. Store the Result.

FLOW CHART:
START

GET THE DATA& AL = 01

DATA = DATA(n) * DATA(n-1)

IF CL -1 =0?

STORE THE RESULT

END

PROGRAM :

ADDRESS
1100
1102
1104
1106
1108
110A
110C
110E
1111
1113

LABEL

LOOP

MNEMONICS
MOV
MOV
MOV
MUL
INC
DEC
JNZ
MOV
MOV
INT 3

OPERAND
CL, 04
AL,01
BL,01
BL
BL
CL
LOOP
DI,2000
[DI],AX

B1

B2 B3

OBSERVATION:

INPUT

OUTPUT

RESULT:

Expt.No:6 (A)

ADDITION OF 3 X 3 MATRIX

Date:
AIM
To write an ALP in 8086 to Add the Data of two 3 x 3 matrix.

B4

COMMENT

APPARATUS REQUIRED:
8086 Trainer Kit.
ALOGORITHMIS:
1.
2.
3.
4.

Load the order of the matrix.


Add the elements of two matrices.
Continue till the count value becomes zero
Store the result.

FLOWCHART :

START

GET THE ORDER OF THE MATRIX AS COUNT VALUE

GET THE ELEMENTS OF EACH MATRIX

ADD THE ELEMENT OF EACH MATRIX

STORE THE RESULT

COUNT = COUNT - 01

IF
COUNT
=O?

END

PROGRAM :

ADDRESS
1500
1502
1505
1508
150A
150C
150E
1510
1511
1512
1514
1516

LABEL

LOOP

MNEMONICS
MOV
MOV
MOV
MOV
MOV
ADD
MOV
INC
INC
DEC
JNZ
INT 3

OPERAND
CL, 09
SI,2000
DI,3000
AL,[SI]
BL,[DI]
AL,BL
[DI],AL
DI
SI
CL
LOOP

B1

B2 B3

B4

COMMENT

OBSERVATION:
INPUT -1

INPUT -2

OUTPUT

RESULT:

Expt.No:6(B)

8086 STRING MANIPULATION FIND AND REPLACE

Date:

A WORD

AIM:
To find and replace a word from a string.

ALGORITHM:
1. Load the source and destination index register with starting and the ending
address respectively.
2. Initialize the counter with the total number of words to be copied.
3. Clear the direction flag for auto incrementing mode of transfer.
4. Use the string manipulation instruction SCASW with the prefix REP to search
a word from string.
5. If a match is found (z=1), replace the old word with the current word in
destination address. Otherwise, stop.

PROGRAM:

ADDRESS

LABEL

MNEMONICS
MOV
MOV
MOV
MOV
MOV
MOV
CLD
REPLACE
SCASW
JNZ
MOV
MOV
LOOP
MOV
INT 21

OPERAND
AX,DATA
DS, AX
AX,15
SI, OFFSET
CX, COUNT
AX, 00

B1

LOOP
DI, LABEL
[DI],REPLACE
AH,4C

OBSERVATION:
INPUT -1

OUTPUT

RESULT:

Expt.No:7
Date:
AIM:

PASSWORD CHECKING

B2 B3

B4

COMMENT

To write an ALP for password checking.

ALGORITHM:
1.Initialize the Memory Pointer.
2.Store the Required password as our wish.
3.Enter the Password
4.IF the entered Password matches with the Stored Password then the Welcome screen
appears on Display
5.Others wise Wrong Password is displayed on the Screen.

FLOW-DIAGRAM:

STARin a specific
Store Initialize
your Password
the
Memory
Pointer
Enter
Password
Memory AddressTthe
ie.1500

No

IF
Match
es

Yes
LCD displays Correct
Password

Enters into Welcome Screen

PROCEDURE:
STEP: 1

LCD displays Wrong


Password

Download the hex file which is given cd.


STEP: 2
Set 4 digit password in address of 1500
STEP: 3
To open welcome screen give 4 digit correct password in address of 1700
STEP: 4
If password match means welcome screen will display in lcd.
Otherwise reenter password in address of1700
OUTPUT:
Set password and user given password matched and enter into welcome screen in lcd
display.
PROGRAM:
ADDRESS
1000
1003
1005

OPCODES
E8 18 01
B5 06
B1 06

MNEMONICS
CALL 111B
MOV CH,06
MOV CL,06

COMMENTS
;Call the LCD initialization
;Initialize the register CH
;Initialize the register CL

1007
100A
100D
100F
1010
1012

BB 00 15
E8 00 00
8A 07
43
FE C9
75 F9

MOV BX, 1500


CALL 100D
MOV AL,[BX]
INC BX
DEC CL
JNE 100D

;Load the Password in the Address 1500


;Call the loop
;Move the value from the BX register to AL
;Increment BX register by 1
;Decrement CL by 1
;Continue until the CL register not equal to zero

1014
1017
101A
101D
101F
1021

BB 00 15
BE 00 17
E8 00 00
8A 04
3A 07
75 7E

MOV BX, 1500


MOV SI, 1700
CALL 101D
MOV AL,[SI]
CMP AL,[BX]
JNE 10A1

;Again move the address 1500 to BX


;Need another address to enter the Password
;Call the Next loop

1023
1024
1025
1027
1029
102C

43
46
FE CD
75 F4
E8 00 00
BA 20 FF

INC BX
INC SI
DEC CH
JNE 101D
CALL 102C
MOV DX,FF20

102F
1031
1032
1035

B0 0C
EE
E8 19 01
B0 43

MOV AL,0C
OUT DX,AL
CALL 114E
MOV AL,43

;Compare each character with the stored Password


;Jump to wrong loop if the character in 'BX'
matches with 'SI'
;Increment BX
;Increment SI
;Decrement CH
;Continue until the CH register not equal to zero
;Choosing PORT A of 8255
;Display ON and cursor OFF
;Call LCD enable
;ASCII value of char 'C' is 43h

1037
1038

EE
E8 23 01

OUT DX,AL
CALL 115E

103B
103D
103E
1041

B0 4F
EE
E8 1D 01
B052

MOV AL,4F
OUT DX,AL
CALL 115E
MOV AL,52

1043

EE

OUT DX,AL

1044

E8 17 01

CALL 115E

;Call LCD data line

1047

B0 52

MOV AL,52

;ASCII value of char 'R' is 52h

1049

EE

OUT DX,AL

104A

E8 11 01

CALL 115E

;Call LCD data line

104D

B0 45

MOV AL,45

;ASCII value of char 'E' is 45h

104F

EE

OUT DX,AL

1050

E8 0B 01

CALL 115E

;Call LCD data line

1053

B0 43

MOV AL,43

;ASCII value of char 'C' is 43h

1055

EE

OUT DX,AL

1056

E8 05 01

CALL 115E

;Call LCD data line

1059

B0 54

MOV AL,54

;ASCII value of char 'T' is 54h

105B

EE

OUT DX,AL

105C

E8 FF 00

CALL 115E

105F

E8 80 00

CALL 10E2

1062

B0 01

MOV AL,01

1064

EE

OUT DX,AL

1065

E8 E6 00

CALL 114E

Call LCD enable line

1068

B0 84

MOV AL,84

;Characters start to print from 4th column of the


first row

106A

EE

OUT DX,AL

106B

E8 E0 00

CALL 114E

Call LCD enable line

106E

B0 0C

MOV AL,0C

;LCD display ON and cursor OFF

1070

EE

OUT DX,AL

1071

E8 DA 00

CALL 114E

Call LCD enable line

1074

B0 57

MOV AL,57

;ASCII value of char 'W' is 57h

1076

EE

OUT DX,AL

1077

E8 E4 00

CALL 115E

;Call LCD data line

107A

B0 45

MOV AL,45

;ASCII value of char 'E' is 45h

107C

EE

OUT DX,AL

107D

E8 DE 00

CALL 115E

;Call LCD data line

1080

B0 4C

MOV AL,4C

;ASCII value of char 'L' is 4Ch

1082

EE

OUT DX,AL

;Call LCD data line


;ASCII value of char 'O' is 4Fh
;Call LCD data line
;ASCII value of char 'R' is 52h

;Call LCD data line


;Clear LCD

1083

E8 D8 00

CALL 115E

;Call LCD data line

1086

B0 43

MOV AL,43

;ASCII value of char 'C' is 43h

1088

EE

OUT DX,AL

1089

E8 D2 00

CALL 115E

;Call LCD data line

108C

B0 4F

MOV AL,4F

;ASCII value of char 'O' is 4Fh

108E

EE

OUT DX,AL

108F

E8 CC 00

CALL 115E

;Call LCD data line

1092

B0 4D

MOV AL,4D

;ASCII value of char 'M' is 4Dh

1094

EE

OUT DX,AL

1095

E8 C6 00

CALL 115E

;Call LCD data line

1098

B0 45

MOV AL,45

;ASCII value of char 'E' is 45h

109A

EE

OUT DX,AL

109B

E8 C0 00

CALL 115E

109E

E8 C1 FF

CALL 1062

10A1

B0 81

MOV AL,81

10A3

EE

OUT DX,AL

10A4

E8 A7 00

CALL 114E

Call LCD enable line

10A7

B0 0C

MOV AL,0C

;LCD display ON and cursor OFF

10A9

EE

OUT DX,AL

10AA

E8 A1 00

CALL 114E

Call LCD enable line

10AD

B0 57

MOV AL,57

;ASCII value of char 'W' is 57h

10AF

EE

OUT DX,AL

10B0

E8 AB 00

CALL 115E

;Call LCD data line

10B3

B0 52

MOV AL,52

;ASCII value of char 'R' is 52h

10B5

EE

OUT DX,AL

10B6

E8 A5 00

CALL 115E

;Call LCD data line

10B9

B0 4F

MOV AL,4F

;ASCII value of char 'O' is 4Fh

10BB

EE

OUT DX,AL

10BC

E8 9F 00

CALL 115E

;Call LCD data line

10BF

B0 4E

MOV AL,4E

;ASCII value of char 'N' is 4Eh

10C1

EE

OUT DX,AL

10C2

E8 99 00

CALL 115E

;Call LCD data line

10C5

B0 47

MOV AL,47

;ASCII value of char 'G' is 47h

10C7

EE

OUT DX,AL

10C8

E8 93 00

CALL 115E

10CB

E8 14 00

CALL 10E2

10CE

E8 9D 00

CALL 116E

;Call the delay function

10D1

E8 9A 00

CALL 116E

;Call the delay function

;Call LCD data line


;Characters start to print from the 2nd column of
the first row

;Call LCD data line

10D4

E8 97 00

CALL 116E

;Call the delay function

10D7

E8 94 00

CALL 116E

;Call the delay function

10DA

E8 91 00

CALL 116E

;Call the delay function

10DD

E8 8E 00

CALL 116E

;Call the delay function

10E0

CD 21

INT 21

10E2

BA 20 FF

MOV DX,FF20

;Choosing PORT A of 8255

10E5

B0 C7

MOV AL,C7

;Characters start to print from the 7th column of the


2nd row

10E7

EE

OUT DX,AL

10E8

E8 63 00

CALL 114E

10EB

B0 50

MOV AL,50

10ED

EE

OUT DX,AL

10EE

E8 6D 00

CALL 115E

;Call LCD data line

10F1

B0 41

MOV AL,41

;ASCII value of char 'A' is 41h

10F3

EE

OUT DX,AL

10F4

E8 67 00

CALL 115E

;Call LCD data line

10F7

B0 53

MOV AL,53

;ASCII value of char 'S' is 53h

10F9

EE

OUT DX,AL

10FA

E8 61 00

CALL 115E

;Call LCD data line

10FD

B0 53

MOV AL,53

;ASCII value of char 'S' is 53h

10FF

EE

OUT DX,AL

1100

E8 5B 00

CALL 115E

;Call LCD data line

1103

B0 57

MOV AL,57

;ASCII value of char 'W' is 57h

1105

EE

OUT DX,AL

1106

E8 55 00

CALL 115E

;Call LCD data line

1109

B0 4F

MOV AL,4F

;ASCII value of char 'O' is 4Fh

110B

EE

OUT DX,AL

110C

E8 4F 00

CALL 115E

;Call LCD data line

110F

B0 52

MOV AL,52

;ASCII value of char 'R' is 52h

1111

EE

OUT DX,AL

1112

E8 49 00

CALL 115E

;Call LCD data line

1115

B0 44

MOV AL,44

;ASCII value of char 'D' is 44h

1117

EE

OUT DX,AL

1118

E8 43 00

CALL 115E

111B

B4 00

MOV AH,00

111D

BA 26 FF

MOV DX,FF26

1120

B0 80

MOV AL,80

1122

EE

OUT DX,AL

1123

BA 20 FF

MOV DX,FF20

;ASCII value of char 'P' is 50h

;Call LCD data line

;Characters start to print from the first column of


the first row
;8255 PORT A DATABITS

1126

B0 38

MOV AL,38

;Function set

1128

EE

OUT DX,AL

1129

E8 22 00

CALL 114E

112C

B0 38

MOV AL,38

112E

EE

OUT DX,AL

112F

E8 1C 00

CALL 114E

1132

B0 38

MOV AL,38

1134

EE

OUT DX,AL

1135

E8 16 00

CALL 114E

1138

B0 0F

MOV AL,0F

113A

EE

OUT DX,AL

113B

E8 10 00

CALL 114E

113E

B0 06

MOV AL,06

1140

EE

OUT DX,AL

1141

E8 0A 00

CALL 114E

1144

B0 01

MOV AL,01

1146

EE

OUT DX,AL

1147

E8 04 00

CALL 114E

114A

E8 01 00

CALL 114E

114D

C3

RET

114E

BA 22 FF

MOV DX,FF22

1151

B0 04

MOV AL,04

1153

EE

OUT DX,AL

1154

B0 00

MOV AL,00

1156

EE

OUT DX,AL

1157

E8 14 00

CALL 116E

115A

BA 20 FF

MOV DX,FF20

115D

C3

RET

115E

BA 22 FF

MOV DX,FF22

1161

B0 05

MOV AL,05

1163

EE

OUT DX,AL

1164

B0 00

MOV AL,00

1166

EE

OUT DX,AL

1167

E8 04 00

CALL 116E

116A

BA 20 FF

MOV DX,FF20

116D

C3

RET

116E

53

PUSH BX

;Store the Values in Stack

116F

BB FF FF

MOV BX,FFFF

;Load the Delay value 0FFFFh in BX register

1172

4B

DEC BX

;Decrement BX register

;Function set

;Function set

;Display ON/OFF

;Entry mode

;Clear screen

;Choosing the PORTB of 8255

;Choosing the PORTB of 8255

1173

75 FD

JNE 1172

;Jump to D1 until BX is not equal to Zero

1175

5B

POP BX

;Get the value from Stack

1176

C3

RET

;Returns the value

Expt.No:8

COUNTERS AND TIME DELAY

Date:
AIM:
To write an ALP for Counter and Time Delay using 8086 Microprocessor.

ALGORITHM:
1. Enter the program into the kit.
2. Connect the PLCK and CLK0 through a wire connector.
3. Now see the output wave form on the OUT0.

PROGRAM:

ADDRESS
1000
1002
1005
1006

OPCODE
B0 36
BA 56 FF
EE
B0 78

MNEMONICS
MOV
MOV
OUT
MOV

OPERAND
AL,36
DX,FF56
DX,AL
AL,78

COMMENTS

1008
100B
100C
100E
100F

RESULT:

BA 50 FF
EE
B0 00
EE
CC

MOV
OUT
MOV
OUT
INT 3

DX,FF50
DX,AL
AL,00
DX,AL

MASAM - PROGRAMS

Expt.No:1 (A) ADDITION OF TWO 16 BIT DATA IN 8086 using


MASAM
Date:
AIM:
To Add two16 bit numbers and to store the result using MASAM.

APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE

16-BIT ADDITION:
.model.small
.data
.code
Start: org 000h
mov ax,06h
mov bx,05h
add ax,bx
int 3
End

OBSERVATION:
INPUT:

DATA1
DATA 2

OUTPUT:

RESULT

Expt.No:1(B) SUBTRACTIONOF TWO 16 BIT DATA IN 8086


using MASAM
Date:
AIM:
To Subtract two16 bit numbers and to store the result using MASAM..

APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE

16-BIT SUBTRACTION:
.model.small
.data
.code
Start: org 000h
mov ax,05h
mov bx,03h
sub ax,bx
int 3
End

OBSERVATION:
INPUT:
DATA1
DATA 2
OUTPUT:

RESULT

Expt.No:2(A)
MASAM

MULTIPLICATION OF TWO 16 BIT DATA USING

Date:
AIM:
To Multiply two16 bit numbers and to store the result using MASAM..

APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
16-BIT MULTIPICATION
.model.small
.data
.code
Start: org 000h
mov ax,03h
mov bx,04h
mul ax,bx
int 3
End

OBSERVATION:
INPUT:
OUTPUT:

DATA1
DATA 2

RESULT:

Expt.No:2(B)

DIVISION OF TWO 16 BIT DATA USING MASM

Date:
AIM:
To Divide two16 bit numbers and to store the result using MASM..

APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
16-BIT DIVISION:
.model.small
.data
.code
Start: org 000h
mov ax,06h
mov bx,05h
mul ax,bx
int 3
End

OBSERVATION:
INPUT:
OUTPUT:

DATA1
DATA 2

RESULT

Expt.No:3

LOGICAL OPERATIONS USING MASM

Date:
AIM:
To perform Logical Operations and store the result using MASM.

APPARATUS REQUIRED:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE

PROGRAM:
AND OPERATION:
.model.small
.data
.code
Start:org 000h
mov al,02h
mov bl,04h
and al,bl
int 3
End

OUTPUT:

OR OPERATION:
.model.small
.data
.code
Start:org 000h
mov al,02h
mov bl,04h
or al,bl
int 3
End
OUTPUT:

NOT OPERATION:
.model.small
.data
.code
Start:org 000h
mov al,01h
not al
int 3
End
OUTPUT:

RESULT:

Expt.No:4
BLOCK TRANSFER WITHOUT OVERLAP
USING MASAM
DAte:
AIM:
To Transfer n 16 bit array from one location to another using MASAM..

PROGRAM:
.MODEL SMALL .DATA
Array1 DW 1111h,2222h,3333h,4444h,5555h
Array2 DW 5 DUP (0)
Count DW 0005H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,Array1
LEA DI,Array2
MOV CX,Count
NEXT: MOV AX,[SI]
MOV [DI],AX
INC SI
INC SI
INC DI
INC DI
LOOP NEXT
MOV AH,4Ch
INT 21h
END
INPUT

OUTPUT

RESULT

Expt.No:5

PASSWORD CHEKING USING MASAM

Date:
AIM:
To Write an ALP to Verify the Password using MASAM
Software Required:
1. Pc with windows (95/98/XP/NT/2000)
2. MASM SOFTWARE
Program:
ASSUME CS:CODE,DS:DATA,ES:EXTRA
DATA SEGMENT
STRING1 DB 'MRCET'
STRLEN EQU ($-STRING1)
SANE DB 'STRINGS ARE UNEQUAL$'
SAE DB 'STRINGS ARE EQUAL$'
DATA ENDS
EXTRA SEGMENT
STRING2 DB 'MRCET'
EXTRA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV SI,OFFSET STRING1
MOV DI,OFFSET STRING2
CLD
MOV CX,STRLEN
REP CMPSB
JZ GO
MOV AH,09H
MOV DX,OFFSET SANE
INT 21H
JMP EXITP
GO: MOV AH,09H
MOV DX,OFFSET SAE
INT 21H
EXITP: INT 03H

CODE ENDS
END START
RESULT

Expt.no:6(A)

ASCENDING / DECENDING ORDER USING MASAM

Date:
AIM:

To Sort n 16 bit array in Ascending / Descending Order using MASAM..


Apparatus Required:

1. Pc with windows (95/98/XP/NT/2000)


2. MASM SOFTWARE

Program:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
ARRAY DB 0500H,0300H,0001H,0004H,0002H
COUNT DB 05H
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
SUB AX,AX
MOV DX,COUNT-1
AGAIN:MOV CX,DX
MOV SI,OFFSET ARRAY
BACK: MOV AX,[SI]
CMP AX,[SI+2]
JBE FORW
XCHG AX,[SI+2]
MOV [SI],AX
FORW: INC SI
INC SI
LOOP BACK
DEC DX
JNZ AGAIN
INT 03H
CODE ENDS
END START
INPUT

OUTPUT

RESULT
Expt.No:6(B)
Date:

SEARCHING USING MASM

AIM:

To search an element in an array using MASM.


APPARATUS REQUIRED:

1. Pc with windows (95/98/XP/NT/2000)


2. MASM SOFTWARE

PROGRAM:
.model.small
.data
.code
Start: org 0000h
Mov DI,1300h
Mov SI,1200h
Mov CL,50h
Mov DL,0ah
Loop1:LODSB
CMP DL,AL
JZ loopz
DEC CL
JNZ loop1
HLT
Loop2:Mov [DI],AL
DEC SI
Mov BX,SI
INC DI
Mov [DI],BL
INC DI
Mov [DI],BL
INPUT
End

OUTPUT

INT 3

RESULT:

Expt.No:7

SQUARE USING MASM

Date:
AIM:
To perform square operation using MASM.
APPARATUS REQUIRED:

1. Pc with windows (95/98/XP/NT/2000)


2. MASM SOFTWARE
PROGRAM:
pu"8051.tbl"
hof"int8"
org 8500h
main:
MOV DPTR, #9000H
MOVX A, @DPTR
MOV R0,A
MOV F0,A
MUL AB
INC DPTR
MOVX @DPTR,A
CLR C
JB 01,LOOP
PUSH F0
MOV F0,A
MOV A,R0
MUL AB
INC DPTR
MOVX @DPTR,A
MOV A,F0
MOV R2,A
POP F0
MOV A,R0
MUL AB
ADD A,R2
LOOP: INC DPTR
MOVX @DPTR,A
MOV A,F0
ADDC A,#00H
INC DPTR
MOVX @DPTR,A

LCALL 00BBh
end
INPUT

OUTPUT

RESULT:

INTERNAL ARCHITECTURE OF 8051


The Intel

MCS-51 (commonly

referred

to

as 8051)

is

a Harvard

architecture, CISCinstruction set, single chip microcontroller (C) series which was
developed by Intelin 1980 for use in embedded systems

Important features and applications

The 8051 architecture provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer,
etc.) in a single package.

8-bit ALU and Accumulator, 8-bit Registers (one 16-bit register with special move
instructions), 8-bit data bus and 216-bit address bus/program counter/data pointer and
related 8/11/16-bit operations; hence it is mainly an 8-bitmicrocontroller

Boolean processor with 17 instructions, 1-bit accumulator, 32 registers (4 bitaddressable 8-bit) and up to 144 special 1 bit-addressable RAM variables (18 bitaddressable 8-bit)

Multiply, divide and compare instructions

4 fast switchable register banks with 8 registers each (memory mapped)

Fast interrupt with optional register bank switching

Interrupts and threads with selectable priority

Dual 16-bit address bus It can access 2 x 2 memory locations 64 KB (65,536


locations) each of RAM and ROM

128 bytes of on-chip RAM (IRAM)

4 KB of on-chip ROM, with a 16-bit (64 KB) address space (PMEM). Not included on
803X variants

Four 8-bit bi-directional input/output port

UART (serial port)

Two 16-bit Counter/timers

Power saving mode (on some derivatives)

One feature of the 8051 core is the inclusion of a boolean processing engine which
allows bit-level boolean logic operations to be carried out directly and efficiently on select
internal registers and select RAM locations. This feature helped cement the 8051's
popularity in industrial control applications because it reduced code size by as much as
30%. Another feature is the inclusion of four bank selectable working register sets which
greatly reduce the amount of time required to complete an interrupt service routine. With a
single instruction the 8051 can switch register banks as opposed to the time consuming
task of transferring the critical registers to the stack or designated RAM locations. These
registers also allowed the 8051 to quickly perform a context switch.Once a UART, and a
timer if necessary, has been configured, the programmer needs only write a simple interrupt
routine to refill the send shift register whenever the last bit is shifted out by the UART and/or
empty the full receive shift register (copy the data somewhere else). The main program then
performs serial reads and writes simply by reading and writing 8-bit data to stacks.

Memory architecture
The MCS-51 has four distinct types of memory internal RAM, special function registers,
program memory, and external data memory.
Internal RAM (IRAM) is located from address 0 to address 0xFF. IRAM from 0x00 to 0x7F
can be accessed directly. IRAM from 0x80 to 0xFF must be accessed indirectly, using the
@R0 or @R1 syntax, with the address to access loaded in R0 or R1. The 128 bits at IRAM
locations 0x200x2F are bit-addressable.
Special function registers (SFR) are located in the same address space as IRAM, at
addresses 0x80 to 0xFF, and are accessed directly using the same instructions as for the
lower half of IRAM. They cannot be accessed indirectly via @R0 or @R1. 16 of the SFRs
are also bit-addressable.
Program memory (PMEM, though less common in usage than IRAM and XRAM) is up to
64 KB of read-only memory, starting at address 0 in a separate address space. It may be
on- or off-chip, depending on the particular model of chip being used. Program memory is
read-only, though some variants of the 8051 use on-chip flash memory and provide a
method of re-programming the memory in-system or in-application. In addition to code, it is
possible to store read-only data in program memory, accessed by the MOVC A, @DPTR
instruction. Data is fetched from the address specified in the 16-bit special function register
DPTR.
External data memory (XRAM) is a third address space, also starting at address 0. It can
also be on- or off-chip; what makes it "external" is that it must be accessed using the MOVX
(Move eXternal) instruction. Many variants of the 8051 include the standard 256 bytes of
IRAM plus a few KB of XRAM on the chip.
The 8051 is designed as a strict Harvard architecture. The 8051 can only execute code
fetched from program memory. The 8051 does not have any instruction to write to program
memory. Most 8051 systems respect this distinction, and so are unable to download and
directly execute new programs. The strict Harvard architecture has the advantage of making
such systems immune to most forms of malware. Some 8051 systems have (or can be
modified to have) some "dual-mapped" RAM, making them act somewhat more
like Princeton architecture. This (partial) Princeton architecture has the advantage of
making it possible for a Forth boot loader running on the 8051 to write new native code to
RAM and then execute it, leading to faster incremental and interactive programming cycles
than strict Harvard systems.

Registers
The only register on an 8051 that is not memory-mapped is the 16-bit program counter PC.
This specifies the address of the next instruction to execute. Relative branch instructions
supply an 8-bit signed offset which is added to the PC.
8 general-purpose registers R0R7 may be accessed with instructions 1 byte shorter than
others. They are mapped to IRAM between 0x00 and 0x1F. Only 8 bytes of that range are
used at any given time, determined by the two bank select bits in the PSW.
The following registers are memory-mapped into the special function register space:
(0x81) Stack pointer SP. This is an 8-bit register used by subroutine call and return

instructions. The stack grows upward; the SP is incremented before pushing, and
decremented after popping a value.
(0x8283) Data pointer DP. This is a 16-bit register that is used for accessing PMEM

and XRAM.

(0xD0) Program status word PSW. This contains important status flags:
PSW.0: P Parity. Gives the parity (modulo-2 sum of the bits of) the most recent ALU
result.
PSW.1: UD User Defined. For general software use, not otherwise used by hardware.
PSW.2: OV Overflow flag. Set when addition produces a signed overflow.
PSW.3: RS0 Register select 0. The low-order bit of the register bank. Set when banks
at 0x08 or 0x18 are in use.
PSW.4: RS1 Register select 1. The high-order bit of the register bank. Set
when banks at 0x10 or 0x18 are in use.
PSW.5: F0 Flag 0. For general software use, not otherwise used by hardware.
PSW.6: AC auxiliary carry. Set when addition produces a carry from bit 3 to bit 4.

PSW.7: C Carry bit.

(0xE0) Accumulator A. This register is used by most instructions.

(0xF0) B register. This is used as an extension to the accumulator for multiply and
divide instructions.

256 single bits are directly addressable. These are the 16 IRAM locations from 0x200x2F,
and the 16 special function registers 0x80, 0x88, 0x90, ,0xF8. Any bit of these bytes may
be directly accessed by a variety of logical operations and conditional branches.
Note that the PSW does not contain the common N (negative) and Z (zero) flags. Instead,
because the accumulator is a bit-addressable SFR, it is possible to branch on its most
significant bit directly. There is also an instruction to jump if the accumulator is zero or nonzero.

8051 - PROGRAMS

Expt.No:1(A)

ADDITION OF TWO 8 BIT DATA IN 8051

Date:
AIM:
To write an ALP in 8051 to Add two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be added in microcontroller.
3. Add the data and store the sum.
4. Check for the carry and store the carry also.
FLOW CHART:
START

INTIALIZE DATA POINTER

GET THE DATAS TO BE ADDED

ADD THE DATAS

STORE THE SUM

STORE CARRY

END

PROGRAM:

ADDRESS
4100
4103
4104
4105
4106
4107
4108
4109
410A
410C
410E
410F
4110

LABEL

MNEMONICS
MOV
MOVX
MOV
INC
MOVX
ADD
INC
MOVX
MOV
ADDC
INC
MOVX
LCALL

OPERAND
DPTR,#9000
A, @DPTR
R0,A
DPTR
A, @DPTR
A, R0
DPTR
@DPTR,A
A,# 00
A, #00
DPTR
@DPTR, A
00BB

OBSERVATION:

INPUT

RESULT:

OUTPUT

B1

B2 B3

COMMENT

Expt.No:1(B)

SUBRACTION OF TWO 8 BIT DATA IN 8051

Date:
AIM:
To write an ALP in 8051 to Add two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be added in microcontroller.
3. subtract the data and store the sum.
4. Check for the carry and store the carry also.
FLOW CHART:
START

INTIALIZE DATA POINTER

GET THE DATAS TO BE SUBTRACTED

SUBTRACT THE DATAS

STORE THE DIFFERENCE

END

PROGRAM :

ADDRESS
4100
4103
4104
4105
4106
4107
4108
4109
4110

LABEL

MNEMONICS
MOV
MOVX
MOV
INC
MOVX
SUB
INC
MOVX
LCALL

OPERAND
DPTR,#9000
A, @DPTR
R0,A
DPTR
A, @DPTR
A, R0
DPTR
@DPTR,A
00BB

OBSERVATION:

INPUT

RESULT:

OUTPUT

B1

B2 B3

COMMENT

Expt.No:2(A)

MULTIPLICATION OF TWO 8 BIT DATA IN 8051

Date:
AIM:
To write an ALP in 8051 to Multiply two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be multiplied in microcontroller.
3. Multiply two datas and store the quotient and remainder.
4. Check for the carry and store the carry.
FLOW CHART:
START

INTIALIZE DATA POINTER

GET THE DATAS TO BE MULTIPLIED

MULTIPLY THE DATAS

STORE THEPRODUCT

END

PROGRAM:

ADDRESS
4100
4103
4104
4106
4107
4108
4109
410A
410B
410C
410E
411F

LABEL

MNEMONICS
MOV
MOVX
MOV
INC
MOVX
MUL
INC
MOVX
INC
MOV
MOVX
LCALL

OPERAND
DPTR,#9000
A, @DPTR
F0,A
DPTR
A, @DPTR
AB
DPTR
@DPTR,A
DPTR
A,FO
@DPTR,A
00BB

B1

B2 B3

COMMENT

OBSERVATION:
INPUT

OUTPUT

RESULT:

Expt.No:2(B)

DIVISION OF TWO 8 BIT DATA IN 8051

Date:
AIM:
To write an ALP in 8051 to Divide two 8 bit Data.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data to be divided in microcontroller.
3. Divide the data and store the Quotient.
4. Store the Remainder also.
FLOW CHART:
START

INTIALIZE DATA POINTER

GET THE DATAS TO BE DIVIDED

DIVIDE THE DATAS

STORE THE QUOTIENT &


REMAINDER

END

PROGRAM:

ADDRESS
4100
4103
4104
4106
4107
4108
4109
410A
410B
410C
410E
411F

LABEL

MNEMONICS
MOV
MOVX
MOV
INC
MOVX
DIV
INC
MOVX
INC
MOV
MOVX
LCALL

OPERAND
DPTR,#9000
A, @DPTR
F0,A
DPTR
A, @DPTR
AB
DPTR
@DPTR,A
DPTR
A,FO
@DPTR,A
00BB

B1

B2 B3

COMMENT

OBSERVATION:
INPUT

OUTPUT

RESULT:

Expt.No:3

LOGICAL OPERATIONS OF 8051

Date:
AIM:
To write an ALP for logical operations using 8051 Microcontroller.

ALGORITHIMS:
1. Initialize the Register A and Register B.
2. Get the datas for performing logical operations in microcontroller.
3. Perform AND,OR and EX-OR operations.
4. For AND multiply the datas.
5. For OR add the datas.
6. Store the datas.

AND PROGRAM:
ADDRESS
9000
9001
9002

MNEMONICS
MOV
MOV
ANL

OPERAND
A,#02
B,#04
AB

9003

LCALL

00BB

COMMENTS

OBSERVATION:
INPUT
ADDRESS
DATA

OUTPUT
ADDRESS
DATA

OR PROGRAM:
ADDRESS
9000
9001

MNEMONICS
MOV
MOV

OPERAND
A,#02
B,#04

COMMENTS

9002
9003

ORL
LCALL

A,B
00BB

OBSERVATION:
INPUT
ADDRESS
DATA

OUTPUT
ADDRESS
DATA

EX-OR:
ADDRESS
9000
9001
9002
9003

MNEMONICS
MOV
MOV
XRL
LCALL

OPERAND
A,#02
B,#04
A,B
00BB

OBSERVATION:
INPUT
ADDRESS
DATA

OUTPUT
ADDRESS
DATA

COMMENTS

RESULT:

Expt.No:4

1's AND 2's COMPLEMENT

Date:
(A).1's COMPLEMENT:
AIM:
To write an ALP for 1's complement using 8051 Microcontroller.
ALGORITHIM:
1. Initialize the Accumalator.
2. Get the data to be 1's complemented in microcontroller.
3. Complement the data in the Accumalator.
4. Store the result in the Accumalator .

PROGRAM:
ADDRESS
9000
9001
9002

MNEMONICS
MOV
CPL
LCALL

OPERAND
A,#02
A
00BB

COMMENTS

OUTPUT:
INPUT

OUTPUT

ADDRESS

DATA

ADDRESS

DATA

(B).2's COMPLEMENT:
AIM:
To write an ALP 2's complement using 8051 Microcontroller.
ALGORITHIMS:
1. Initialize the Data Pointer.
2. Get the data.
3. Complement the Accumulator and add 01.
4. Store the result in the Accumulator.
PROGRAM:
DATA
ADDRESS
9000
9001
9002
9003
9004
9005
9006

MNEMONICS
MOV
MOV
CPL
ADD
MOV
MOVX
LCALL

OPERAND
DPTR,#9500
A,@DPTR
A
A,#01
DPTR,#9500
@DPTR,A
00BB

COMMENTS

OUTPUT:
INPUT
ADDRESS

OUTPUT
DATA

ADDRESS

DATA

RESULT:

5 CODE CONVERSION
ASCII TO HEXA DECIMAL CONVERSION:
AIM:
To perform ASCII to hexadecimal conversion.
ALGORITHM:
1.
2.
3.
4.
5.

Load the data in al register.


Subtract 30 with al.
If data is less than or equal to 16 terminate the program.
Else subtract 7 from al.
Result in al register.

PROGRAM:
ADDRESS

MNEMONICS

OPERAND

9000

MOV

DPTR,#9500

9003

CLR

9004

MOVX

A,@DPTR

9005

SUBB

A,#30

9007

MOV

R1,A

9008

SUBB

A,#0A

900A

JC

9011

900C

CLR

900D

MOV

A,R1

900E

SUBB

A,#07

9010

MOV

R1,A

9011

MOV

A,R1

9012

LCALL

00BB

COMMENTS

OBSERVATION
INPUT
ADDRESS

RESULT:

OUTPUT
DATA

ADDRESS

DATA

INTERFACING
PROGRAMS

Expt.No:1
Date:

DIGITAL CLOCK

AIM:
To write an ALP for Digital Clock.

ALGORITHM:
1.Load the data Hrs,Mins and Sec in Different Memory Registers.
2.Initialize Hr ,Min and Sec.
3.INC Seconds until 59.If it is greater than 59 then the Minute starts incremented by 1 and
the Seconds are initialized to Zero.
4.If minute is greater than 59,then the hour starts incremented by 1 and the Minutes and
Seconds are initialized to Zero.
5.When the hour is greater than 12, then the Seconds and Minutes are initialized to Zero. And
then the Hour is initialized to One.
6. Again the clock starts from

FLOW CHART:
START
Initialize the Memory Pointers for Hr,Min and Sec
Load the data in three Memory
Registers
Initialize Hr
Initialize Min

Loop starts
again

Initialize Sec

Inc Sec

No

If Sec
<=59

Yes

Inc Min

No

If Min
<=59

Inc Hr

If Hr <=
12

Yes

No

Yes

PROGRAM:
ADDRESS

COMMENTS

0000

OPCODES MNEMONICS
E8 B2 00
CALL 00B5

Call the LCD initialization

0003

30 30

Declaring the variables in Bytes.

0005

30 30

0007

0013

31 B3 00
B7
00 B1 00
B5
00 BA 20
FF
B0 0C

XOR
[BX+SI],DH
XOR
[BX+SI],DH
XOR
[BP+DI+B700]
ADD
[BX+DI+B500]
ADD
[BP+SI+FF20]
MOV AL,0C

0015

EE

OUT DX,AL

0016

E8 CF 00

CALL 00E8

0019

BE 00 15

MOV SI, 1500

001C

AC

LODSB

001D

2E A2 05

0021

AC

MOV
[0005],AL
LODSB

0022

8A E0

MOV AH,AL

Load the 2nd digit of an Hr value in to an


Accum.
Move the Hr value from an Accum. to AH

0024

AC

LODSB

Load the new value in to an Accum.

0025

2E A2 06

Move the value from an Accum. to var4

0029

AC

MOV
[0006],AL
LODSB

002A

2E A2 03

Move the value from an Accum. to var 1

002E

AC

MOV
[0003],AL
LODSB

002F

8A E8

MOV CH,AL

0031

AC

LODSB

Move/Store the value from an Accum. to the


Register CH
Load the 2nd digit of Minutes in to an Accum.

0032

8A F8

MOV BH,AL

000B
000F

Move the hex value 0Ch to an Accum. for the


Curser Off and Display ON in LCD
And Output/Send the Accum. value in to
LCD
Call the LCD Command Enable initialization
Define the initial Address for getting the
values
Load the 1st digit of an Hr value in to an
Accum.
Move the Hr value from an Accum. to var3

Load the new Value in to an Accum.

Load the 1st digit of Minutes in to an Accum.

Move/Store the value from an Accum. to the


Register BH

0034

AC

LODSB

Load the 1st digit of Seconds in to an Accum.

0035

8A C8

MOV CL,AL

0037

AC

LODSB

Move/Store the value from an Accum. to the


Register CL
Load the 2nd digit of Seconds in to an Accum.

0038

8A D8

MOV BL,AL

003A

EB 19

JMP 0055

003C

90

NOP

003D
0043

2E C6 06
05
2E A0 05

0047

B4 31

0049
004F

2E C6 06
03
B5 30

0051

B7 30

0053

B1 30

0055

E8 B0 00

MOV
Initialize var3(ie.var3 = 0 for the hex value
B[0005],30
30h )
MOV AL,[0005] Move/Store the value of the variable to an
Accum.
MOV AH,31
Initialize the Register AH = 1( ie the hex value
of 31h)
MOV
Initialize the Register AH = 1( ie the hex value
B[0003],31
of 31h)
MOV CH,30
Initialize the Register CH = 0( ie.the hex value
of 30h )
MOV BH,30
Initialize the Register BH = 0( ie.the hex value
of 30h)
MOV CL,30
Initialize the Register CL = 0( ie.the hex value
of 30h)
CALL 0108
Call the part section

0058

B3 30

MOV BL,30

005A

8A C3

MOV AL,BL

005C

EE

OUT DX,AL

005D

E8 98 00

CALL 00F8

Initialize the Register BL = 0( ie.the hex value


of 30h)
Move/Store the value of the variable from the
Register BL to an Accum.
Output/Send the value of AL through the
Data ports of LCD
Call the LCD Data Enable initialization

0060

E8 A5 00

CALL 0108

Call the part section

0063

FE C3

INC BL

Increment the Register BL by 1

0065

8A C3

MOV AL,BL

0067

EE

OUT DX,AL

0068

E8 8D 00

CALL 00F8

Move/Store the value of the variable from the


Register BL to an Accum.
Output/Send the value of AL through the
Data ports of LCD
Call the LCD Data Enable initialization

006B

80 FB 39

CMP BL,39

Compare the value 39 with the Register BL

006E

75 F0

JNE 0060

Jump to loop2 when it is not equal to Zero

0070

FE C1

INC CL

Increment the Register CL by 1

0072

80 F9 36

CMP CL,36

Compare the value 36 with the Register CL

0075

75 DE

JNE 0055

Jump to loop 1 when the register CL does not


match with 36

Move/Store the value from Accum. to the


Register BL
Jump to loop1 if the condition is equivalent to
Zero

0077

FE C7

INC BH

Increment the Register BH by 1

0079

80 FF 3A

CMP BH,3A

Compare the value 3A with the Register BH

007C

75 D5

JNE 0053

007E

FE C5

INC CH

Jump to loop 3 when the register BH does not


match with 3A
Increment the Register CH by 1

0080

80 FD 36

CMP CH,36

Compare the value 36h with the Register CH

0083

75 CC

JNE 0051

Jump to loop 4 when the register BH does not


match with 36

0085

2E FE 06
03
FE C4

INC B[0003]

2E 80 3E
03
76 BB

CMP
B[0003],39
JBE 004F

2E C6 06
05
2E 8A 26
06
2E FE 06
06
2E 80 3E
06
76 A3

MOV
B[0005],31
MOV AH,
[0006]
INC B[0006]

00B2

2E C6 06
00
06

MOV
B[0000],00
PUSH ES

00B3

89 CC

MOV SP,CX

00B5

B4 00

MOV AH,00

00B7

BA 26 FF

MOV DX,FF26

Control port of 8255

00BA

B0 80

MOV AL,80

Starting Location of LCD

00BC

EE

OUT DX,AL

Output/Send the value of AL through the


Data ports of LCD

00BD

D4

DB 04

00BE

20 FF

AND BH,BH

00C0

B0 38

MOV AL,38

For choosing 16x2 LCD

00C2

EE

OUT DX,AL

00C3

E8 03 00

CALL 00C9

Output/Send the value of AL through the


Data port of LCD
Call the LCD Command Enable initialization

00C6

B0 38

MOV AL,38

For choosing 16x2 LCD

00C8

EE

OUT DX,AL

Output/Send the value of AL through the

008A
008C
0092
0094
009A
009F
00A4
00AA
00AC

INC AH

CMP
B[0006],33
JBE 004F

Increment the Register AH by 1

Jump to loop5 when the value of the variable


below or equal to 39h

Increment the value of the variable var4 by 1


Compare the value 33h with the value of the
variable var4
Jump to loop5 when the value of the variable
below or equal to 39h

Data port of LCD


00C9

E8 1C 00

CALL 00E8

00CC

B0 38

MOV AL,38

For choosing 16x2 LCD

00CE

EE

OUT DX,AL

00CF

E8 16 00

CALL 00E8

Output/Send the value of AL through the


Data port of LCD
Call the LCD Command Enable initialization

00D2

B0 0F

MOV AL,0F

00D4

EE

OUT DX,AL

00D5

E8 10 00

CALL 00E8

00D8

B0 06

MOV AL,06

00DA

EE

OUT DX,AL

00DB

E8 0A 00

CALL 00E8

Output/Send the value of AL through the


Data port of LCD
Call the LCD Command Enable initialization

00DE

B0 01

MOV AL,01

Command for clearing the LCD display

00E0

EE

OUT DX,AL

00E1

E8 04 00

CALL 00E8

Output/Send the value of AL through the


Data port of LCD
Call the LCD Command Enable initialization

00E4

E8 01 00

CALL 00E8

Call the LCD Command Enable initialization

00E7

C3

RET

Return from Procedure or Function

00E8

BA 22 FF

MOV DX,FF22

Choosing the PORTB of 8255

00EB

B0 04

MOV AL,04

00ED

EE

OUT DX,AL

00EE

B0 00

MOV AL,00

00F0

EE

OUT DX,AL

00F1

E8 49 00

CALL 013D

00F4

BA 20 FF

MOV DX,FF20

Choosing the PORTA of 8255

00F7

C3

RET

Return from Procedure or Function

00F8

BA 22 FF

MOV DX,FF22

Choosing the PORTB of 8255

00FB

B0 05

MOV AL,05

00FD

EE

OUT DX,AL

00FE

B0 00

MOV AL,00

0100

EE

OUT DX,AL

0F Command for the Display ON and Curser


blinking
Output/Send the value of AL through the
Data port of LCD
Output/Send the value of AL through the
Data port of LCD
06 for the Entry mode of LCD

Output/Send the value of AL through the


Data port of LCD
Output/Send the value of AL through the
Data port of LCD

Output/Send the value of AL through the


Data port of LCD
Output/Send the value of AL through the
LCD Data

0101

E8 39 00

CALL 013D

0104

BA 20 FF

MOV DX,FF20

Choosing the PORTA of 8255

0107

C3

RET

Return from Procedure or Function

0108

BA 20 FF

MOV DX,FF20

010B

B0 C0

MOV AL,C0

Command for choosing the 2nd Row of LCD

010D

EE

OUT DX,AL

010E

E8 D7 FF

CALL 00E8

Output/Send the value of AL through the


Data port of LCD
Call the LCD Command initialization

0111

2E A0 05

0115

EE

0116

E8 DF FF

MOV AL,[0005] Move/Store the value of the variable var3 in to


an Accum
OUT DX,AL
Output/Send the value of AL through the
Data port of LCD
CALL 00F8
Call the LCD Data mode initialization

0119

8A C4

MOV AL,AH

011B

EE

OUT DX,AL

011C

E8 D9 FF

CALL 00F8

011F

B0 3A

MOV AL,3A

0121

EE

OUT DX,AL

0122

E8 D3 FF

CALL 00F8

0125

8A C5

MOV AL,CH

0127

EE

OUT DX,AL

0128

E8 CD FF

CALL 00F8

012B

8A C7

MOV AL,BH

012D

EE

OUT DX,AL

012E

E8 C7 FF

CALL 00F8

0131

B0 3A

MOV AL,3A

0133

EE

OUT DX,AL

0134

E8 C1 FF

CALL 00F8

0137

8A C1

MOV AL,CL

0139

EE

OUT DX,AL

013A

E8 BB FF

CALL 00F8

Move the value of the Register AH in to an


Accum
Output/Send the value of AL through the
Data port of LCD
Call the LCD Data mode initialization
The character of the ASCII value 3A is
:(colon)
Output/Send the value of AL through the
Data port of LCD
Call the LCD Data mode initialization
Move/Store the value of the Register CH into
an Accum
Output/Send the value of AL through the
Data port of LCD
Call the LCD Data mode initialization
Move/Store the value of the Register BH into
an Accum
Output/Send the value of AL through the
Data port of LCD
Call the LCD Data mode initialization
The character of the ASCII value 3A is
:(colon)
Output/Send the value of AL through the
Data port of LCD
Call the LCD Data mode initialization
Move/Store the value of the Register CL into
an Accum
Output/Send the value of AL through the
Data port of LCD
Call the LCD Data mode initialization

013D

53

PUSH BX

013E

BB FF 3F

MOV BX,3FFF

0141

4B

DEC BX

0142

75 FD

JNE 0141

0144

5B

POP BX

0145

C3

RET

Load the value to the Reg BX for setting the


Delay.
Decrement the Register BX by 1
Jump to D1 loop when the value of BX does
not match with the value 5FFF
Return from Procedure or Function

Example : 1
INPUT :
For the clock below 10
1500 -> var3 ---> 30h
1501 -> AH ---> Required time below 10 (ie. from 0 to 9)
1502 -> var4 ---> 30h
1503 -> Assign AH to var1
1504 ->
CH ---> 35h
1505 ->
BH ---> 36h
1506 ->
CL ---> 35h
1507 ->
BL ---> 30h
OUTPUT :

Hours
Var3 AH
0
9

Minutes
CH BH
5 6

Seconds
CL BL
5 0

Example : 2
INPUT :
For the clock Above 10
1500 ->
var3 ---> 31h
1501 -> AH --->Required time above or equal to 10 (ie. from 0 to 2)
1502 ->
var4 = AH + 1
1503 ->
var1 = 39h;
1504 ->
CH ---> 35h
1505 ->
BH ---> 36h
1506 ->
CL ---> 35h
1507 ->
BL ---> 30h

Hours
Var3 AH
1
1

Expt.No: 2
Date:

Minutes
CH BH
5 6

Seconds
CL BL
5 0

OUTPUT :

PROGRAM TO INTERFACE
A) -ANALOG TO DIGITAL CONVERTOR (ADC)
B)-DIGITAL TO ANALOG CONVERTOR ( DAC)

Program (A):
AIM:

To Write an ALP to Interface8086 Processor with the Analog to Digital


Convertor (ADC) Interface Board.

s
APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. ADC Interface Board.
3. Power Card.
ALGORITHM:

1. Start the program.


2. Connect the 50 Pin connector from 8086 kit to ADC Card.
3. Execute the ADC program.
4. Vary the port in the ADC Card.
5. View the Output in the LCD Display.
6. Repeat the experiment for various value.

FLOW CHART:

START

CONFIGURE THE PORTS

GET THE ANALOG DATA

EXECUTE THE PROGRAM

GET THE DIGITAL OUTPUT

STOP

GET THE COUNT

DECREMENT THE COUNT

ZER
O?

RETURN

PROGRAM:

OBSERVATION:

ADDRESS
2E00

LABEL

PGM - A

S. NO

RESULT:

MNEMONICS
MOV
MOV
OUT
MOV
MOV
OUT
MOV
OUT
CALL
MOV
IN
INT 3
MOV
NOP
NOP
DEC
JNE
RET

OPERAND
DX, FF56
AL, 90
DX, AL
DX, FF54
AL, FF
DX, AL
AL, FF
DX, AL
PGM -A
DX, FF50
AL, DX

B1

CX, 0FFF
CX
LOOP

ANALOG VALUE

DIGITAL VALUE

(volts)

(volts)

B2 B3

COMMENT

Program (B):
AIM:
To Write an ALP to Interface8086 Processor with the Digital to Analog
Convertor (DAC) Interface Board.

APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. DAC Interface Board.
3. Power Card.

PROGRAM:

ADDRESS
3000

LABEL

300C

S. NO

MNEMONICS
MOV
MOV
OUT
MOV
MOV
OUT
INT 3

OPERAND
DX, FF56
AL, 80
DX,AL
DX, FF52
AL, 00
DX,AL

B1

DIGITAL VALUE

ANALOG VALUE

(volts)

(volts)

OBSERVATION:

B2 B3

COMMENT
Move Central Reg. Addr.
Control Word

Out in Port B

RESULT:

Expt.No: 3
Date:

DISPLAY INTERFACE PROGRAM USING 8279


ACCEPTING A KEY

AIM:
To Write an ALP to Interface8086 Processor with the 8279 Interface Board to Accept a
Key.

APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. Display Interface Board.
ALGORITHM:

1. Start The Program.


2. Load the data in Memory Location.
3. Move the control word to A REG.
4. Get the Hexa equivalent of the data to be displayed.

FLOW CHART:

START

LOAD THE MEMORY LOCATION

INTITILIZE CONTROL WORD REGESTER

DISPLY THE DATA

EVEN ?

STOP

PROGRAM:

ADDRESS

LABEL

LOOP

MNEMONICS
MOV
MOV
OUT
MOV
OUT
MOV
OUT
IN
AND
JE
MOV
IN
AND
INT 3

OPERAND
AL,12
DX,FF52
DX,AL
AL,3E
DX,AL
AL,A0
DX,AL
AL,DX
AL,07
LOOP
DX,FF50
AL,DX
AL,3F

B1

B2 B3

COMMENT

OUTPUT:

INPUT

OUTPUT

RESULT:

Expt.No:4
Date:

DISPLAY INTERFACE PROGRAM USING 8279


DISPLAY A LETTER

AIM:
To Write an ALP to Interface8086 Processor with the 8279 Interface Board to Display a
Character.

APPARATUS REQUIRED:
1. 8086 Trainer Kit
2. Display Interface Board.

FLOW CHART:

START
START

LOAD THE COUNT VALUE

GET CONTROL WORD REGESTER

LOAD THE VALUE IN C & B REG.

DECREMENT C - REG

CALL DELAY
CHEC
K
ZERO?

DECREMENT THE COUNTER


DECREMENT B REG.

CHEC
K
ZERO?

IF
ZERO ?

RETURN TO MAIN PGM

ADDRESS

LABEL

LOOP 1

MNEMONICS
MOV
MOV
OUT
MOV
OUT
MOV
OUT
MOV
MOV
MOV
OUT
DEC

OPERAND
AL, 12
DX, FF52
DX, AL
AH, AL
DX, AL
AH, AL
DX, AL
AH, 0B
DX, FF50
AL, 00
DX, AL
AH

B1

B2 B3

COMMENT

LOOP 2

JNZ
MOV
MOV
MOV
MOV
OUT
INC
DEC
JNZ
INT 3

LOOP 1
DX, FF50
CL, 06
BX, 2000
AX, [BX]
DX, AL
BX
CL
LOOP 2

PROGRAM:

a b c d e f g h Hexa
Equivalent
OUTPUT :

RESULT:

Expt.No:5

PROGRAM TO INTERFACE STEPPER MOTOR

Date:
AIM:
To Write an ALP to Interface8086 Processor with the Stepper Motor Interface Board to
rotate in Forward & Backward Directions and to Control its Speed.

APPARATUS REQUIRED:

1.8086 Trainer Kit


2. Stepper Motor Interface Board.
3. Stepper Motor.
4. Power Card.
ALGORITHM:

1. Start the program.


2. Call Rotate forward.
3. Call Delay Program.
4. Call Rotate Backward.
5. Call Delay Program.
6. Repeat the steps.

FLOWCHART:
START
START

INTILIZE

CALL ROTATE

GET STOP COUNT

DECREMENT
CALL DELAY

CALL ROTATE

ZERO
?

CALL DELAY
RETURN

PROGRAM :

ADDRESS

LABEL

ROTATE

MNEMONICS
MOV
MOV
OUT
MOV
MOV

OPERAND
DX, FF26
AL, 80
DX, AL
DX, FF20
AL, 80

B1

B2 B3

COMMENT

DELAY

TABULATION :

OUT
CALL
MOV
OUT
CALL
MOV
OUT
CALL
MOV
OUT
CALL
JMP
MOV
MOV
NOP
NOP
NOP

DX, AL
DELAY
AL, CO
DX, AL
DELAY
AL, E0
DX, AL
DELAY
AL, A0
DX, AL
DELAY
ROTATE
BX, 0010
AX, 00FF

CLOCKWISE

ANTICLOCKWISE

RESULT:

Expt.No:6

PROGRAM TO INTERFACE TRAFFIC LIGHT

Date:

CONTROLLER

AIM:
To Write an ALP to Interface Traffic Light Controller using 8086.
APPARATUS REQUIRED:
1. 8086Trainer Kit
2. Traffic light controller Interface Board.
3. Power Card.
ALGORITHM
1.
2.
3.
4.
5.

Start the Program.


Call forward program.
Call left program.
Call right program.
Repeat the steps.

ADDRESS
9500
9505

LABEL
LOOP

MNEMONICS
MOV
MOV
OUT
MOV
MOV
OUT
MOV
MOV
OUT
CALL
MOV
MOV
OUT
MOV
MOV
OUT
CALL
MOV
MOV
OUT
MOV
MOV
OUT
CALL
MOV
MOV
OUT
MOV
MOV
OUT
CALL

OPERAND
DX, FF26
AL, 81
DX, AL
DX, FF20
AL, CC
DX, AL
DX, FF22
AL, 11
DX, AL
9544
DX, FF20
AL, AA
DX, AL
DX, FF22
AL, AA
DX, AL
9555
DX, FF20
AL, 11
DX, AL
DX, FF22
AL, CC
DX, AL
9544
DX, FF20
AL, AA
DX, AL
DX, FF22
AL, AA
DX, AL
9555

B1

B2 B3

COMMENT

CALL DELAY 1

CALL DELAY 2

CALL DELAY 1

CALL DELAY 2

JMP

9505

PROGRAM:

ADDRESS
9544

9554
9555

9565

LABEL
DELAY 1
LOOP 1
LOOP 2

DELAY 2
LOOP 3
LOOP 4

MNEMONICS
MOV
MOV
NOP
NOP
NOP
NOP
DEC
JNZ
DEC
JNZ
RET
MOV
MOV
NOP
NOP
NOP
NOP
DEC
JNZ
DEC
JNZ
RET

OPERAND
BX, 00FF
AL, FF

AL
9549
BX
9547

B1

B2 B3

COMMENT

JUMP LOOP 2
JUMP LOOP 1

BX, 1000
AL, FF

AL
955A
BX
9558

JUMP LOOP 4
JUMP LOOP 3

OUTPUT :

INPUT

OUTPUT

RESULT:

Expt.No:7

7 PRINTER INTERFACING THROUGH 8255

Date:
AIM:
To write an ALP for Printer Interfacing through 8255.

ALGORITHM :
1.
2.
3.
4.

Initialize the Pointer to memory for data and the result.


Load the data in al register from the memory.
Compare the value of an accumulator with the value 0D.
N-number of characters can be sent to printer through 8255 ports until it doesnt
match with the value0D.
5. This loop continues until it matches with 0D.
6. Loop exits ,when the character matches with 0D.

FLOW -DIAGRAM :
Start
ssssssss
ssSSST
ART
Initialize the Memory pointer

Load the characters in the


Accumulator
Again

Yes

No
if al ==
0D

No
Send the character to
printer through 8255 ports

EXIT

PROGRAM :

ADDRESS OPCODES
0000
BA 26 FF
0003
0005

B0 82
EE

0006
0009
000B

BE 00 18
B0 07
BA 24 FF

000E

EE

000F
0012
0014

E8 0A 00
8A 04
3C 0D

0016

75 01

0018
0019

CC
46

001A

EB F3

001C

BA 22 FF

001F
0020

EC
D0 C8

0022

D0 C8

0024
0026
0028

72 F6
8A 04
BA 20 FF

002B
002C
002E

EE
B0 04
BA 24 FF

0031
0032
0033
0034
0036
0037

EE
90
90
B0 05
EE
C3

OBSERVATION:

MNEMONICS
COMMENTS
MOV
Initialize 8255 address
DX,FF26
MOV AL,82
Continuous word for port b & c o\p
OUT DX,AL
Output/Send the value of AL through
the Data ports of 8255
MOV SI, 1800 Starting address for message string
MOV AL,07
strobe high at low and high
MOV
Choosing Port C
DX,FF24
OUT DX,AL
Output the value of AL through Port
C of 8255
CALL 001C
Call one character
MOV AL,[SI] Put to AL
CMP AL,0D
Compare the character with 0D
Jump to a loop to print the character if
JNE 0019
AL doesnt match with 0D.When the
value of AL matches with 0D then loop
gets terminated.
INT3
Stops printing
INC SI
Increment the source index for getting
the next char.
JMP 000F
Again it goes to the loop for getting
another character.
MOV
Choosing Port B
DX,FF22
IN AL,DX
For getting printer status
ROR AL, 1
get two bits to right to get port b
status(busy)
ROR AL, 1
get two bits to right to get port b
status(busy)
JB 001C
wait if busy
MOV AL,[SI] get char from message string
MOV
put the data to printer
DX,FF20
OUT DX,AL
output the value of AL to printer
MOV AL,04
make strobe low to indicate
MOV
byte is loaded
DX,FF24
OUT DX,AL
NOP
Wait for few seconds(ie.delay)
NOP
MOV AL,05
strobe back to high
OUT DX,AL
RET
Return from Procedure or Function

INPUT:
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809

Enter the datas in the consecutive location starting from 1800.


:
:
:
:
:
:
:
:
:
:

41h
42h
43h
44h
45h
46h
47h
48h
49h
0Dh

(Ascii value of character A)


( B)
( C )
( D)
( E)
( F )
( G)
( H)
( I )

OUTPUT : Printer can print like this.


ABCDEFGHI

RESULT:

Expt.No:8

PARALLEL INTERFACE

Date:
AIM:
To write an ALP for Parallel Interface using 8086 Microprocessor.
ALGORITHM:
1. Start the Program.
2. Call for the program.
3. Repeat the steps.

PROGRAM FOR 8086:

RECEIVER PROGRAM:
ADDRESS
9000
9003
9005
9006
9009
900A
900C
900F
9010
9012
9015
9016

OPCODE
BA 26 FF
B0 9B
EE
BA 24 FF
EC
88 C1
BA 22 FF
EC
88 C3
BA 20 FF
EC
CC

MNEMONICS OPERAND
MOV
DX,FF26
MOV
AL,9B
OUT
DX,AL
MOV
DX,FF24
IN
AL,DX
MOV
CL,AL
MOV
DX,FF22
IN
AL,DX
MOV
BL,AL
MOV
DX,FF20
IN
AL,DX
INT
3

COMMENTS

TRANSMITTER PROGRAM:
ADDRESS
9100
9103
9105
9106
9109
910C
910E
910F
9112
9115
9117
9118
911B
911E
9120
9121
9124

OPCODE
BA 26 FF
B0 80
EE
E8 1C 00
BA 20 FF
B0 FF
EE
E8 13 00
BA 22 FF
B0 22
EE
E8 0A 00
BA 24 FF
B0 33
EE
E8 01 00
CC

MNEMONICS
MOV
MOV
OUT
CALL
MOV
MOV
OUT
CALL
MOV
MOV
OUT
CALL
MOV
MOV
OUT
CALL
INT

OPERAND
DX,
AL, 80
DX, AL
9125
DX,
AL, FF
DX, AL
9125
DX,
AL, 22
DX, AL
9125
DX,
AL, 33
DX, AL
9125
3

COMMENTS

DELAY:
ADDRESS
9125
9128
9129
912A
912B
912C
912D
912F

OUTPUT:

RESULT:

OPCODE
B9 FF 00
90
90
90
90
49
75 F9
C3

MNEMONICS
MOV
LOOP1:NOP
NOP
NOP
NOP
DEC
JNZ
RET

OPERAND
CX,FF

CX
LOOP1

COMMENTS

INTRODUCTION TO MASM
EDITOR
An editor is a program, which allows you to create a file containing the assembly language
statements for your program. As you type in your program, the editor stores the ASCII codes for
the letters and numbers in successive RAM locations. When you have typed in all of your
programs, you then save the file on a floppy of hard disk. This file is called source file. The next
step is to process the source file with an assembler. In the MASM /TASM assembler, you should
give your source file name the extension, .ASM
ASSEMBLER
An assembler program is used to translate the assembly language mnemonics for instructions to
the corresponding binary codes. When you run the assembler, it reads the source file of your
program the disk, where you saved it after editing on the first pass through the source program
the assembler determines the displacement of named data items, the offset of labels and pails this
information in a symbol table. On the second pass through the source program, the assembler
produces the binary code for each instruction and inserts the offset etc that is calculated during
the first pass. The assembler generates two files on floppy or hard disk. The first file called the
object file is given the extension. OBJ. The object file contains the binary codes for the
instructions and information about the addresses of the instructions. The second file generated by
the assembler is called assembler list file. The list file contains your assembly language
statements, the binary codes for each instructions and the offset for each instruction. In
MASM/TASM assembler, MASM/TASM source file name ASM is used to assemble the file.
Edit source file name LST is used to view the list file, which is generated, when you assemble
the file.
LINKER
A linker is a program used to join several object files into one large object file and convert to an
exe file. The linker produces a link file, which contains the binary codes for all the combined
modules. The linker however doesnt assign absolute addresses to the program, it assigns is said
to be reloadable because it can be put anywhere in memory to be run. In MASM/TASM,
LINK/TLINK source filename is used to link the file.
DEBUGGER
A debugger is a program which allows you to load your object code program into system
memory, execute the program and troubleshoot are debug it the debugger allows you to look at
the contents of registers and memory locations after your program runs. It allows you to change
the contents of register and memory locations after your program runs.

It allows you to change the contents of register and memory locations and return the program. A
debugger also allows you to set a break point at any point in the program. If you inset a
breakpoint the debugger will run the program upto the instruction where the breakpoint is set and
stop execution. You can then examine register and memory contents to see whether the results
are correct at that point. In MASM/TASM, td filename is issued to debug the file.
DEBUGGER FUNCTIONS:
1. Debugger allows looking at the contents of registers and memory locations.
2. We can extend 8-bit register to 16-bit register which the help of extended register option.
3. Debugger allows setting breakpoints at any point with the program.
4. The debugger will run the program upto the instruction where the breakpoint is set and then
stop execution of program. At this point, we can examine registry and memory contents at that
point.
5. With the help of dump we can view register contents.
6. We can trace the program step by step with the help of F7.
7. We can execute the program completely at a time using F8
The DOS -Debugger:
The DOS Debug program is an example of simple debugger that comes with MS-DOS.
Hence it is available on any PC .it was initially designed to give the user the capability to
trace logical errors in executable file.
Below, are summarized the basic DOS - Debugger commands
COMMAND SYNTAX
Assemble A [address]
Compare C range address
Dump D [range]
Enter E address [list]
Fill F range list
Go G [=address] [addresses]
Hex H value1 value2
Input I port
Load L[address] [drive][first sector][number]
Move M range address

Name N[pathname][argument list]


Output O port byte
Proceed P [=address][number]
Quit Q
Register R[register]
Search S range list
Trace T [=address][value]
Unassembled u [range]
Write W[address][drive][first sector][number]
MS-MASM:
Microsofts Macro Assembler (MASM) is an integrated software package Written by Microsoft
Corporation for professional software developers. It consists of an editor, an assembler, a linker
and a debugger (Code View). The programmers workbench combines these four parts into a
user-friendly programming environment with built in on line help. The following are the steps
used if you are to run MASM from DOS
MICROPROCESSOR LAB EXECUTION PROCEDURE
STEP1: Opening the DOS prompt
Click start menu button and click on Run and then type cmd at command prompt immediately
DOS window will be appeared
STEP2: Checking the MASM installation
To know MASM is installed or not simply type masm at the command prompt upon that it
replies masm version vendor (Microsoft), etc... If you get any error there is no masm in that PC
STEP3: Directory changing (create a folder with your branch and no in D drive)
Change the current directory to your won directory suppose your folder in D drive type the
following commands to change the directory at command prompt type D: hit enter now you are
in D drive type cd folder name hit the enter
Ex. D cd ece10
Now we are in folder cse10
STEP4: writing the program
At the command prompt type the edit programname.asm
Ex. Edit add.asm
Immediately editor window will open and there you have to write the program. Type the program
in that window after completion save the Program, to save the program Go to file opt in the
menu bar and select save opt now your code is ready to Assemble.

STEP5: Assembling, Linking and Executing the program


Go to file opt click exit opt now DOS prompt will be displayed to assemble the program type the
following commands at the DOS prompt
Masm Program Name, Program Name, Program Name, Program Name hit the enter
Ex: Masm add, add, add, add enter
OR
Ex: Masm add.asm
If there are any errors in the program assembler reports all of them at the command prompt with
line nos, if there are now bugs your ready to link the program. To link the program type the
following line at command prompt Link program name,,,,, (5 commas)
Ex: Link add,,,,,
OR
Ex: link add.obj
After linking you are ready to execute the program. To execute the program type the following
command
Debug program name.exe hit the enter
Ex: Debug add.exe
Now you entered into the execution part of the program here you have to execute the program
instruction by instruction (debugging) first of all press the r key(register) hit the enter key itll
displays all the registers and their initial values in HEXDECIMAL note down the values of all
the register which are used in the program. To execute the next instruction press t key (TRACE)
hit the enter itll execute that instruction and displays the contents of all the register. You have to
do this until you reach the last instruction of the program. After execution you have to observe
the results (in memory or registers based on what you have written in the program).
STEP6: Copying list file (common for all programs):
A list file contains your code starting address and end address along with your program .For
every program assembler generates a list file at your folder, programname.lst (ex. Add.lst) you
should copy this to your lab observation Opening a list file
Edit programname.lst
Ex. Edit add.lst

Execution of 8086 programs.


Run command prompt and go to Masm directory
i.e. C:\masm\
Type the program by opening an editor using Edit command
i.e. C:\masm\edit filename.asm
After typing the program assemble the program using masm command.
i.e. C:\masm\masm filename.asm;
After assembling, link the file using link command
i.e. C:\masm\link filename.obj;
Finally use debug or afdebug command to execute the program.
C:\masm\debug filename .exe
-t ; for single step execution
-g ; for at a time execution
-I ; for restarting the program execution
-d ; to see the data segment
-q ; to quit the execution
C:\masm\afdebug filename .exe
F1 ; for single step execution
g ; for at a time execution
L filename
Quit ; to come out of the execute screen

END

You might also like