Professional Documents
Culture Documents
8-BIT ADDITION
ALGORITHM:
1. Start the program
2. Initialize the carry register asSTART
00H.
3. Move the data1 and data2 to accumulator and B register respectively.
4. Add B register to the content
[C] of accumulator
5. If there is no carry, go to 00H
step 6, else increment C register.
6. Store the content of accumulator to the memory location.
[HL]
7. Move the content of C register to accumulator.
8500H
8. Store the content of accumulator to the next memory location.
[A]
[M]
9. Stop the program.
PROGRAM:
ADDRESS
OPCODE
LABEL
MNEMONICS
[HL][HL]+1
MVI C,00 H
COMMENTS
8100
0E, 00
8102
3E, data1
8104
06,data2
MVI B,data2
8106
80
ADD B
8107
D2,0B,81
810A
0C
810B
32,00,80
810E
810F
79
32,01,80
CarryMOV
? A,C
[C][C]+1
STA 8001
8112
76
HLT
[HL][HL]+1
MVI A,data1
[A][A]+[M]
GO
JNC GO
Is there
a
INR C
carry?
STA 8000
OUTPUT:
Input
Memory location
Data 1
Data 2
FLOW CHART:
[M]
[A]
Data
04
[HL][HL]+1
02
[M]
[C]
STOP
Output
Memory location
8000
8001
Data
06
00
NO
YES
8-BIT SUBTRACTION
ALGORITHM:
1. Load the subtrahend from memory to A register and move it to B register.
2. Load the minuend to the accumulator.
3. Clear the C register to account for the sign of result.
4. Subtract the contents of B register from the A register.
5. Check for carry. If carry=0 go to 7th step, else go to next step.
6. Increment C register, and find the 2s complement of the content of accumulator.
7. Store the content of accumulator
and C-register
START
8. Stop the program
PROGRAM:
[C] 00H
LABEL
MNEMONICS
ADDRESS
OPCODE
8100
3A, 00, 82
8103
47
8104
3A, 01, 82
8107
0E, 00
8109
90
SUB B
810A
D2, 11, 81
JNC AHEAD
[HL][HL]+1
810D
0C
INR C
810E
2F
810F
C6,01
8111
32, 02, 82
8114
79
8115
32, 03, 82
8118
76
[A]
LDA 8201H
[M] C,00H
MVI
CMA
[A][A]-[M]
Input
ADI 01H
AHEAD
STA 8202H
Is there
MOV A,C
a STA 8203H
borrow
HLT
?
[M]
[A]
[HL][HL]+1
FLOW CHART:
Complement
Borrow
[A]
?
OUTPUT:
Memory location
8200
8201
LDA 8200H
[HL] 8500H
MOV B,A
COMMENTS
[M]
[C]
STOP
Data
04
00
NO
YES
8-BIT MULTIPLICATION
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
PROGRAM:
ADDRESS
OPCODE
8500
3E, 00
8502
LABEL
MNEMONICS
COMMENTS
MVI A,00
06,data1
MVI B,data1
8504
0E,data2
MVI C,data2
8506
16,00
MVI D,00
8508
80
ADD B
repetitive addition
8509
D2, 0D, 85
850C
14
850D
0D
850E
LOOP2
JNC LOOP1
INR D
DCR C
Decrement multiplier
C2, 08,85
JNZ LOOP2
8511
32,00,80
STA 8000
8514
7A
MOV A,D
8515
32,01,80
STA 8001
8518
76
HLT
LOOP1
OUTPUT:
Input
Memory location
Data 1
Data 2
FLOWCHART:
Output
Data
03
02
Memory location
8000
8001
Data
06
00
START
[HL]
8500
B M
[HL] [HL]+1
A 00
C 00
[A] [A] +
[M]
NO
YES
Is there
any
carry?
C C+1
B B-1
IS
B=0?
NO
YES
[HL][HL]+1
[M]
[A]
[HL][HL]+1
[M]
[C]
STOP
8-BIT
DIVISION
ALGORITHM:
START
ADDRESS
OPCODE
8500
3E,data1
8502
06,data2
8504
0E, 00
8506
B8
8507
DA, 0F, 85
850A
90
850B
0C
850C
C3, 06,85
850F
8512
8513
32,01,80
79
32,00,80
8516
76
LABEL
B 00
[HL]
8500
000
LOOP2
A M
MNEMONICS
MVI A,data1
MVI B,data2
MVI C,00
CMP B
JC LOOP1
[HL] [HL]+1
M A-M
COMMENTS
Clear C register
Compare B reg and accumulator.
Jump on carry to loop1.
SUB B
INR C
Increment C register
JMP LOOP2
LOOP1
STA 8001
MOV A,C
[B] [B] +1
STA 8000
HLT
Jump to loop2
Store the remainder.
Store the quotient.
Stop the process.
IS
A<0?
OUTPUT:
AA+ M
Input
Memory location
Data 1
Data 2
Output
Data
B B-1
04
02
[HL][HL]+1
[M]
[A]
[HL][HL]+1
FLOWCHART:
[M]
[B]
STOP
Memory location
8000
8001
Data
02
00
NO
YES
RESULT:
Thus the assembly language program for 8-bit addition, subtraction, multiplication and division was
executed using an 8085 microprocessor.
To write an assembly language program in 8085 to add, subtract, multiply and divide two 16-Bit
numbers.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.
PROGRAM:
ADDRESS
8100
8103
8104
OPCODE
2A, 00, 82
EB
2A, 02, 82
8107
AF
8108
19
8109
810C
D2, 0D, 81
3C
810D
22, 04, 82
8110
32, 06, 82
8113
LABEL
76
MNEMONICS
START
LHLD 8200
XCHG
[L]
LHLD 8202
[8200H]
[H] XRA A
[8201H]
[DE]DAD D
[HL]
JNC RESULT
[L] INR A
[8202H] [H]
RESULT SHLD 8204
[8203H]
STA 8206
[A]00H
HLT
Input
FLOW CHART:
[HL][HL]+ [DE]
OUTPUT:
Memory location
8200
8201
8202
8203
COMMENTS
Output
Data
Memory location
Is there
8204
a
8205
carry?
8206
Carry?
[A][A]+1
[8204][ L]
[8205] [H]
[8206]
[A]
STOP
Data
NO
YES
16-BIT SUBTRACTION
ALGORITHM:
1. Start the program
2. Load the first 16 bit data in HL register pair and move it to DE reg pair.
3. Load the second 16 bit data in HL register pair.
4. Subtract the lower byte of data first and then higher byte of data.
5. If there is a carry obtain 2S Complement of result.
6. Store the difference and sign bit.
OPCODE
LABEL
MNEMONICS
COMMENTS
8200
0E, 00
MVI C, 00H
Clear C register
8202
2A, 00, 84
LHLD 8400H
8205
EB
XCHG
8206
8209
820A
2A, 02, 84
7D
93
LHLD 8402
MOV A, L
SUB E
820B
6F
MOV L, A
820C
820D
7C
9A
MOV A, H
SBB D
820E
67
MOV H, A
820F
8212
D2, 1A, 82
0C
START
JNC
GO
INR C
8213
7D
8214
8215
8216
8217
8218
8219
821A
821D
821E
8421
2F
6F
7C
2F
67
23
22, 04, 84
79
32, 06, 84
76
L
[L] MOV A,
[8400
H]
[H]
CMA
[8401 H]
MOV L, A
[DE]
MOV A, H
[HL]
CMA
MOV H,A
INX H
[L]
GO
SHLD 8404H
[8402H]
MOV A, C
[H]
STA 8406H
[8403H]
HLT
OUTPUT:
Input
Memory location
8400
8401
8402
8403
FLOW CHART:
Output
Data
Is thereMemory location
8404
a
8405
borrow
8406
?
borrow
?
[8404][ L]
STOP
Data
[HL][HL]- [DE]
NO
NO
YES
[C][C]+1
[8405] [H]
[8406]
[C]
16-BIT MULTIPLICATION
ALGORITHM:
1. Start the program
2. Load the multiplicand in HL pair register and copy in SP.
3. Load the multiplier in DE reg pair and clear HL and BC reg pair.
4. Add content of SP to HL pair register content.
5. Perform repetitive addition of the multiplicand until the multiplier becomes zero.
6. Store the product.
7. Stop the program.
PROGRAM:
COMMENTS
ADDRESS
OPCODE LABEL
MNEMONICS
8000
2A,50,80
8003
F9
8004
2A,52,80
8007
EB
8008
21,00,00
LXI H, 0000H
800B
01,00,00
LXI B, 0000H
800E
39
800F
LHLD 8050H
SPHL
LHLD 8052
XCHG
LOOP
D2,13,80
DAD SP
JNC NEXT
8012
03
8013
1B
8014
7B
MOV A,E
8015
B2
ORA D
8016
NEXT
SHLD 8054
801C
79
MOV A, C
32,56,80
STA 8056
78
MOV A, B
32,57,80
STA 8057
76
22,54,80
8024
DCR D
8019
8021
JNZ LOOP
8020
INX B
C2,0E,80
801D
HLT
OUTPUT:
Input
Memory location
8050
8051
8052
8053
Output
Data
Memory location
8054
8055
8056
8057
Data
FLOWCHART :
START
L
[8050]
H
[8051]
SP HL
[8052]
[8053]
DE
HL
HL0000
BC0000
HLHL+SP
NO
YES
Is Carry
flag set?
[8054]
L
[8055]
H
[8056]
C
BCBC+1
DEDE+1
NO
[8057]
B
STOP
YES
Is Zero
flag set?
16-BIT DIVISION
ALGORITHM:
1. Start the program
2. Load the dividend in HL pair register.
3. Load the divisor in accumulator and move to C register.
4. Subtract the content of the divisor from the dividend until the carry flag is set.
5. Increment the quotient during every time of subtraction.
6. Store the quotient and the remainder.
7. Stop the program.
PROGRAM:
ADDRESS
8100
8103
8106
8107
810A
810B
810C
OPCODE
2A,00, 42
3A,02,42
4F
11,00,00
7D
91
6F
LABEL
810D
D2,11,81
JNC LOOP2
8110
8111
8112
8113
25
13
7C
FE,00
DCR H
INX D
MOV A,H
CPI 00H
8115
C2,0A,81
JNZ LOOP1
8118
8119
7D
B9
MOV A,L
CMP C
811A
D2,0A,81
JNC LOOP1
811D
8120
8121
8124
22,02,83
EB
22,00,83
76
SHLD 8302H
XCHG
SHLD 8300H
HLT
LOOP1
LOOP2
MNEMONICS
LHLD 8200H
LDA 8202H
MOV C,A
LXI D,0000H
MOV A,L
SUB C
MOV L,A
COMMENTS
Load the dividend in HL reg pair
Load the divisor in C register
Clear DE reg pair
Move the content of Acc to L.
Subtract reg. C from that of Acc.
Move the content of Acc to L.
If there is no carry, go to the location
labeled LOOP 2.
Decrement H reg. pair.
Increment the quotient
Move the content of reg. H Acc.
If there is no zero, go to instruction
labeled LOOP1
Move the content of Acc to L.
Compare C & A
If there is no carry, go to the location
labeled LOOP 1.
Store the remainder
Exchange
Store the quotient
Stop the program execution.
OUTPUT:
Input
Memory location
8200
8201
8202
8203
Output
Data
Memory location
8300
8301
8302
8303
Data
FLOWCHART:
START
L
[8200]
H [8201]
HL
DE
L
[8202]
H [8203]
BC 0000H
A
A
E
L; AABCBC- 1
LA
HLHL+DE
AH;
AA- HBorrow;
L[8300]
H[8301]
HA
BCBC+ 1
AC
NO
HA
Is
Carry
flag
set ?
[8302] A
AB
YES
[8303] A
A
STOP
RESULT:
Thus the assembly language program for 16-bit addition, subtraction, multiplication and division was
executed using an 8085 microprocessor.
3.A)ASCENDING ORDER
AIM:
To sort the given number in the ascending order using 8085 microprocessor.
ALGORITHM:
1.
Get the numbers to be sorted from the memory locations.
2.
Compare the first two numbers and if the first number is larger than second then I interchange the
number.
3.
If the first number is smaller, go to step 4
4.
Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:
ADDRESS
OPCODE
8000
06,04
8002
21,00,81
8005
0E,04
8007
7E
8008
LABEL
MNEMONICS
COMMENTS
MVI B,04
LXI H,8100
MVI C,04
MOV A,M
23
INX H
8009
BE
CMP M
Compare M & A
800A
DA,12,80
JC LOOP1
800D
56
MOV D,M
800E
77
MOV M,A
800F
2B
DCX H
Decrement HL pair
8010
72
MOV M,D
8011
23
INX H
Increment HL pair
8012
0D
DCR C
Decrement C reg
8013
C2,07,80
JNZ LOOP2
8016
05
DCR B
Decrement B reg
8017
C2,02,80
JNZ LOOP3
801A
76
HLT
LOOP 3
LOOP2
LOOP1
OUTPUT:
INPUT
MEMORY LOCATION
OUTPUT
DATA
MEMORY LOCATION
8100
8100
8101
8101
8102
8102
8103
8103
8104
8104
FLOWCHART:
DATA
START
[B] 04H
[HL]
[8100H]
[C] 04H
[A] [HL]
[HL [HL] + 1
YES
IS [A] <
[HL]?
NO
[D] [HL]
[HL] [A]
[HL] [HL] - 1
YES
[HL] [D]
[HL] [HL] + 1
[C] [C] NO
01 H
A
B
NO
YES
A
IS
[C]=0?
NO
[C] =
YES
0?
[B] [B]-1
IS
[B]=0?
[B] =
0?
STOP
RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in ascending order.
OPCODE
LABEL
MNEMONICS
START
8000
06,04
8002
21,00,81
8005
0E,04
8007
7E
8008
COMMENTS
MVI B,04
LXI H,8100
MVI C,04
MOV
A,M
[HL]
23
[8100H]
INX
H
8009
BE
CMP M
Compare M & A
800A
D2,12,80
JNC LOOP1
800D
56
MOV
[A] D,M
[HL]
800E
77
MOV M,A
800F
2B
[HL
[HL]
DCX
H +1
8010
72
MOV M,D
8011
23
INX H
Increment HL pair
8012
0D
8013
C2,07,80
JNZ LOOP2
8016
05
DCR B
Decrement B reg
8017
C2,02,80
JNZ LOOP3
801A
76
HLT
LOOP 3
LOOP2
[B] 04H
[C] 04H
LOOP1
IS [A] <
DCR
C
[HL]?
[D] [HL]
Decrement HL pair
Decrement C reg
[HL] [A]
OUTPUT:
INPUT
MEMORY LOCATION
8100
8101
8102
8103
8104
FLOWCHART:
[HL] [HL] - 1
DATA
[HL] [D]
[HL] [HL] + 1
[C] [C] 01 H
OUTPUT
MEMORY LOCATION
8100
8101
8102
8103
8104
DATA
NO
YES
IS
[C]=0?
[C] =
0?
[B] [B]-1
IS
[B]=0?
[B] =
0?
STOP
NO
YES
YES
RESULT:
Thus the descending order program is executed and thus the numbers are arranged in descending
order.
ALGORITHM:
1. Place all the elements of an array in the consecutive memory locations.
2. Fetch the first element from the memory location and load it in the accumulator.
3. Initialize a counter (register) with the total number of elements in an array.
4. Decrement the counter by 1.
5. Increment the memory pointer to point to the next element.
6. Compare the accumulator content with the memory content (next element).
7. If the accumulator content is smaller, then move the memory content (largest element) to the
accumulator. Else continue.
8. Decrement the counter by 1.
9. Repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
PROGRAM:
ADDRESS
OPCODE LABEL
MNEMONICS
COMMENTS
8001
21,00,81
LXI H,8100
8004
06,04
MVI B,04
8006
7E
MOV A,M
8007
23
INX H
8008
BE
CMP M
Compare M & A
8009
D2,0D,80
JNC LOOP
800C
7E
MOV A,M
800D
05
DCR B
Decrement B reg
800E
C2,07,08
JNZ LOOP1
8011
32,05,81
STA 8105
8014
76
HLT
LOOP1
LOOP
OUTPUT:
INPUT
MEMORY LOCATION
8100
8101
8102
8103
8104
FLOW CHART:
OUTPUT
DATA
MEMORY LOCATION
8105
DATA
START
[HL]
[8100H]
[B] 04H
[A] [HL]
[HL [HL] + 1
NO
IS [A] <
[HL]?
YES
[A] [HL]
[B] [B]-1
NO
IS [B]
= 0?
YES
YES
[8105] [A]
STOP
RESULT:
Thus the largest number in the given array is found out.
2.
3.
4.
5.
6.
7.
Fetch the first element from the memory location and load it in the accumulator.
Initialize a counter (register) with the total number of elements in an array.
Decrement the counter by 1.
Increment the memory pointer to point to the next element.
Compare the accumulator content with the memory content (next element).
If the accumulator content is smaller, then move the memory content (largest element) to the
accumulator. Else continue.
8. Decrement the counter by 1.
9. Repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
PROGRAM:
ADDRESS
OPCODE LABEL
MNEMONICS
COMMENTS
8001
21,00,81
LXI H,8100
8004
06,04
MVI B,04
8006
7E
START
MOV
A,M
8007
23
INX H
8008
BE
[HL]
CMP
M
Compare M & A
8009
DA,0D,80
JC LOOP
800C
7E
MOV
[B] A,M
04H
800D
05
DCR B
Decrement B reg
800E
C2,07,08
[A]LOOP1
[HL]
JNZ
8011
32,05,81
STA 8105
8014
76
LOOP1
[8100H]
LOOP
[HL [HL] + 1
HLT
OUTPUT:
INPUT
MEMORY LOCATION
IS [A] <
[HL]?
DATA
8100
8101
8102
FLOW CHART:
MEMORY LOCATION
8105
[A] [HL]
8103
8104
OUTPUT
[B] [B]-1
IS [B]
= 0?
[8105] [A]
STOP
DATA
YES
NO
NO
NO
YES
RESULT:
Thus the smallest number in the given array is found out.
S.NO
APPARATUS
SPECIFICATION
QUANTITY
Microprocessor
8085 system
Power supply
+5V
Interface board
VBMB-004
Bus
VXT
CIRCUIT DIAGRAM
D6
D5
D1
SYNCMODE.
ASYNC * 1
ASYNC * 16
ASYNC * 64
CHARACTER LENGTH:
D2
D3
5BITS
6BITS
D4
D3
D2
D1
D0
7BITS
8BITS
PARITY CONTROL:
D4
D5
NO PARITY
ODD PARITY
EVEN PARITY
FRAMING CONTROL:
D6
D7
NOT VALID
1 STOP BIT
1 STOP BIT
2 STOP BIT
EH
IR
RTS
ER
1-enable
IR->Internal reset
1-Reset
SBRK
RXE
DTR
RTS->Request to send
1-enable RTS.
ER->Error reset
RE->Receive enables
1-Enable
TXEN->Transmit enable
1-Enable
TXEN
SYNDET
FE
OE
PE
TXEN
RDY
RXRDY
TXRRDY
FE
->Framing Error sets when a valid stop bit is not detected and reset by ER Command.
OE -> Overrun error reads the character before it is available. It is reset by ER bit in Command word.
PE -> Parity error, 1-Enable parity error reset by ER bit of command word.
RS 232 C
PROGRAM:
ADDRESS
OPCODE
LABEL
MNEMONICS
8100
3E , 36
MVI A , 36
8102
D3 , CE
OUT 0CEH
8104
3E ,0A
MVI A,0A
8106
D3 , C8
OUT 0C8H
8108
3E ,00
MVI A,00
810A
D3 ,C8
OUT 0C8H
810C
3E ,4E
MVI A,4E
810E
D3 ,C2
OUT 0C2H
8110
3E ,37
MVI A, 37H
8112
D3,C2
OUT 0C2H
8114
3E ,41
MVI A, 41H
8116
D3 ,C0
OUT 0C0H
8118
CF
8200
DB, C0
8202
32 ,50 , 82
8205
CF
COMMENTS
Mode set for 8253
RST 1
IN 0C0H
STA 8250H
RST 1
RESULT:
Thus the 8251 is interfaced with 8085 and 8086 and the data was transmitted & received using
interface card.
CONTROL FORMAT:
SC1
SC0
SCO
SC1
RL1
RL0
M2
M1
M0
RL1
RL2
=Counter 0
=Counter latch
=Counter 1
=LSB
=Counter 2
=MSB
=X
=LSB/MSB
M2
M1
M0
MODE
Rate Generator
BCD
BCD:
0=Binary count (16 bit)
1=BCD (11 decoder)
To generate a square wave the control word is formed for a counter 0, using LSB/MSB, Mode3 and
a binary count. The Control word is now 36 H.
0
OPCODE
LABLE
MNEMONICS
COMMENTS
8100
3E, 36
START
MVI A,36H
8102
D3, CE
OUT CEH
8104
3E, 0A
MVI A,0AH
8106
D3, C8
OUT C8H
8108
3E, 00
MVI A,00H
810A
D3, C8
OUT C8H
810C
76
HLT
RESULT:
Thus using the timer interface 8253 square waveform is generated.
DISPLAYING A CHARACTER:
ADDRESS
OPCODE
LABLE
8100
3E, 00
8102
MNEMONICS
COMMENTS
MVI, 00H
D3 ,C2
OUT C2H
8104
3E,CC,00
MVI A, CCH
8106
D3 , C2
OUT C2H
8108
3E ,90
MVI A, 90H
810A
D3 , C2
OUT C2H
810C
3E , 88
MVI A, 88
Display A
810E
D3, C0
OUT C0
8110
3E , FF
MVI A, FF
8112
D3, C0
OUT C0
8114
D3 , C0
OUT C0
8116
D3 , C0
OUT C0
8118
D3 , C0
OUT C0
811A
D3 , C0
OUT C0
811C
76
HLT
OPCODE
8100
DB, C2
8102
LABLE
LOOP
MNEMONICS
COMMENTS
IN C2H
E6, 07
ANI 07H
8104
CA,00,81
JZ LOOP
8107
3E, 40
MVI A, 40H
Command
RAM
8109
D3 , C2
OUT C2H
810B
DB, C0
IN C0H
810D
32, 00, 42
STA 8200H
8110
76
HLT
RESULT:
Thus a keyboard and a display are interfaced with 8085 microprocessor and the assembly
language program for displaying a character and reading the scan code of a key is written.
AIM:
Date:
To perform 16-bit addition, 8-bit subtraction, 8-bit multiplication and division using 8051 micro
controller.
16 BIT ADDITION:
ALGORITHM:
1.Get the LSB of the first operand and add with the LSB of the second operand.
2.Store the LSB of the result.
3.Get the MSB of the first operand and add with the MSB of the second operand.
4.Store the result.
5.Stop the program.
PROGRAM:
ADDRESS
OPCODE
LABLE
9100
C3
CLR C
9101
74,32
MOV A,#DATA L1
Move LSB1 to A
9103
24,CD
ADD A,#DATA L2
9105
90,91,50
MOV DPTR,#4150
9108
F0
MOVX @DPTR, A
Accumulator content is
immediately moved to DPTR
9109
A3
INC DPTR
Increment DPTR
910A
74,54
MOV A,#DATA M1
Move MSB1 to A
910C
34,AB
910E
F0
MOVX @DPTR, A
Accumulator content is
immediately moved to DPTR
910F
80
9110
FE
here
MNEMONICS
COMMENTS
SJMP here
Stop the program
8 BIT SUBTRACTION
PROGRAM:
ADDRESS
OPCODE
9100
C3
LABLE
MNEMONICS
CLR C
COMMENTS
Clear the carry flag
9101
74,C2
MOV A,#DATA1
Move data1 to A
9103
94,02
SUBB A,#DATA2
Data2 is subtracted
accumulator
9105
90,45,00
MOV DPTR,#9500
Initialize DPTR
9108
F0
MOVX @DPTR,A
9109
80
910A
FE
here
from
SJMP here
Stop
8 BIT MULTIPLICATION
PROGRAM:
ADDRESS
OPCODE
LABLE
9100
74,FF
MOV A,#DATA1
9102
75,F0,FF
MOV B, #DATA2
9105
A4
MUL A,B
9106
90,95,00
MOV DPTR,
#9500
9109
F0
MOVX @DPTR,A
910A
A3
INC DPTR
Increment DPTR
910B
E5,F0
MOV A,B
910D
F0
MOVX @DPTR,A
Move A to DPTR
910E
80
910F
FE
Here
MNEMONICS
COMMENTS
SJMP here
Stop the program
8BIT DIVISION
PROGRAM:
ADDRESS
HEXCODE
LABEL
MNEMONICS
COMMENT
9100
74,65
MOV A,#DATA1
9102
75,F0,08
MOV B,#DATA2
9105
84
DIV A,B
Divide A by B
9106
90,95,00
MOV DPTR,#9500
Move 9500toDPTR
9109
F0
MOV @DPTR,A
910A
A3
INC DPTR
Increment DPTR
910B
E5,F0
MOV A,B
910D
F0
MOVX @DPTR,A
910E
80
SJMP here
910F
FE
here
RESULT:
Thus 16 bit addition, 8 bit subtraction ,8 bit multiplication and division were executed using 8051
microcontroller.
EX.NO: 10
DATE :
AIM:
To write a program for the transmission and reception of a character between 8085 and 8253/8251.
APPARATUS REQUIRED:
ALGORITHM:
1. Type the transmission program and execute the program
2. Type the reception of a character and execute
3. To check the reception of a character.
PROGRAM:
FOR TRANSMITTING A CHARACTER:
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
9000
3E,36
MVI A,36H
9002
D3,CE
OUT OCEH
9004
3E,0A
MVI A,0AH
9006
D3,C8
OUT OC8H
9008
3E,00
MVI A,00H
Clear A register
900A
D3,C8
OUT OC8H
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
900C
3E,4E
MVI A,4EH
900E
D3,C2
OUT OC2H
9010
3E,37
MVI A,37H
9012
D3,C2
OUT OC2H
9014
3E,50
MVI A,50H
9016
D3,C0
OUT OC0H
9018
CF
RST
Reset
OPCODE
LABEL
MNEMONICS
COMMENTS
9100
DB,C0
IN 0C0H
9102
32,50,41
STA 9150H
9105
CF
RST
Reset
RESULT:
Thus the transmission and reception of a character between 8085 and 8253/8251 was executed and
verified successfully.
EX.NO: 11
DATE :
AIM:
To perform interfacing of keyboard and seven segment display with 8051.
APPARATUS REQUIRED:
1. 8081 Microprocessor Kit
ALGORITHM:
1. Assemble the program
2. Execute it and press any key in keyboard and then view the result in the accumulator
3. Before pressing any key in keyboard execute the program once.
KEYBOARD PROGRAM:
ADDRESS
OPCODE
LABEL
9000
90,60,61
MOV DPTR,#6061
9003
74,12
MOV A,#12H
Control word
9005
F0
MOVX @DPTR,A
Out to 8279
9006
74,3E
MOV A,#3EH
9008
F0
MOVX @DPTR,A
Out to 8279
9009
74,A0
MOV A,#A0H
Display/write inhibit
900B
F0
MOVX @DPTR,A
Out to 8279
900C
90,60,61
900F
E0
LOOP1
MNEMONICS
COMMENTS
MOV DPTR,#6061
MOVX A,@DPTR
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
9010
54,07
ANL A,#07H
9012
60,F8
JZ 900C (LOOP1)
9014
90,60,60
MOV DPTR,#6060
9017
E0
MOVX A,@DPTR
9018
54,3F
ANL A,#3FH
901A
12,00,BB
LCALL 00 BBH
Break Point
DISPLAY PROGRAM:
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
9200
79,60
MOV R1,#60H
9202
90,60,61
MOV DPTR,#6061H
9205
74,12
MOV A,#12H
Control word
9207
F0
MOVX @DPTR,A
Out to 8279
9208
74,3E
MOV A,#3EH
920A
F0
MOVX @DPTR,A
Out to 8279
920B
74,A0
MOV A,#A0H
Display/write inhibit
920D
F0
MOVX @DPTR,A
Out to 8279
920E
78,08
MOV R0,#08H
8 Digit count
9210
74,00
MOV A,#00H
9212
90,60,60
MOV DPTR,#6060H
9215
F0
9216
D8,FD
DJNZ R0,9215H(L1)
9218
E9
MOV A,R1
7 Segment code to be
displayed
9219
F0
MOVX @DPTR,A
Out to 8279
LOOP1
LOOP2
MOVX @DPTR,A
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
921A
80,FD
SJMP 9219H(L2)
921C
12,00,BB
LCALL 00 BBH
Break Point
OUTPUT:
7 SEGMENT CODES FOR 0 TO F:
FC
60
BA
F2
66
D6
DE
70
FE
76
7E
CE
9C
EA
9E
1E
Hex code
FC
60
a
f
b
g
.h
RESULT:
Thus the interfacing of keyboard and seven segment display with 8051 were executed and verified
successfully.
EX.NO: 12
DATE :
AIM:
To write an assembly language program to perform analog to digital conversion using 8051.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit
2. ADC Interface Kit
3. Power supply 5V
4. Keyboard
PROCEDURE:
1. Assemble the program
2. Vary the pot in the adc chord
3. Execute it and view the output count in the accumulator, which will be displayed in the LCD
display
4. Every time you vary the pot, execute the program and measure the count value in the
accumulator.
5. Repeat the above step for different inputs in the pot
6. After enough of readings have been taken reduce the pot to its minimum value
7. Switch off the power supply and remove all the connections.
ADC PROGRAM:
ADDRESS
OPCODE
LABEL
9000
90,60,03
MOV DPTR,#6003H
9003
74,90
MOV A,#90H
9005
F0
MOVX @DPTR,A
9006
90,60,02
MOV DPTR,#6002H
9009
74,FF
MOV A,#FFH
Start of conversion
900B
F0
MOVX @DPTR,A
900C
90,60,02
MOV DPTR,#6002H
900F
74,00
9011
F0
MOVX @DPTR,A
9012
90,60,02
MOV DPTR,#6002H
9015
74,FF
MOV A,#FFH
9017
F0
MOVX @DPTR,A
9018
12,90,22
LCALL 9022H
Delay routine
901B
90,60,00
MOV DPTR,#6000H
Port A as I/P
901E
E0
MOV A, @DPTR
901F
12,00,BB
LCALL 00 BBH
Break Point
LOOP1
MNEMONICS
COMMENTS
MOV A,#00H
DELAY SUBROUTINE:
ADDRESS
OPCODE
9022
79,FF
9024
00
9025
LABEL
MNEMONICS
COMMENTS
MOV A,#FFH
Delay Count
NOP
No Operation
00
NOP
No Operation
9026
00
NOP
No Operation
9027
00
NOP
No Operation
9028
00
NOP
No Operation
9029
00
NOP
No Operation
902A
00
NOP
No Operation
902B
D9,F7
DJNZ 9024(LOOP1)
902D
22
RET
LOOP1
OUTPUT:
S.NO
1
2
3
4
5
6
ANALOG INPUT
DIGITAL OUTPUT
RESULT:
Thus the analog to digital conversion using 8051 was executed and verified successfully.
EX.NO: 13
DATE :
AIM:
To write an assembly language program to perform digital to analog conversion using 8051.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit
2. DAC Interface Kit
3. Power supply 5V
4. Keyboard
PROCEDURE:
1.
2.
3.
4.
5.
DAC PROGRAM:
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
9000
74,80
MOV A,#80H
9002
90,60,03
MOV DPTR,#6003H
9005
F0
MOVX @DPTR,A
9006
74,80
MOV A,#80H
9008
90,60,01
MOV DPTR,#6001H
Out Port B
900B
F0
MOVX @DPTR,A
ADDRESS
OPCODE
900C
12,00,BB
LABEL
MNEMONICS
COMMENTS
LCALL 00BBH
Break point
OUTPUT:
S.NO
DIGITAL INPUT
ANALOG OUTPUT
1
2
3
4
5
RESULT:
Thus the digital to analog conversion using 8051 was executed and verified successfully.
AIM:
To perform stepper motor control using 8051 microcontroller.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit
2. DC motor interfacing board
3. Power supply 5V
4. Keyboard
PROCEDURE:
1.
2.
3.
4.
5.
DC MOTOR PROGRAM:
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
9000
74,80
MOV A,#80H
9002
90,60,03
MOV DPTR,#6003H
9005
F0
MOVX @DPTR,A
9006
74,80
MOV A,#80H
9008
90,60,01
MOV DPTR,#6001H
Out Port B
900B
F0
MOVX @DPTR,A
900C
12,00,BB
LCALL 00BBH
Break point
RESULT:
Thus the DC motor was interfaced successfully with 8051 and verified.
EX.NO: 15
DATE :
AIM:
To perform stepper motor control using 8051 microcontroller.
APPARATUS REQUIRED:
1. 8051 Microprocessor Kit-1
2. Power supply 5V
3. Keyboard-1
4. Serial interface cable
5. Stepper motor
6. Stepper motor interfacing board
ALGORITHM:
1.
2.
3.
4.
5.
PROGRAM:
CLOCK WISE DIRECTION:
ADDRESS
OPCODE
LABEL
9000
90,60,03
MOV DPTR,#6003
9003
74,80
MOV A,#80H
9005
F0
MOVX @DPTR,A
9006
90,60,00
MOV DPTR,#6000
9009
74,05
900B
F0
MOVX @DPTR,A
900C
12,90,24
LCALL 9024(DELAY)
Call Delay
900F
74,07
9011
F0
MOVX @DPTR,A
9012
12,90,24
LCALL 9024(DELAY)
Delay
9015
74,06
MOV A,#06H
9017
F0
MOVX @DPTR,A
9018
12,90,24
LCALL 9024(DELAY)
Delay
901B
74,04
MOV A,#04H
Fourth sequence
901D
F0
MOVX @DPTR,A
901E
12,90,24
LCALL 9024(DELAY)
Delay
9021
02,90,09
LJMP 9009(LOOP1)
Repeat
LOOP1
MNEMONICS
MOV A,#05H
COMMENTS
Control port
All bits outputs
First step sequence
OPCODE
9000
90,60,03
LABEL
MNEMONICS
MOV DPTR,#6003
COMMENTS
Control port
ADDRESS
OPCODE
LABEL
MNEMONICS
COMMENTS
9003
74,80
MOV A,#80H
9005
F0
MOVX @DPTR,A
9006
90,60,00
MOV DPTR,#6000
9009
74,04
900B
F0
MOVX @DPTR,A
900C
12,90,24
LCALL 9024(DELAY)
Call Delay
900F
74,06
9011
F0
MOVX @DPTR,A
9012
12,90,24
LCALL 9024(DELAY)
Delay
9015
74,07
MOV A,#07H
9017
F0
MOVX @DPTR,A
9018
12,90,24
LCALL 9024(DELAY)
Delay
901B
74,05
MOV A,#05H
Fourth sequence
901D
F0
MOVX @DPTR,A
901E
12,90,24
LCALL 9024(DELAY)
Delay
9021
02,90,09
LJMP 9009(LOOP1)
Repeat
LOOP2
MOV A,#04H
DELAY SUBROUTINE:
ADDRESS
OPCODE
LABEL
MNEMONICS
9024
79,0A
MOV R1,#0AH
9026
74,40
LOOP3
MOV A,#40H
9028
00
LOOP4
NOP
9029
00
NOP
902A
00
NOP
902B
00
NOP
902C
14
DEC A
COMMENTS
ADDRESS
OPCODE
LABEL
MNEMONICS
902D
70,F9
JNZ 9028(LOOP4)
902F
D9,F5
DJNZ R1,9026(LOOP3)
9031
22
RET
COMMENTS
RESULT:
Thus the stepper motor was interfaced successfully with 8051 and the full step rotation for both
clockwise and anti-clockwise was verified.