Microcontroller
Microcontroller
ANNA UNIVERSITY
CHROMEPET, CHENNAI-600044
LABORATORY MANUAL
(Regulation – 2023)
MOHAMMED DHIYAN S
2024504541
DEPARTMENT OF ELECTRONICS ENGINEERING
ANNA UNIVERSITY
LABORATORY MANUAL
(Regulation – 2023)
ANNA UNIVERSITY
Prepared By Approved By
VISION
MISSION
PEO1: The graduated Students will demonstrate sufficient theoretical, analytical and
initiative skills in Basic Sciences and Engineering necessary, to assimilate, analyze,
synthesize and innovative solutions to meet societal needs.
PEO2: The graduated students will have inculcated a thirst for lifelong learning and
sustained research interest.
PEO 3: The graduated students will practice values and exhibit leadership qualities
and team spirit to promote entrepreneurship and indigenization.
PROGRAMME OUTCOMES (POs):
PO1: Ability to apply technical knowledge in mathematics, Science and Engineering
leading to the realization and evaluation of complex systems, through research problems
in the context of evolving societal needs.
PO2: Imaginative critical thinking with an ability to think critically, analyze and solve
Engineering problems.
PO3: Ability to design a system, component, or process to meet desired needs within
realistic constraints.
PO4: Ability to, gather user needs and requirements, design, develop, integrate, and test
complex systems by employing systems engineering thinking and processes, within
required operational and acquisition system environments.
PO5: Personal and intellectual autonomy to independently and with an openness to reflect
upon and use modern engineering tools necessary to engineering practices.
PO7: An active and committed global citizen with an awareness of contemporary issues
and their Impact on economic, environmental, social, political, ethical, health and
safety, manufacturability and sustainability.
PO9: A creative, enterprising team player and engaged participative leader able to effect
change.
PO10: A confident, resilient and adaptable individual with good communication skills.
CO2: Ability to develop assembly language programme and interface peripherals with
microprocessors.
CO3: Ability to understand the 8051 architecture and the methodology to configure and
program peripherals.
CO5: Ability to understand the ARM architecture and the methodology to configure and
program peripherals.
CO1 2 1 1 1 1
CO2 2 1 1 1 1
CO3 3 3 2 1 1 1 1
CO4 2 2 2 1 1 1
CO5 3 3 3 3 2 1 1 1
7. Interfacing LED, LCD, Switch and 4x4 Keypad with ARM processor.
Exp.
Date Title of the Experiment Page Marks Remarks
No.
EX NO: ADDITION OF TWO 8-BIT NUMBERS
DATE:
Aim :
To perform Addition of two 8-bit numbers using 8085 microprocessor.
Algorithm :
1. Set the register C to zero.
Program :
MVI C,00
LDA 8150
MOV B,A
LDA 8151
ADD B
JNC LOOP
INR C
MOV A,C
STA 8153
HLT
Execution table :
Memory Hex Label Mnemonics Comments
Address Code
addition
8004 81
register B
8008 81
Accumulator
800A D2 JNC LOOP
If carry does not arise after addition
800B 0E
jump to label LOOP
800C 80
the register C
accumulator
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8150 23 8152 7A
8151 57 8153 00
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8150 78 8152 0A
8151 92 8153 01
Result :
Thus the assembly Language Program to perform addition of two 8-bit numbers is
Aim :
Algorithm :
Program :
MVI C,00
LDA 8150
MOV B,A
LDA 8151
SUB B
JNC LOOP
CMA
INR A
INR C
MOV A,C
STA 8153
HLT
Execution table :
Memory Hex
Label Mnemonics Comments
Address Code
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8150 57 8152 34
8151 23 8153 00
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8150 23 8152 CC
8151 57 8153 01
Result :
Aim :
Algorithm :
5. If the data in the accumulator is larger than the data in register B, increment C register
8. Once the data in the accumulator is less than the data in the B register, stop the process
Program:
LXI H,8150
MOV B,M
MVI C,00
INX H
MOV A,M
LOOP 2 CMP B
JC LOOP 1
SUB B
INR C
JMP LOOP 2
MOV A,C
STA 8153
HLT
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 21 LXI H,8150
8001 50 Move 8150 to HL register pair
8002 81
Move data from memory pointer to
8003 46 MOV B,M
register B
8004 0E MVI C,00
Initialize C register to zero
8005 00
8006 23 INX H increment H register
Move contents of memory pointer to A
8007 7E MOV A,M
register
LOOP
8008 B8 CMP B compare B with data in accumulator
2
8009 DA JC LOOP 1
800A 11 If carry flag is set, jump to LOOP 1
800B 80
subtract data in B from the accumulator
800C 90 SUB B
contents
800D 0C INR C Increment C register
800E C3 JMP LOOP2 Jump to location indicated by LOOP 2
800F 08 Jump to location indicated by LOOP 2
800D 0C INR C Increment C register
8010 80
8011 32 LOOP 1 STA 8152 Store the data in the accumulator in
memory location 8152
8012 52
8013 81
8014 79 MOV A,C Move data from register C to the
accumulator
8015 32 STA 8153 store the accumulator data to memory
location 8153
8016 53
8017 81
8018 76 HLT Halt the program.
Output table:
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8150 02 8152 01
8151 13 8153 02
Result :
Aim :
Algorithm :
Program
LDA 8500
MOV E, A
LDA 8501
MVI C,09
MVI D,00
LXI H,0000
LOC 1 DCR C
JZ LOC 3
DAD H
RLC
JNC LOC 1
DAD D
LDA 8500
MOV E, A
LDA 8501
MVI C,09
MVI D,00
LXI H,0000
LOC 1 DCR C
JZ LOC 3
DAD H
RLC
JNC LOC 1
DAD D
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 3A LDA 8500
Load the data from memory location 8500 to the
8001 00
accumulator
8002 85
8003 5F MOV E,A Move data from accumulator to E register
8004 3A LDA 8501
Load the data from memory location 8501 to the
8005 1
accumulator
8006 85
8007 0E MVI C,09
Initialize C register to 09
8008 9
8009 16 MVI D,00
Clear D register
800A 00
800B 21 LXI H,0000
800C 00 Clear HL register pair
800D 00
800E 0D LOC 1 DCR C Decrement C regiter
800F CA JZ LOC 3
8010 19 If zero flag is set, jump to location 3
8011 80
8012 29 DAD H Perform 16 bit addition of HL with HL pair
8013 7 RLC Rotate the contents of accumulator left
8014 D2 JNC LOC 1
8015 0E If carry flag is not set, jump to location 1
8016 80
8017 19 DAD D Perform 16 bit addition of HL with DE pair
8018 C3 JMP LOC 1
8019 0E jump to location 1
801A 80
801B 7C LOC 3 MOV A,H Move the data from H register to the accumulator
801C 32 STA 8502
store the data in accumulator in the memory
801D 2
location 8502
801E 85
801F 7D MOV A,L Move the data from L register to the accumulator
8020 32 STA 8503
store the data in the accumulator in the memory
8021 3
location 8503
8022 85
8023 76 HLT Halt the program
Output Table:
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8500 12 8502 01
8501 13 8503 56
Result :
Algorithm :
Program :
LHLD 8200
LDA 8202
MOV C,A
LXI D,0000
LOOP 1: MOV A,L
SUB C
MOV L,A
JNC LOOP 2
DCR H
LOOP 2: INX D
MOV A,H
CPI 00
JNZ LOOP 1
MOV A,L
CMP C
JNC LOOP 1
MOV A,L
CMP C
JNC LOOP 1
SHLD 8302
XCHG
SHLD 8300
HLT
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8009 00
LOOP Move the contents of L register to the
800A 7D MOV A,L
1 accumulator
Subtract contents of C register with the data in
800B 91 SUB C
the accumulator
800C 6F MOV L,A Copy the contents of accumulator to register L
8017 80
Copy the contents of L register to the
8018 7D MOV A,L
accumulator
Compare the data in the C register with that of
8019 B9 CMP C
the accumulator
801A D2 JNC LOOP 1
801C 80
Output Table:
INPUT OUTPUT
Memory Memory
Data Data
Location Location
8200 32 8302 08
8201 32 8303 08
8202 04 8300 00
8301 00
Result :
Algorithm :
LXI H,0000
LXI SP,8400
MVI B,00
MVI C,03
LOC 1: DAD SP
JC LOC 2
LOC 3: DCX B
MOV A,C
ORA B
JNZ LOC 1
HLT
LOC 2: INX D
JMP LOC 3
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 11 LXI D,0000
8001 00 Initialize DE pair to zero
8002 00
8003 21 LXI H,0000 Initialize HL pair to zero
8004 00
8005 00
8006 31 LXI SP,8400
8007 00 Load multiplicand into SP
8008 84
8009 06 MVI B,00
Initialize B register to zero
800A 00
800B 0E MVI C,03
Load C register with multiplier
800C 03
800D 39 LOC 1 DAD SP Add contents of SP with that of HL pair
800E CA JC LOC 2
800F 18 If carry arises, jump to loc 2
8010 80
8011 0B LOC 3 DCX B Decrement BC pair
8012 79 MOV A,C Copy contents of register C to register A
8013 B0 ORA B logical OR of B register with Accumulator
8014 C2 JNZ LOC 1 If zero flag is not set, jump to loc 1
8015 0D
8016 80
8017 76 HLT Stop the program execution
8018 13 LOC 2 INX D Increment DE register pair
8019 C3 JMP LOC 3
801A 11 Unconditional jump to loc 3
801B 80
Output Table:
INPUT OUTPUT
SP 8400 HL 8C00
BC 0003 DE 0001
Result :
Aim :
To arrange the elements in an array in ascending order using 8085 microprocessor.
Algorithm :
1. Compare the first two 8-bit numbers in the memory.
2. Interchange them if the value in first memory location is greater than the value
in second memory location. Otherwise, don’t interchange.
3. Compare the contents of second and third memory location and, interchange if
needed.
4. Continue this process till the last two numbers are compared and interchanged.
5. Repeat the above steps n-1 times.
Program :
LXI H,8200
MOV C,M
DCR C
LOOP 1 MOV D,C
LXI H,8201
LOOP 2 MOV A,M
INX H
CMP M
JC LOOP 3
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
LOOP 3 DCR D
JNZ LOOP 2
DCR C
JNZ LOOP 1
HLT
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 21 LXI H,8200
8001 00 Load HL register pair with the value 8200
8002 82
8003 4E MOV C,M Move the data in the location pointed out
by M to register C
8004 0D DCR C Decrement C register
8005 51 LOOP 1 MOV D,C Move the data in register C to register D
8006 21 LXI H,8201
8007 01 Load HL register pair with the value 8201
8008 82
8009 7E LOOP 2 MOV A,M Move the data in the location pointed out
by M to the accumulator
800A 23 INX H Increment data in HL pair
800B BE CMP M Compare the data pointed out by M with
the data in accumulator
800C DA JC LOOP 3
800D 14 If carry flag is set, jump to loop 3
800E 80
800F 46 MOV B,M Move the data in the location pointed out
by M to B register
8010 77 MOV M,A Move the accumulator data to the
memory location pointed by M
8011 0B DCX H Decrement the data in HL pair
8012 70 MOV M,B Move the data in B register to the memory
location pointes by M
8013 23 INX H Increment data in HL pair
8014 15 LOOP 3 DCR D Decrement data in D register
8015 C2 JNZ LOOP 2
8016 09 If zero flag is not set, jump to loop 2
8017 80
8018 0D DCR C Decrement C register
8019 C2 JNZ LOOP 1
If zero flag is not set, jump to loop 1
801A 05
801B 80
801C 76 HLT Halt the program execution
Output Table:
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8200 02 8200 02
8201 13 8201 09
8202 09 8202 13
8203 23 8203 14
8204 14 8204 23
Result :
Aim :
Algorithm :
2. Interchange them if the value in first memory location is smaller than the value in
3. Compare the contents of second and third memory location and, interchange if
needed.
4. Continue this process till the last two numbers are compared and interchanged.
Program :
LXI H,8200
MOV C,M
DCR C
LOOP 1 MOV D,C
LXI H,8201
LOOP 2 MOV A,M
INX H
CMP M
Page 36
JNC LOOP 3
MOV B,M
MOV M,A
DCX H
MOV M,B
INX H
LOOP 3 DCR D
JNZ LOOP 2
DCR C
JNZ LOOP 1
HLT
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 21 LXI H,8200
8001 00 Load HL register pair with the value 8200
8002 82
8003 4E MOV C,M Move the data in the location pointed out
by M to register C
8004 0D DCR C Decrement C register
8005 51 LOOP 1 MOV D,C Move the data in register C to register D
8006 21 LXI H,8201
8007 01 Load HL register pair with the value 8201
8008 82
8009 7E LOOP 2 MOV A,M Move the data in the location pointed out
by M to the accumulator
800A 23 INX H Increment data in HL pair
800B BE CMP M Compare the data pointed out by M with
the data in accumulator
800C DA JNC LOOP 3
800D 14 If carry flag is not set, jump to loop 3
800E 80
800F 46 MOV B,M Move the data in the location pointed out
by M to B register
Page 37
8010 77 MOV M,A Move the accumulator data to the memory
location pointed by M
8011 0B DCX H Decrement the data in HL pair
8012 70 MOV M,B Move the data in B register to the memory
location pointes by M
8013 23 INX H Increment data in HL pair
8014 15 LOOP 3 DCR D Decrement data in D register
8015 C2 JNZ LOOP 2
8016 09 If zero flag is not set, jump to loop 2
8017 80
8018 0D DCR C Decrement C register
8019 C2 JNZ LOOP 1
If zero flag is not set, jump to loop 1
801A 05
801B 80
801C 76 HLT Halt the program execution
Output Table:
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8200 02 8200 23
8201 13 8201 14
8202 09 8202 13
8203 23 8203 09
8204 14 8204 02
Result :
Page 38
Thus the assembly Language Program to arrange the elements in an array in
Algorithm :
5. If the data in the accumulator is lesser than the other data in the memory, perform
swapping
Program:
MVI C,05
LXI H,8500
MOV A,M
LOC 1 DCR C
JZ LOC 2
Page 39
INX H
CMP M
JNC LOC 1
MOV A,M
JMP LOC 1
LOC 2 STA 8600
HLT
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 0E MVI C,05 Move an immediate value of 5 to the
8001 05 register C
8002 21 LXI H,8500
8003 00 Load HL pair with 8500
8004 85
Move the contents of location pointed
8005 7E MOV A,M
out by M to the accumulator
8006 0D LOC 1 DCR C Decrement the counter ( C register)
8007 CA JZ LOC 2
8008 13 If zero flag is set, jump to location 2
8009 80
800A 23 INX H Increment HL pair
Compare the data in the accumulator
800B BE CMP M
with the data pointed by M
800C D2 JNC LOC 1
800D 06 If carry flag is not set, jump to location 1
800E 80
Move the contents of location pointed
800F 7E MOV A,M
out by M to the accumulator
8010 C3 JMP LOC 1
8011 06 Unconditional jump to location 1
8012 80
8013 32 LOC 2 STA 8600 Store contents of accumulator in the
8014 00 memory location 8500
Page 40
8015 86
8016 76 HLT Halt the program
Output Table:
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8500 2 8600 23
8501 13
8502 9
8503 23
8504 14
Result :
Thus the assembly Language Program to find out the largest value in an
Page 41
EX NO: TO FIND THE SMALLEST VALUE IN AN ARRAY
DATE:
Aim :
Algorithm :
5. If the data in the accumulator is greater than the other data in the memory, perform
swapping
Program :
MVI C,05
LXI H,8500
MOV A,M
LOC 1 DCR C
JZ LOC 2
INX H
CMP M
Page 42
JC LOC 1
MOV A,M
JMP LOC 1
LOC 2 STA 8600
HLT
Execution Table:
Memory Hex
Label Mnemonics Comments
Address Code
8000 0E MVI C,05 Move an immediate value of 5 to the
8001 05 register C
8002 21 LXI H,8500
Load HL pair with 8500
8003 00
8004 85
Move the contents of location pointed
8005 7E MOV A,M
out by M to the accumulator
8006 0D LOC 1 DCR C Decrement the counter ( C register)
8007 CA JZ LOC 2
8008 13 If zero flag is set, jump to location 2
8009 80
800A 23 INX H Increment HL pair
Compare the data in the accumulator
800B BE CMP M
with the data pointed by M
800C DA JC LOC 1
800D 06 If carry flag is set, jump to location 1
800E 80
Move the contents of location pointed
800F 7E MOV A,M
out by M to the accumulator
8010 C3 JMP LOC 1
Unconditional jump to location 1
8011 06
8012 80
8013 32 LOC 2 STA 8600 Store contents of accumulator in the
8014 00 memory location 8500
8015 86
8016 76 HLT Halt the program
Page 43
Output Table:
INPUT OUTPUT
Memory Memory
Data Data
Address Address
8500 02 8600 02
8501 13
8502 09
8503 23
8504 14
Result :
Thus the assembly Language Program to find out the smallest value in an
array is performed using 8085 Microprocessor.
Page 44
EX NO: BASIC ARITHMETIC OPERATIONS USING 8086
DATE: MICROPROCESSOR
Aim:
To perform basic arithmetic operations like addition, subtraction, multiplication,
division.
Algorithm:
Move the contents to the contents to the respective registers.
1. Add the content and store the result in a memory location.
2. Repeat step 2 for subtraction, multiplication, division.
3. Execute the program.
4. To see the result go to the respective memory location where the
5. results are stored.
Program:
MOV AX,2000
MOV BX,1000
MOV CX,AX
ADD AX,BX
MOV [2000],AX
MOV AX,CX
SUB AX,BX
MOV [2002],AX
MOV AX,CX
MUL BX
MOV [2004],AX
MOV [2006],DX
MOV AX,CX
DIV BX
Page 45
MOV [2008],AL
MOV [2009],DX
INT 3
Execution Table:
MEMORY MNEMONICS COMMENT
ADDRESS
Page 46
Output Table:
OUTPUT
MEMORY DATA
ADDRESS
2000 3000
2002 1000
2004 0200
2006 0000
2008 02
2009 00
Result:
Thus the assembly language program to perform basic arithmetic operations
using 8086 is performed.
Page 47
EX NO: ASCENDING ORDER
DATE:
Aim:
To arrange the given set of numbers in ascending order.
Algorithm:
1. The count and the numbers to be arranged is stored in memory locations.
2. Count is moved to CL and DL register.
3. First two numbers are transferred to AL and BL registers.
4. Both are compared and swapped.
5. The result is the numbers arranged in order in the memory locations.
Program:
MOV SI,9000
MOV CL,[SI]
LOC4: MOV SI,9000
MOV DL,[SI]
INC SI
MOV AL,[SI]
LOC3: INC SI
MOV BL,[SI]
CMP AL,BL
JNB LOC1
DEC SI
MOV [SI],AL
MOV AL,BL
JMP LOC2
LOC1: DEC SI
Page 48
MOV [SI],BL
LOC2: INC SI
DEC DL
JNZ LOC3
MOV [SI],AL
DEC CL
JNZ LOC4
INT 3
Execution Table:
MEMORY MNEMONICS COMMENT
ADDRESS
Page 49
801A MOV AL,BL Content of BL moved to AL register
Output Table:
INPUT OUTPUT
9001 08 9001 02
9002 05 9002 05
9003 09 9003 08
9004 02 9004 09
Page 50
Result:
Thus the numbers are arranged in ascending order using 8086.
Page 51
EX NO: DESCENDING ORDER
DATE:
Aim:
To arrange the given set of numbers in descending order.
Algorithm:
1. The count and the numbers to be arranged is stored in memory locations.
2. Count is moved to CL and DL register.
3. First two numbers are transferred to AL and BL registers.
4. Both are compared and swapped.
5. The result is the numbers arranged in order in the memory locations.
Program:
MOV SI,9000
MOV CL,[SI]
LOC4: MOV SI,9000
MOV DL,[SI]
INC SI
MOV AL,[SI]
LOC3: INC SI
MOV BL,[SI]
CMP AL,BL
JB LOC1
DEC SI
MOV [SI],AL
MOV AL,BL
JMP LOC2
LOC1: DEC SI
MOV [SI],BL
Page 52
LOC2: INC SI
DEC DL
JNZ LOC3
MOV [SI],AL
DEC CL
JNZ LOC4
INT 3
Execution Table:
MEMORY MNEMONICS COMMENT
ADDRESS
Page 53
801C JMP LOC2 Jumps to loc2
Output Table:
INPUT OUTPUT
9001 08 9001 09
9002 05 9002 08
9003 09 9003 05
9004 02 9004 02
Page 54
Result:
Thus the numbers are arranged in descending order using 8086 Microprocessor.
Aim:
programmable IC.
Algorithm:
2. Initialise the 8255 IC as input-mode 0 operation and port A as input and port C upper to
Program:
MOV DX,FF26
MOV AL,90
OUT DX,AL
MOV DX,FF24
MOV AL,FF
Page 55
OUT DX,AL
MOV AL,00
OUT DX,AL
MOV AL,FF
OUT DX,AL
CALL DELAY
MOV DX,FF20
IN AL,DX
INT 3
WAIT: NOP
NOP
DEC CX
JNZ WAIT
RET
Execution table:
Page 56
1004 Initializing Port A as input and others as output ports
in 8255
1005 OUT DX,AL Out the AL contents to address location FF26 in
8255
1006 MOV DX,FF24 Address of Port C upper is loaded in DX register
1007
1008
1009 MOV AL,FF Load FF in AL register
100A
100B OUT DX,AL Out the AL contents to address location FF24 in
8255
100C MOV AL,00 Start of Conversion
100D
100E OUT DX,AL Out the AL contents to address location FF24 in
8255
100F MOV AL,FF Load FF in AL register
1011
1012 OUT DX,AL Out the AL contents to address location FF24 in
8255
1013 CALL DELAY Calling the DELAY function
1014
1015
1016 MOV DX,FF20 Address of Port A is loaded in DX register
1017
1018
1019 IN AL,DX Contents of Port A is loaded in AL register
101A INT 3 Halt the program
101B DELAY MOV CX,07FF Set CX register to 07FF
101C
101D
101E LABEL1 NOP Does nothing
101F NOP Does nothing
1020 DEC CX Decrement the CX-register
1021 JNZ LABEL1 If zero flag is reset ,jump to LABEL1
1022
1023 RET Return to main program
Output table:
0 00
Page 57
1 2C
2.5 6E
4.8 D3
Result:
Thus the Assembly language program to interface analog to digital convertor IC with 8086
programmable IC
Algorithm:
1. Initialize the 8255 IC in input-mode 0 operation and all ports as output ports
3. View the equivalent analog output in the display devices like CRO etc
Program:
MOV DX,FF26
MOV AL,80
OUT DX,AL
LOOP: MOV AL,FF
OUT DX,AL
CALL DELAY
MOV AL,00
OUT DX,AL
Page 58
CALL DELAY
JMP LOOP
DELAY: MOV CX,07FF
WAIT: NOP
NOP
DEC CX
JNZ WAIT
RET
Execution table:
Page 59
100F MOV AL,00 Load 00 in AL register
1010
1011 OUT DX,AL Out the AL contents to address location FF22 in
8255
1012 CALL Calling DELAY function
DELAY
1013
1014
1015 JMP LOOP Unconditional jump to location LOOP
1016
1017 DELAY MOV Load 07FF in CX register
CX,07FF
1018
1019
101A BACK NOP No operation
101B NOP No operation
101C DEC CX Decrement the contents in CX register
101D JNZ BACK If zero flag is reset ,jump to location BACK
101E
101E RET Return to the main program
Page 60
Result:
Thus the Assembly language program to interface digital to analog convertor IC with
To interface the stepper motor with 8086 microprocessor using 8255 programmable IC
Algorithm:
1. Initialize the 8255 IC as input-mode 0 operation and all port s as output ports
Program:
MOV DX,FF26
MOV AL,80
OUT DX,AL
WAIT: MOV DX,FF20
Page 61
MOV AL,05
OUT DX,AL
CALL DELAY
MOV AL,07
OUT DX,AL
CALL DELAY
MOV AL,06
OUT DX,AL
CALL DELAY
MOV AL,04
OUT DX,AL
CALL DELAY
JMP WAIT
DELAY: MOV BX,0010
BACK: MOV AL,FF
BACK1: NOP
NOP
NOP
NOP
DEC AL
JNZ BACK1
DEC BX
JNZ BACK
RET
Execution table:
Memory
address Label Mnemonics Comments
1000 MOV Address of control word is loaded in DX register
1001 DX,FF26
1002
1003 MOV AL,80
Page 62
1004 Initializing 8255 in input-mode 0 operation and all
ports as output ports
1005 OUT DX,AL Out the AL contents to address location FF26 in
8255
1006 WAIT MOV Address of Port A is loaded in DX register
1007 DX,FF20
1008
1009 MOV AL,05 Load 05 in AL register
100A
100B OUT DX,AL Out the AL contents to address location FF20 in
8255
100C CALL Calling DELAY function
100D DELAY
100E
100F MOV AL,07 Load 07 in AL register
1010
1011 OUT DX,AL Out the AL contents to address location FF20 in
8255
1012 CALL Calling DELAY function
1013 DELAY
1014
1015 MOV AL,06 Load 06 in AL register
1016
1017 OUT DX,AL Out the AL contents to address location FF20 in
8255
1018 CALL Calling DELAY function
1019 DELAY
101A
101B MOV AL,04 Load 04 in AL register
101C
101D OUT DX,AL Out the AL contents to address location FF20 in
8255
101E CALL Calling DELAY function
101F DELAY
1020
1021 JMP WAIT Unconditional jump to location WAIT
1022
1023 DELAY MOV Load 0010 in BX register
1024 BX,0010
1025
1026 BACK1 MOV AL,FF Load FF in AL register
1027
1028 BACK2 NOP Does nothing
1029 NOP Does nothing
102A NOP Does nothing
Page 63
102B NOP Does nothing
102C DEC AL Decrement the contents in AL register
102D JNZ BACK2 If zero flag is reset ,jump to BACK2
102E
102F
1030 DEC BX Decrement the contents in BX register
1031 JNZ BACK1 If zero flag is reset ,jump to BACK1
1032
1033 RET Return to main program
Result:
Thus the Assembly language program to interface the stepper motor with 8086
Aim:
To interface keyboard and display with 8086 microprocessor using 8279
keyboard/display controller
Algorithm:
1. Initialise the 8279 IC in 8-bit character Right entry-encoded scan,N-key roll over (input)
mode
Program:
Page 64
MOV AL,12
MOV DX,FF52
OUT DX,AL
MOV AL,3E
OUT DX,AL
MOV AL,A0
OUT DX,AL
WAIT : IN AL,DX
AND AL,07
JZ WAIT
MOV DX,FF50
IN AL,DX
AND AL,3F
INT 3
Execution table:
MEMORY
LABEL MNEMONICS COMENTS
ADDRESS
1000
MOV AL,12 Eight 8-bit character right entry mode
1001
1002
Address of control word is loaded in DX
1003 MOV DX,FF52
register
1004
Out the AL contents to status register in
1005 OUT DX,AL
8279
1006
MOV AL,3E For frequency division
1007
Out the AL contents to status register in
1008 OUT DX,AL
8279
1009
MOV AL,A0 encoded scan, N-key roll over mode
100A
Out the AL contents to status register in
100B OUT DX,AL
8279
Get the status register contents in AL
100C WAIT IN AL,DX
register
100D Logical AND of 07 with contents of AL
AND AL,07
100E register
Page 65
100F
JZ WAIT If zero flag is set ,jump to location WAIT
1010
1011
Initialising DX register with data register
1012 MOV DX,FF50
address
1013
Get the data register contents in AL
1014 IN AL,DX
register
1015 Logical AND of 3F with contents of AL
AND AL,3F
1016 register
1017 INT 3 Halt the program
21 22 23 24
19 1A 1B 1C
11 12 13 14
09 0A 0B 0C
Page 66
Result:
Thus the Assembly language program to interface keyboard and display with 8086
Page 67
EX NO: ADDITION AND SUBTRACTION USING 8051
DATE: MICROCONTROLLER
Aim:
Algorithm:
Program:
Page 68
Execution table:
Output:
Page 69
Result:
Thus the program to perform addition and subtraction using 8051 is verified.
Algorithm:
2. Compare the values with each other and load the larger value in the accumulator.
Program:
Page 70
LOC1: JC LOC3
MOV R0, A
LOC3: DJNZ R2, LOC2
LCALL 00BB
Execution table:
Output table:
Page 71
Register R0:87
Result:
Algorithm:
5. Add the last and previous number and store it in next location.
Program:
Page 72
MOV X A, @DPTR
MOV R0, A
INC DPTR
MOV R1, #00
MOV A, R1
MOVX @DPTR, A
INC DPTR
MOV R2, #01
MOV A, R2
MOVX @DPTR, A
Page 73
MOV R1, #00 Loads 00 in R1
MOV A, R1 Moves R1 to A
MOVX @DPTR, A Moves value in A to memory location in
dptr
INC DPTR Increments dptr
MOV R2, #01 Loads 01 in R2
MOV A, R2 Copies R2 to A
MOVX @DPTR, A Moves value in A to memory location in
dptr
REPEAT INC DPTR Increments dptr
MOV A, R2 Copies R2 to A
ADD A, R1 Adds A with R1
MOV R3, A Moves A to R3
MOVX @DPTR, A Moves value in A to memory location in
dptr
MOV A, R2 Moves R2 to A
MOV R1, A Moves A to R1
MOV A, R3 Moves R3 to A
MOV R2, A Moves A to R2
DJNZ R0, REPEAT Control is transferred to REPEAT
LCALL OOBB Halts the program
Output table:
Page 74
8805 03
8806 05
8807 08
8808 0D
8809 15
880A 22
880B 37
Result:
Thus, Fibonacci series is computed using 8051 microcontroller.
Page 75
Page 76
Page 77