CS-2259-MICROPROCESSOR-LABORATORY vels.pdf
description
Transcript of CS-2259-MICROPROCESSOR-LABORATORY vels.pdf
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
1
VEL TECH HIGH TECHDr.RANGARAJAN Dr.SAKUNTHALA
ENGINEERING COLLEGE(ISO 9001: 2000 Certified Institution & NBA Accredited)
(Owned by VEL Sree Dr.RANGARAJAN Dr. Sakunthala Rangarajan Educational Academy1997)
CS 2259-MICROPROCESSORLABORATORY
Approved by AICTE, New Delhi & Affiliated to Anna UniversityNo 60, Avadi-Vel tech Road, Chennai – 600 062
PREPARED BY (HOD/ECE)E.JAYAPRAKASH ESTHER RANI.PN.PRABHAKARANMUBEEN MUBARAK
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
2
CS 2259-MICROPROCESSOR LABORATORY
CS2259 MICROPROCESSORS LABORATORY 0 0 3 2(Common to CSE & IT)AIM: To learn the assembly language programming of 8085,8086 and 8051 and also
to give a practical training of interfacing the peripheral devices with theprocessor.
OBJECTIVES: To implement the assembly language programming of 8085,8086 and 8051. To study the system function calls like BIOS/DOS. To experiment the interface concepts of various peripheral device with the
processor.Experiments in the following:1. Programming with 80852. Programming with 8086-experiments including BIOS/DOS calls:3. Keyboard control, Display, File Manipulation.4. Interfacing with 8085/8086-8255,82535. Interfacing with 8085/8086-8279,82516. 8051 Microcontroller based experiments for Control Applications7. Mini- Project
TOTAL: 45 PERIODS
List of equipments/components for 30 students (two per batch)1. 8085 Trainer Kit with onboard 8255, 8253, 8279 and 8251 – 15 nos.2. TASM/MASM simulator in PC (8086 programs) – 30 nos.3. 8051 trainer kit – 15 nos.4. Interfacing with 8086 – PC add-on cards with 8255, 8253, 8279 and 8251 – 15nos.5. Stepper motor interfacing module – 5 nos.6. Traffic light controller interfacing module – 5 nos.7. ADC, DAC interfacing module – 5 nos.8. CRO’s – 5 nos.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
3http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
4
ADDITION OF TWO 8-BIT NUMBERS WITH CARRY USING 8085
AIM
To write an assembly language program to add the two 8-bit numbers
with carry.
APPARATUS REQUIRED
1. 8085 Microprocessor kit
2. Power chord
ALGORITHM
1. Clear C-register for carry.
2. Move the first data from memory to accumulator and move it to B-
register.
3. Move the second data from memory to accumulator.
4. Add the content of B-register with Accumulator.
5. Check for carry. If carry=’1’ then go to step 6 else go to step 7.
6. Increment the C-register
7. Store the sum in memory.
8. Move the carry to accumulator and store in memory.
9. Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
5
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA 6200 3A 00 62
6103 MOV B,A 47
6104 LDA 6201 3A 01 62
6107 MVI C,00 0E 00
6109 ADD B 80
610A JNC LOOP D2 0E 61
610D INR C 0C
610E LOOP STA 6202 32 02 62
6111 MOV A,C 79
6112 STA 6203 32 03 62
6115 HLT 76
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 02H 6202 07H (sum)
6201 05H 6203 00H (carry)
RESULT Thus the assembly language program to add the two 8-bit
numbers was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
6
SUBTRACTION OF TWO 8-BIT NUMBERS WITH BORROW
USING 8085
AIM
To write an assembly language program to subtract the two 8-bit
numbers with BORROW.
APPARATUS REQUIRED
1. 8085 Microprocessor kit
2. Power chord.
ALGORITHM
1. Clear C-register for sign.
2. Move the subtrahend from memory to accumulator and move it to
B-register.
3. Move the minuend from memory to accumulator.
4. Subtract the content of B-register from Accumulator.
5. Check for carry. If carry=’1’ then go to step 6 else go to step 7.
6. Increment the C-register. Complement the accumulator and add
01H.
7. Store the Difference in memory.
8. Move the sign to accumulator and store in memory.
9. Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
7
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA 6201 3A 01 62
6103 MOV B,A 47
6104 LDA 6200 3A 00 62
6107 MVI C,00 0E 00
6109 SUB B 90
610A JNC LOOP D2 11 61
610D INR C 0C
610E CMA 2F
610F ADI 01H C6 01
6111 LOOP STA 6202 32 02 62
6114 MOV A,C 79
6115 STA 6203 32 03 62
6118 HLT 76
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 04H 6202 02H (Difference)
6201 02H 6203 00H (sign)
RESULT
Thus the assembly language program to subtract the two 8-bit
numbers was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
8
MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8085
AIM
To write an assembly language program to multiply the two 8-bit
numbers APPARATUS REQUIRED
1. 8085 Microprocessor kit
2. Power chord
ALGORITHM
1. Load the address of the first data in HL pair (pointer).
2. Clear C-register for overflow (carry).
3. Clear the accumulator.
4. Move the first data to B-register.
5. Increment the pointer.
6. Move the second data to D-register from memory (multiplicand).
7. Add the content of D-register to accumulator.
8. Check for carry, if carry = 1, go to step 9,or carry = 0, go to step
10.
9. Increment the C- register.
10.Decrement B- registers (count).
11.Check whether count has reached zero. If ZF = 0, repeat step 7
through 11, or if ZF = 1 go to next step.
12.Increment the pointer and store LSB of the product in memory.
13.Increment the pointer and store MSB of the product in memory.
14.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
9
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LXI H, 6200 21 00 62
6103 MVI C,00 0E,00
6105 XRA A AF
6106 MOV B,M 23
6107 INX H B8
6108 MOV D,M 56
6109 REPT ADD D 82
610A JNC AHEAD D2 0E 61
610D INR C 0C
610E AHEAD DCR B 05
610F JNZ REPT C2 09 61
6112 INX H 23
6113 MOV M,A 77
6114 INX H 23
6115 MOV M,C 71
6116 HLT 76
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 02H 6202 08H (LSB of product)
6201 04H 6203 00H (MSB of product)
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
10
RESULT
Thus the assembly language program to multiply the two 8-bit
numbers was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
11
DIVISION OF TWO 8-BIT NUMBERS WITH BORROW
AIM
To write an assembly language program to divide the two 8-bit
numbers with remainder.
APPARATUS REQUIRED
1. 8085 Microprocessor kit
2. Power chord
ALGORITHM
1. Load the divisor in accumulator and move it to B- register.
2. Load the dividend in accumulator.
3. Clear C-register to account for quotient.
4. Check whether divisor is less than dividend
If divisor is less than dividend, go to step 8, otherwise go to next
step.
5. Subtract the content of B register from accumulator.
6. Increment the content of C-register (quotient).
7. Go to step 4.
8. Store the content of accumulator (remainder) in memory.
9. Move the content of C-register (quotient) to accumulator and store
in memory.
10.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
12
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA 4201 3A 01 42
6103 MOV B,A 47
6104 LDA 4200 3A 00 42
6107 MVI C,00 0E 00
6109 AGAIN CMP B B8
610A JC STORE DA 12 61
610D SUB B 90
610E INR C 0C
610F JNC AGAIN C3 09 61
6112 STORE STA 6203 32 03 42
6115 MOV A,C 79
6116 STA 6202 32 02 62
6119 HLT 76
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 08H 6202 04H (Quotient)
6201 02H 6203 00H (Remainder)
RESULT
Thus the assembly language program to divide the two 8-bit numbers
was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
13
MAXIMUM OF NUMBER IN THE ARRAY USING 8085
AIM
To write an assembly language program to search the maximum of
number data in the array.
APPARATUS REQUIRED
1. 8085 Microprocessor kit
2. Power chord
ALGORITHM
1. Load the address of the first element of the array in HL register
pair.
2. Move the count to B-register.
3. Increment the pointer.
4. Get the first data in accumulator.
5. Decrement the count.
6. Increment the pointer.
7. Compare the content of memory addressed by HL pair with that of
accumulator.
8. If carry=0, go to step 10, or if carry= 1, go to step 9.
9. Move the content memory addressed HL to accumulator.
10.Decrement the count.
11.Check for zero of the count. If ZF = 0, go to step 6, or If ZF = 1, go
to next step.
12.Store the smallest data in memory.
13.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
14
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LXI H,6200 21 00 62
6103 MOV B,M 46
6104 INX H 23
6105 MOV A,M 7E
6106 DCR B 05
6107 LOOP INX H 23
6108 CMP M BE
6109 JNC AHEAD D2 OD 61
610C MOV A,M 7E
611D AHEAD DCR B 05
610E JNZ LOOP C2 07 61
6111 STA 6300 32 00 63
6114 HLT 76
OBSERVATIONINPUT OUTPUT
Address Data Address Data
6200 05H
6300 0CH
6201 0AH
6202 03H
6203 08H
6204 06H
6205 0CH
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
15
RESULT
Thus the assembly language program to search the largest data in an
array was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
16
MINIMUM OF NUMBER IN THE ARRAY USING 8085
AIM
To write an assembly language program to search the minimum of
number in the array.
APPARATUS REQUIRED
8085 Microprocessor kit
Power chord
ALGORITHM
1. Load the address of the first element of the array in HL register
pair.
2. Move the count to B-register.
3. Increment the pointer.
4. Get the first data in accumulator.
5. Decrement the count.
6. Increment the pointer.
7. Compare the content of memory addressed by HL pair with that of
accumulator.
8. If carry=1,, go to step 10, or if carry= 0, go to step 9.
9. Move the content memory addressed HL to accumulator.
10.Decrement the count.
11.Check for zero of the count. If ZF = 0, go to step 6, or If ZF = 1, go
to next step.
12.Store the smallest data in memory.
13.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
17
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LXI H,6200 21 00 62
6103 MOV B,M 46
6104 INX H 23
6105 MOV A,M 7E
6106 DCR B 05
6107 LOOP INX H 23
6108 CMP M BE
6109 JC AHEAD DA OD 61
610C MOV A,M 7E
611D AHEAD DCR B 05
610E JNZ LOOP C2 07 41
6111 STA 6300 32 00 63
6114 HLT 76
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 05H
6300 03H
6201 0AH
6202 03H
6203 08H
6204 06H
6205 0CH
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
18
RESULT
Thus the assembly language program to search the smallest data in an
array was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
19
ARRANGE THE GIVEN NUMBER IN ASCENDING ORDER USING
8085
AIM
To write an assembly language program to sort an array of data in ascending
order.
ALGORITHM
1. Load the count value from memory to A-register and store it in B-
register.
2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pair as data address pointer.
4. Set C-register as counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address
pointer.
6. Increment the HL pair (data address pointer).
7. Compare the data pointed by HL with accumulator.
8. If carry flag is set (if the content of accumulator is smaller than
memory) then go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the
accumulator.
10.Decrement C-register. If zero flag is reset go to step 6, otherwise,
go to next step.
11.Decrement B-register. If zero flag is reset go to step 3, otherwise,
go to next step.
12.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
20
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA,6200 3A 00 62
6103 MOV B,A 47
6104 DCR B 05
6105 LOOP2 LXI H,6200 21 00 62
6108 MOV C,M 4E
6109 DCR C 0D
610A INX H 23
610B LOOP1 MOV A,M 7E
610C INX H 23
611D CMP M BE
610E JC AHEAD DA 16 61
6111 MOV D,M 56
6112 MOV M,A 77
6113 DCX H 2B
6114 MOV M,D 72
6115 INX H 23
6116 AHEAD DCR C 0D
6117 JNZ LOOP1 C2 0B 61
611A DCR B 05
611B JNZ LOOP2 C2 05 61
611E HLT 76
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
21
OBSERVATION
INPUT (Before sorting) OUTPUT (After sorting)
Address Data Address Data
6200 04H 6200 04H
6201 0AH 6201 03H
6202 0CH 6202 06H
6203 06H 6203 0AH
6204 03H 6204 0CH
RESULT
Thus the assembly language program to sort an array of data in
ascending order was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
22
ARRANGE THE GIVEN NUMBER IN DESCENDING ORDER
USING 8085
AIM
To write an assembly language program to sort an array of data in
descending order.
ALGORITHM
1. Load the count value from memory to A-register and store it in B-
register.
2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pair as data address pointer.
4. Set C-register as counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address
pointer.
6. Increment the HL pair (data address pointer).
7. Compare the data pointed by HL with accumulator.
8. If carry flag is reset (if the content of accumulator is larger than
memory) then go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the
accumulator.
10.Decrement C-register. If zero flag is reset go to step 6, otherwise,
go to next step.
11.Decrement B-register. If zero flag is reset go to step 3, otherwise,
go to next step.
12.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
23
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA,6200 3A 00 62
6103 MOV B,A 47
6104 DCR B 05
6105 LOOP2 LXI H,6200 21 00 62
6108 MOV C,M 4E
6109 DCR C 0D
610A INX H 23
610B LOOP1 MOV A,M 7E
610C INX H 23
611D CMP M BE
610E JNC AHEAD D2 16 61
6111 MOV D,M 56
6112 MOV M,A 77
6113 DCX H 2B
6114 MOV M,D 72
6115 INX H 23
6116 AHEAD DCR C 0D
6117 JNZ LOOP1 C2 0B 61
611A DCR B 05
611B JNZ LOOP2 C2 05 61
611E HLT 76
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
24
OBSERVATION
INPUT (Before sorting) OUTPUT (After sorting)
Address Data Address Data
6200 04H 6200 04H
6201 0AH 6201 0CH
6202 0CH 6202 0AH
6203 06H 6203 06H
6204 03H 6204 03H
RESULT
Thus the assembly language program to sort an array of data in
descending order was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
25
CONVERT THE ASCII CODE TO HEX CODE USING 8085
AIM
To write an assembly language program to convert the ASCII code to
HEX code.
APPARATUS REQUIRED
8085 Microprocessor kit
Power chord
ALGORITHM
1. Set HL pair as pointer for ASCII array.
2. Set D-register as counter for number of data in the array.
3. Set BC pair as pointer for binary (Hexa) array.
4. Increment HL pair and move a data of ASCII array to A-register.
5. Call subroutine BIN to find the binary (Hexa) value.
6. The binary (Hexa) value available in A-register is stored in
memory.
7. Increment BC pair.
8. Decrement D-register. If ZF = 0, then go to step 4. if ZF = 1, then
step.
Algorithm for subroutine BIN
1. Subtract 30 from A-register.
2. Compare the content of A-register with 0A.
3. If CY = 1, go to step 5. If CY = 0, go to next step.
4. Subtract 07 from A-register.
5. Return to main program.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
26
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LXI H,6200 21 00 62
6103 MOV D,M 56
6104 LXI B,6300 01 00 63
6107 INX H 23
6108 MOV A,M 7E
6109 CALL BIN CD 13 61
610C STAX B 02
611D INX B 03
610E DCR D 15
610F JNZ LOOP C2 07 61
6112 HLT 76
6113 BIN SUI 30 D6 07
6115 CPI 0A FE 0A
6117 RC D8
6118 SUI 07 D6 07
611A RET C9
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
27
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 01 6202 30H
6201 0A 6203 41H
RESULT
Thus the assembly language program to covert the ASCII code to
HEX code was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
28
CONVERT THE HEX CODE TO ASCII CODE USING 8085
AIM
To write an assembly language program to convert the HEXI code to
ASCII code.
APPARATUS REQUIRED
8085 Microprocessor kit
Power chord
ALGORITHM
1. Load the given data in A register and move to B register.
2. Mask the upper nibble of HEX data.
3. Call subroutine code to find the ASCII value of the lower nibble
and store in memory.
4. Move B register to A register Mask the lower nibble .
5. Rotate the upper nibble to lower nibble
6. Call subroutine code to find the ASCII value of the upper nibble
and store in memory.
Algorithm for subroutine CODE
1. Compare the content of A-register with 0A.
2. If CY = 1, go to step 4. If CY = 0, go to next step.
3. Add 07H to A register.
4. Add 30H to A register
5. Return to main program.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
29
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA 4200 3A 00 62
6103 MOV B,A 47
6104 ANI 0F E6 0F
6106 CALL CODE CD 1A 61
6109 STA 4201 32 01 62
610C MOV A,B 78
610D ANI F0 E6 F0
610F RLC 07
6110 RLC 07
6111 RLC 07
6112 RLC 07
6113 CALL CODE CD 1A 41
6116 STA 4202 32 02 62
6119 HLT 76
611A CODE CPI 0AH FE 0A
611C JC SKIP DA 21 62
611F ADI 07H C6 07
6121 ADI 30H C6 30
6123 RET C9
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
30
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 30H6201 01H
6202 00H
RESULT
Thus the assembly language program to covert the HEX code to
ASCII code was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
31
CONVERT THE HEX CODE TO BCD CODE USING 8085AIM
To write an assembly language program to convert the HEXI code to
BCD code.
APPARATUS REQUIRED
8085 Microprocessor kit
Power chord
ALGORITHM
1. Clear D and E registers to count for hundreds and tens.
2. Load the HEX data in A register.
3. Compare A-register with 64H. If carry=’1’ then go to step 7 else
go to next step.
4. Subtract 64H from A register.
5. Increment E register
6. Go to step 3
7. Compare A register with 0AH. If carry=’1’ then go to step 10 else
go to next step
8. Subtract 0AH from A register.
9. Increment D register and Go to step 7
10.Save the units, tens and hundreds.
11.Stop
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
32
PROGRAMMEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 MVI E,00H IE 00
6102 MOV D,E 53
6103 LDA 6200 3A 00 62
6106 HUNDRED CPI 64H FE 64
6108 JC TEN DA 11 61
610B SUI 64H D6 64
610D INR E 1C
610E JMP HUNDRED C3 06 61
6111 TEN CPI 0AH FE 0A
6113 JC UNIT DA 1C 61
6116 SUI 0AH D6 0A
6118 INR D 14
6119 JMP TEN C3 11 61
611C UNIT MOV C,A 4F
611D MOV A,D 7A
611E RLC 07
611F RLC 07
6120 RLC 07
6121 RLC 07
6122 ADD C 81
6123 STA 6201 32 01 62
6126 MOV A,E 7B
6127 STA 6202 32 02 62
612A HLT 76
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
33
OBSERVATION
INPUT OUTPUT
Address Data Address Data
4200 55H4201 55H (Tens and Units)
4202 00H (hundreds)
RESULT
Thus the assembly language program to covert the HEX code to BCD code
was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
34
CONVERT THE BCD CODE TO HEX CODE USING 8085
AIM
To write an assembly language program to convert the BCD code to
HEX code.
APPARATUS REQUIRED
1. 8085 Microprocessor kit
2. Power chord
ALGORITHM
1. Get the BCD data in A register and save in B register.
2. Mask the lower nibble of BCD data
3. Rotate the upper nibble to lower nibble and save in B register.
4. Clear the accumulator.
5. Move 0Ah to C register.
6. Add B register to A register.
7. Decrement the C-register. If C=’0’ then go to next step else go to
step 6.
8. Save the product in B register.
9. Get the BCD data in A register and mask the upper nibble.
10.Add the units to product.
11.Store the HEX value.
12.Stop
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
35
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 LDA 6200 3A 00 62
6103 MOV E,A 5F
6104 ANI 0FH E6 F0
6106 RLC 07
6107 RLC 07
6108 RLC 07
6109 RLC 07
610A MOV B,A 47
610B XRA A AF
610C MVI C,0AH 0E 0A
610E ADD B 80
610F DCR C 0D
6110 JNZ REP C2 0E 61
6113 MOV B,A 47
6114 MOV A,E 7B
6115 ANI 0FH E6 F0
6117 ADD B 80
6118 STA 6201 32 01 62
611B HLT 76
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
36
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 10 6201 0AH
RESULT
Thus the assembly language program to covert the HEX code to
ASCII code was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
37
ADC INTERFACING USING 8085AIM
To write an assembly language program to interface ADC board with
8085.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord, ADC interface board.
ALGORITHM
1. Find the data for corresponding channel.
2. Move the control word to accumulator and place in ADC.
3. Get the signal from ADC.
4. If the signal is valid go to next step else go to step 3.
5. Find the display value for the input.
6. Move this value to the display board.
7. Go to step 1.
8. Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
38
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 START MVI A,00H 3E 004102 OUT CNT D3 C84104 ORI 08 F6 084106 OUT CNT D3 C84108 NOP 004109 NOP 00
410A NOP 00
410B ANI F7 E6 F7
410D OUT CNT D3 C8
410F NOP 00
4110 NOP 00
4111 NOP 00
4112 MVI A,10H 3E 10
4114 OUT CNT D3 C8
4116 NOP 00
4117 NOP 00
4118 NOP 00
4119 MVI A,20H 3E 20
411B OUT CNT D3 C8
411D LOOP IN EOC DB C0
411F ANI 01 E6 01
4121 JNZ LOOP C2 1D 41
4124 IN DATA DB C4
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
39
4126 MOV B,A 47
4127 LXI H,8200 21 00 42
412A MVI A,94 3E 94
412C OUT CNT D3 01
412E MOV A,B 78
412F ANI 0F E6 0F
4131 RRC 07
4132 RRC 07
4133 RRC 07
4134 RRC 07
4135 MOV L,A 6F
4136 MOV A,M 7E
4137 OUT DATA D3 00
4139 MOV A,B 78
413A ANI 0F E6 0F
413C MOV L,A 6F
413D MOV A,M 7E
413E OUT DAT D3 00
4140 JMP START C3 10 41
4143 HLT 76
4200 0C 9F 4A 0B
99 29 28 8F
08 89 88 38
6C 1A 68 E8
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
40
OBSERVATION
S.No ANALOG INPUT DIGITAL OUTPUT
RESULTThus the assembly language program to interface ADC board with
8085 was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
41
SQUARE WAVE GENERATION WITH 8085 USING DACAIM
To write an assembly language program to generate square wave with
amplitude of 5 volts.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord, DAC interface chord.
ALGORITHM
1. Clear the accumulator.
2. Get the data to accumulator for 5 volts
3. Move this data to DAC kit.
4. Call the delay routine for required time interval.
5. Get the data to accumulator for 0 volts
6. Move this data to DAC kit.
7. Call the delay routine for required time interval.
8. Go to the first step.
9. Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
42
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 START MVI A,FFH 3E FF
4102 OUT C0 D3 C0
4104 CALL DELAY CD
4107 MVI A, 00H 3E 00
4109 OUT C0 D3 C0
410B CALL DELAY CD 20 41
410E JMP START C3 00 41
4111 HLT 76
4120 DELAY PUSH B C5
4121 MVI C,05 0E 05
4123 LOOP3 LXI D,FFFFH 11 FF FF
4126 LOOP2 DCX D 1B
4127 MOV A,D 7A
4128 ORA E B3
4129 JNZ LOOP2 C2 26 41
412C DCR C 0D
412D JNZ LOOP3 C2 23 41
4130 POP B C1
4131 RET C9
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
43
OBSERVATION
S.No TIME PERIOD (msec) AMPLITUDE (volts)
1 1.6 * 2 = 3.2mse 2.5 * 2 = 5 V
RESULT
Thus the assembly language program to generate square wave was
written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
44
TRIANGULAR WAVE GENERATION WITH 8085 USING DAC
AIM
To write an assembly language program to generate triangular wave
with amplitude of 5 volts.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord, DAC interface chord.
ALGORITHM
1. Clear the accumulator.
2. Move this data to DAC kit.
3. Increment the accumulator.
4. If ACC=’00’then go to step 5 else step 2
5. Get the data to accumulator for 5 volts
6. Move this data to DAC kit.
7. Decrement the accumulator.
8. If ACC=’00’then go to step 9 else step 6
9. Go to the step 1.
10.Stop.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
45
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 START XRA A AF
4101 LOOP OUT C0 D3 C0
4103 INR A 3C
4104 JNZ LOOP C2 01 41
4107 MVI A,FFH 3E FF
4109 LOOP1 OUT C0 D3 C0
410B DCR A 3D
410C JNZ LOOP1 C2 09 41
410F JMP START C3 00 41
OBSERVATION
S.No TIME PERIOD (msec) AMPLITUDE (volts)
1 1.2* 2 = 2.4mse 2.4 * 2 = 4.8 V
RESULT
Thus the assembly language program to generate triangular wave was
written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
46
SAWTOOTH WAVE GENERATION USING DAC USING 8085AIM
To write an assembly language program to generate saw tooth wave
with amplitude of 5 volts.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord, DAC interface chord.
ALGORITHM
1. Clear the accumulator.
2. Move this data to DAC kit.
3. Increment the accumulator.
4. Go to the step 2
5. Stop.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
8100 START XRA A AF
8101 LOOP OUT C0 D3 C0
8103 INR A 3C
8104 JMP LOOP C2 01 81
8107 HLT 76
OBSERVATION
S.No TIME PERIOD (msec) AMPLITUDE (volts)
1 1.4 * 2 = 2.8mse 2.4 * 2 = 4.8 V
RESULT
Thus the assembly language program to generate saw tooth wave was
written and executed successfully
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
47
TRAFFIC LIGHT CONTROLLER USING 8085AIM
To write an assembly language program to interface traffic light
controller with 8085 using 8255.
APPARATUS REQUIRED8085 Microprocessor kit,Power chord,Traffic light interface board
ALGORITHM1. Find the control word for 8255 and data corresponding to the given
condition’s and load this data in to the memory location.
2. Get the number of conditions in the C-register.
3. Move the control word to accumulator and place in 8255.
4. Move the first data to accumulator and place in port-A.
5. Move the next data to accumulator and place in port-B.
6. Move the next data to accumulator and place in port-C.
7. Call the delay routine.
8. Decrement the C-register. If C=’0’ then go to next step else go to
step 3.
9. Go to step 1 and Stop
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 START LXI H,4500H 21, 00, 45
4103 MOV A,M 7E
4104 OUT CONT D3, 0F
4106 MIV C, 04H 0E, 04
4108 LOOP INX H 234109 MOV A, M 7E
410A OUT PORTA D3, 0C
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
48
410C INX H 23
410D MOV A, M 7E
410E OUT PORTB D3, 0D
4110 INX H 23
4111 MOV A, M 7E
4112 OUT PORTC D3, 0E
4114 CALL DELAY CD, 00, 42
4117 DCR C 0D
4118 JNZ LOOP C2, 08, 41
411B JMP START C3, 00, 41
411E HLT 76
DELAY PROGRAM
4200 DELAY MVI C, 05H 0E, 05
4202 LOOP2 LXI D, FFFFH 11, FF, FF
4205 LOOP1 DCX D 1B
4206 MOV A, D 7A
4207 ORA E B3
4208 JNZ LOOP1 C2, 05, 42
420B DCR C 0D
420C JNZ LOOP2 C2, 02, 42
420F RET C9
INPUT DATA
4500 80, 84, 2E, 4C
4504 84, 9D, 90, 93
4507 2B, 10, 64, 27, 12
PORT A [ {D0 - D20}………0 - OFF & 1 – ON ]
D8 D7 D6 D5 D4 D3 D2 D1
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
49
POSITION 1 1 0 0 0 0 1 0 0 84H
POSITION 2 1 0 0 0 0 1 0 0 84H
POSITION 3 1 0 0 1 0 0 1 1 93H
POSITION 4 0 1 1 0 0 1 0 0 64H
PORT B [ {DL1 - DL8}………0 - GREEN & 1 – RED ]
D20 D19 D18 D17 DL78 DL56 DL34 DL12POSITION
10 0 1 0 1 1 1 0 2EH
POSITION
21 0 0 1 1 1 0 1 9DH
POSITION
30 0 1 0 1 0 1 1 2BH
POSITION
40 0 1 0 0 1 1 1 27H
PORT C [ {D0 - D20}………0 - OFF & 1 – ON ]
D16 D15 D14 D13 D12 D11 D10 D9POSITION
10 1 0 0 1 1 0 0
4CH
POSITION
21 0 0 1 0 0 0 0
90H
POSITION
30 0 0 1 0 0 0 0
10H
POSITION
40 0 0 1 0 0 1 0
12H
RESULT
Thus the assembly language program to interface traffic light
controller with 8085 using 8255 was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
50
TIMER INTERFACE WITH 8085 USING 8251AIM
To write an assembly language program to timer interface with 8085
using 8251.
APPARATUS REQUIRED8085 Microprocessor kit, Power chord, keyboard/display interface board.
ALGORITHM1. Find the control words for 8279 and data corresponding to the key and load
this data in to the memory location.2. Move the control word to accumulator and place in 8279.
3. Clear all the display
4. Scan the key board continuously.
5. If any key pressed go to next step else go to step 4.
6. Find the display value for the pressed key.
7. Move this value to the display board
8. Stop.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 LXI H,CLEAR 21 50 41
4103 MVI B,08 16 08
4105 MVI A,10H 3E 10
4107 OUT CNT D3 C2
4109 MVI A,CC 3E,CC
410B OUT CNT D3 C2
410D MVI A,90H 3E,90
410F OUT CNT D3 C2
4111 MOV A,M 7E
4112 BACK OUT DAT D3 C0
4114 INX H 23
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
51
4115 DCR B 05
4112 JNZ BACK C2 12 41
4114 LOOP IN CNT DB C2
4117 ANI 07H E6 07
4118 JZ LOOP CA 19 41
4119 MVI A,40H 3E 40
411C OUT CNT D3 C2
411F IN DAT DB C0
4120 ANI 0FH E6 0F
4121 MOV L,A 6F
4123 MVI H,82H 26 82
4126 MOV A,M 7E
4127 OUT DAT D3 C0
4128 JMP LOOP C3 19 41
4129 HLT
4150 FF FF FF FF
FF FF FF FF
8200 0C 9F 4A 0B
99 29 28 8F
08 89 88 38
6C 1A 68 E8
RESULT
Thus the assembly language program to timer interface with 8085
using 8251 was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
52
KEYBOARD/DISPLAY INTERFACE WITH 8085 USING 8279AIM
To write an assembly language program to interface keyboard/display
board with 8085 using 8279.
APPARATUS REQUIRED8085 Microprocessor kit, Power chord, keyboard/display interface board.
ALGORITHM1. Find the control words for 8279 and data corresponding to the key and load
this data in to the memory location.
2. Move the control word to accumulator and place in 8279.
3. Clear all the display
4. Scan the key board continuously.
5. If any key pressed go to next step else go to step 4.
6. Find the display value for the pressed key.
7. Move this value to the display board and Stop.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 LXI H,CLEAR 21 50 41
4103 MVI B,08 16 08
4105 MVI A,10H 3E 10
4107 OUT CNT D3 C2
4109 MVI A,CC 3E,CC
410B OUT CNT D3 C2
410D MVI A,90H 3E,90
410F OUT CNT D3 C2
4111 MOV A,M 7E
4112 BACK OUT DAT D3 C0
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
53
4114 INX H 23
4115 DCR B 05
4112 JNZ BACK C2 12 41
4114 LOOP IN CNT DB C2
4117 ANI 07H E6 07
4118 JZ LOOP CA 19 41
4119 MVI A,40H 3E 40
411C OUT CNT D3 C2
411F IN DAT DB C0
4120 ANI 0FH E6 0F
4121 MOV L,A 6F
4123 MVI H,82H 26 82
4126 MOV A,M 7E
4127 OUT DAT D3 C0
4128 JMP LOOP C3 19 41
4129 HLT
4150 FF FF FF FF
FF FF FF FF
4200 0C 9F 4A 0B
99 29 28 8F
08 89 88 38
6C 1A 68 E8
RESULT
Thus the assembly language program to interface keyboard/display
board with 8085 using 8279 was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
54
TIMER INTERFACE WITH 8085 USING 8254
AIM
To write an assembly language program to timer interface with 8085
using 8254.
APPARATUS REQUIRED8085 Microprocessor kit, Power chord, 8254 interface board.
ALGORITHM1. Find the control words for 8279 and data corresponding to the key and load
this data in to the memory location.
2. Move the control word to accumulator and place in 8279.
3. Clear all the display
4. Scan the key board continuously.
5. If any key pressed go to next step else go to step 4.
6. Find the display value for the pressed key.
7. Move this value to the display board and Stop.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
4100 LXI H,CLEAR 21 50 41
4103 MVI B,08 16 08
4105 MVI A,10H 3E 10
4107 OUT CNT D3 C2
4109 MVI A,CC 3E,CC
410B OUT CNT D3 C2
410D MVI A,90H 3E,90
410F OUT CNT D3 C2
4111 MOV A,M 7E
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
55
4112 BACK OUT DAT D3 C0
4114 INX H 23
4115 DCR B 05
4112 JNZ BACK C2 12 41
4114 LOOP IN CNT DB C2
4117 ANI 07H E6 07
4118 JZ LOOP CA 19 41
4119 MVI A,40H 3E 40
411C OUT CNT D3 C2
411F IN DAT DB C0
4120 ANI 0FH E6 0F
4121 MOV L,A 6F
4123 MVI H,82H 26 82
4126 MOV A,M 7E
4127 OUT DAT D3 C0
4128 JMP LOOP C3 19 41
4129 HLT
4150 FF FF FF FF
FF FF FF FF
8200 0C 9F 4A 0B
99 29 28 8F
08 89 88 38
6C 1A 68 E8
RESULT
Thus the assembly language program to timer interface with 8085
using 8254 was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
56
ADDITION OF TWO 16-BIT NUMBERS USING 8085
AIMTo write an assembly language program to add the two 16-bit
numbers using microprocessor instruction set.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord.
ALGORITHM
1. Initialize memory pointer to data location.
2. Get the first number from memory and store in Register pair.
3. Get the second number in memory and add it to the Register pair.
4. Store the sum & carry in separate memory locations.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
1000 START LHLD 2000H
1005 XCHG
1008 LHLD 2002H
1000 MVI A, 00H
1005 DAD D
1008 JNC LOOP
1000 INR A
1005 LOOP SHLD 3000H
1008 STA 3002H
1009 HLT
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
57
OBSERVATION
INPUT OUTPUT
Address Data Address Data
2000 04H 3000 06H (Sum)
2001 04H 3001 06H (Sum)
2002 02H3002 00 (Carry)
2004 02H
RESULT
Thus the assembly language program to add the two 16-bit numbers
using 8085 simulator tool was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
58
SUBTRACTION OF TWO 16-BIT NUMBERS USING 8085AIM
To write an assembly language program to subtract the two 16-bit
numbers using microprocessor simulator tool.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord.
ALGORITHM
1. Initialize memory pointer to data location.
2. Get the subtrahend from memory and transfer it to register pair.
3. Get the minuend from memory and store it in another register pair.
4. Subtract subtrahend from minuend.
5. Store the difference and borrow in different memory locations.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
1000 START MVI C, 00
1008 LHLD 2000H
1000 XCHG
1005 LHLD 2002H
1008 MOV A, L
1000 SUB E
1005 MOV L, A
1008 MOV A, H
1009 SBB D
1000 MOV H, A
1008 SHLD 3000H
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
59
1000 JNC LOOP
1005 INR C
1008 LOOP MOV A, C
1005 STA 3000H
1008 HLT
OBSERVATION
INPUT OUTPUT
Address Data Address Data
2000 04H 3000 02H (Difference)
2001 04H 3001 02H (Difference)
2002 02H3002 00H (Borrow)
2004 02H
RESULT
Thus the assembly language program to subtract the two 16-bit
numbers using 8085 simulator tool was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
60
MULTIPLICATION OF TWO 16-BIT NUMBERS USING 8085
AIMTo write an assembly language program to multiply the two 16-bit
numbers using microprocessor simulator tool.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord.
ALGORITHM
1. Get the multiplier and multiplicand.
2. Initialize a register to store partial product.
3. Add multiplicand, multiplier times.
4. Store the result in consecutive memory locations.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
1000 START LHLD 2000H
1008 SPHL
1000 LHLD 20002
1005 XCHG
1008 LXI H, 0000H
1000 LXI B, 0000H
1005 DAD SP
1008 JNC NEXT
1009 INX B
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
61
1000 NEXT DCX D
1008 MOV A,E
1000 ORA D
1005 JNZ LOOP
1008 SHLD 3000H
1005 MOV A, C
1008 STA 3001H
1008 MOV A, B
1005 STA3002H
1008 HLT
OBSERVATION
INPUT OUTPUT
Address Data Address Data
2000 04H 3000 08H (Multiply)
2001 04H 3001 08H (Multiply)
2002 02H3002 00H (Carry)
2004 02H
RESULT
Thus the assembly language program to multiply the two 16-bit
numbers using 8085 simulator tool was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
62
DIVISION OF TWO 16-BIT NUMBERS USING 8085
AIMTo write an assembly language program to divide the two 16-bit
numbers using microprocessor simulator tool.
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord.
ALGORITHM
1. Get the dividend and divisor.
2. Initialize the register for quotient.
3. Repeatedly subtract divisor from dividend till dividend becomes
less than divisor.
4. Count the number of subtraction which equals the quotient.
5. Store the result in memory.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
1000 START LHLD 3000H
1008 XCHG
1000 LHLD 3002H
1005 LXI B, 0000H
1008 MOV A, L
1000 SUB E
1005 MOV L, A
1008 MOV A, H
1009 SBB D
1000 MOV H, A
1008 LOOP INX B
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
63
1000 JNC LOOP
1005 DCX B
1008 DAD D
1005 SHLD 3000H
1008 MOV A, C
1008 STA 3001H
1005 MOV A, B
1008 STA 3002H
1009 HLT
OBSERVATION
INPUT OUTPUT
Address Data Address Data
2000 04H 3000 02H (Quotient)
2001 04H 3001 02H (Quotient)
2002 02H3002 00H (Remainder)
2004 02H
RESULT
Thus the assembly language program to divide the two 16-bit numbers
using 8085 simulator tool was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
64http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
65
PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS
(USING 8086)
A-ADDITION OF TWO 16-BIT NUMBERS
ADDRESS MNEMONICS OP-CODE COMMANDS1000 MOV AX,[1100] A1,00,11 MOVE THE DATA TO
ACCUMULATOR
1003 ADD AX,[1102] 03,06,02,11 ADD MEMORYCONTENTWITHACCUMULATOR
1007 MOV [1200],AX A3,00,12 MOVEACCUMULATORCONTENT TOMEMORY
100A HLT F4 STOP
OUT PUT:
OUT PUTADDRESS
DATA
1200 041201 04
IN PUTADDRESS
DATA
1100 021101 021102 021103 02
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
66
PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS
(USING 8086)B-SUBTRACTION OF TWO 16-BIT NUMBERS
ADDRESS MNEMONICS OP-CODE COMMANDS1000
1003
1007
100A
MOV AX[1100]
SUB AX[1102]
MOV [1200],AX
HLT
A1,00,11
2B,06,02,11
A3,00,12
F4
MOVE THE DATA TOACCUMULATOR
SUBTRACTMEMORY CONTENTWITHACCUMULATOR
MOVEACCUMULATORCONTENT TOMEMORY
STOP
OUT PUT:
OUT PUTADDRESS
DATA
1200 021201 02
IN PUTADDRESS
DATA
1100 041101 021102 041103 02
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
67
PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS
(USING 8086)C-MULTIPLICATION OF TWO 16-BIT NUMBERS
ADDRESS MNEMONICS OP-CODE COMMANDS1000
1003
1007
100B
100E
MOV AX[1100]
MUL[1102]
MOV [1200],DX
MOV[1202],AX
HLT
A1,00,11
F7,26,02,11
87,16,00,12
A3,02,12
F4
MOVE THE DATA TOACCUMULATOR
MULTIPLY MEMORYCONTENTWITHACCUMULATOR
MOVEACCUMULATORCONTENT TO AXREGISTER
MOVEACCUMULATORCONTENT TO DXREGISTER
STOP
OUT PUT:
OUT PUTADDRESS
DATA
1200 001201 041202 081203 04
IN PUTADDRESS
DATA
1100 021101 021102 021103 02
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
68
PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS
(USING 8086)D-DIVISION OF TWO 16-BIT NUMBERS
ADDRESS MNEMONICS OP-CODE COMMANDS1000
1003
1007
100B
100E
MOV AX[1100]
DIV[1102]
MOV [1200],DX
MOV[1200],AX
HLT
A1,00,11
F7,36,02,11
87,16,00,12
A3,00,12
F4
MOVE THE DATATOACCUMULATOR
DIVIDE MEMORYCONTENTWITHACCUMULATOR
MOVEACCUMULATORCONTENT TO DXREGISTER
MOVE CONTENTOF AXREGISTER TOMEMORY
STOP
OUT PUT:
OUT PUTADDRESS
DATA
1200 021201 021202 001203 00
IN PUTADDRESS
DATA
1100 041101 041102 021103 02
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
69
INTERFACING ADC AND DAC
(I) PROGRAM FOR ANALOG-DIGITAL CONVERTER
MEMORYADDRESS
MNEMONICS OPCODE COMMENTS
1000 MOV AL,03 B0, 03Move toaccumulator
1002 OUT C8,AL E6, C8move the value toregister
1004 MOV AL,23 B0, 23move the value toB0
1006 OUT C8,AL E6, C8move the value tomain memory
1008 MOV AL,03 B0, 03Move the valuefrom main memoryto accumulator
100A OUT C8,AL E6,C8move the value tomain memory
100C MOV AL,01 B0, 01move to register
100E OUT DO, AL E6, D0move to memory
1010 MOV AL,00 B0, 00Move toaccumulator
1012 OUT D0,AL E6, D0Move fromaccumulator. toregister
1014 LOOP IN AL E0 E4 ,E0increment the value
1016 AND AL,01 24, 01move to register
1018 CMP AL,01 3C ,01Compare the valueof accumulator. anmemory
101A JNZ LOOP 75, F8jump no zero
101C IN AL,C0 E4, C0increment loopcondition
101E MOV BX,1100 BB,00,11move to memory
1021 MOV[BX],AL 88, 07move to register
1023 HLT F4stop
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
70
IN PUT:IN PUTANALOGVOLTAGE
OUT PUTDIGITAL DATA
5V FF [1100]
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
71
INTERFACING ADC AND DAC
PROGRAM FOR DIGITAL- ANALOG CONVERTER
GENERATION OF SAWTOOTH WAVE
MEMORYADDRESS
LABEL MNEMONICS OPCODE COMMENTS
1000 START MOV AL, 00 B0,00 move to AL reg
1002 L1 OUT C0,AL E6 ,C0 move to CO
1004 INC AL FE ,C0 increment ALregister
1006 JNZ L1 75, FA jump no carry
1008 JMP START EB ,F6 jump to start
100A RET C3 Return
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
72
INTERFACING ADC AND DAC
PROGRAM FOR DIGITAL- ANALOG CONVERTERB- GENERATION OF SQUARE WAVE
MEMORYADDRESS
LABEL MNEMONICS OPCODE COMMENTS
1000START
MOV AL,00 B0,00move to AL reg.
1002 OUT C8,AL E6 ,C8 move to C8
1004 CALL DELAY E8 ,09 ,00 call the delay
1007 MOV AL,FF B0, FFmove to FF reg.
1009 OUT C8, AL E6 ,C8 move to C8
100B CALL DELAY E8 ,02 ,00 call the delay
100E JMP START EB,F0 jump to start
1010 DELAY MOV CX, 05,FF
B9, FF, 05 declare thedata toaccumulator
1013 L1 LOOP L1 E2 ,FE move to loop
1015 RET C3 return
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
73
INTERFACING ADC AND DAC
PROGRAM FOR DIGITAL- ANALOG CONVERTERC- GENERATION OF TRIANGULAR WAVE
MEMORYADDRESS
LABEL MNEMONICS OPCODE COMMENTS
1000START MOV BL,00
B3,00 Move toaccumulator
1002 L1 MOV AL,BL 88,D8move to BL reg
1004 OUT C8,AL E6,C8move to C8
1006 INC BL FE,C3increment value
of BL reg.
1008 JNZ L1 75,F8jump no zero
100A MOV BL,FF B3,FFmove to FF reg.
100C L2 MOV AL,BL 88,D8Move to
accumulator.
100E OUT C8,AL E6,C8move to C8
1010 DEC BL FE,CBdecrement value
of BL reg.
1012 JNC L2 75,F8jump no carry
1014 JMP START EB,EAjump start
1016 RET C3return
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
74
PARALLEL COMMUNICATION BETWEEN TWO MP KITSUSING MODE 1 AND MODE 2 OF 8255
AIM:To perform interface program of parallel communication between two mp kits
using mode 1 and mode 2 of 8255.
APPARATUS REQUIRED:
1. 8086 p kit
2. 8255 Interface board
3. DC regulated power supply
4. VXT parallel bus
I/O MODES:
Control Word:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
75
TRANSMITTER PROGRAM:
ADDRESS LABEL MNEMONICS OPCODES1000 MOV AL,80 B0 801002 OUT 0F,AL E6 0F1004 MOV AL,05 (DATA) B0 051006 OUT 0C,AL E6 0C1008 HLT F4
RECEIVER PROGRAM:
ADDRESS LABEL MNEMONICS OPCODES1000 MOV AL,90 B0 901002 OUT 0F,AL E6 0F1004 IN AL 0C E4 0C1006 MOV BX[1250] BB 50 121009 MOV BX AL 88 07100B HLT F4
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
76
INTERFACING AND PROGRAMMING 8279, 8259, AND 8253INTERFACING OF 8279
ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b)ADDRESS LOOP MNEMONICS OP-CODE COMMANDS1000 START MOV SI,1200 BE 00 12 SET MODE
COUNT ANDDISPLAY
1003 MOV CX,000F B9 0F 00 MOVE 000F DATAIN CX
1006 MOV AL,10 B0 10 SET ACC DATA1008 OUT C2,AL E6 C2 CLEAR DISPLAY100A MOV AL,CC B0 CC MOVE CC DATA
IN AL100C OUT C2,AL E6 C2 SET PORT DATA100E MOV AL,90 B0 90 WRITE DISPLAY1010 OUT C2,AL E6,C2 CLEAR DISPLAY
IN RAM1012 NEXT MOV AL,[SI] 8A 04 LOP FOR THE
PRESSING OFKEY
1014 OUT CO,AL E6 C0 SET TO READFIFO RAM
1016 CALL DELAY E8 E7 04 CALL DISPLAYDATA
1019 INC SI 46 GET THECORRESPONDINGCODE FORMLOOKUP TABLE
101A LOOP NEXT E2 F6 GO TO NEXT101C JMP START EB E2 JUMP START
SUB PROGARM:
ADDRESS LOOP MNEMONICS OP-CODE COMMANDS
1500 DELAY MOV DX,A0FF BA FF 0A MOVE THEVALUE TODX REGISTER
1503 DEC DX 4A DECREMENT DX
1504 JNZ LOOP1 75 FD JUMP NO ZERO
1506 RET C3 RETURN
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
77
LOOK-UP TABLE
ADDRESS DATA
1200 FF,FF,FF,FF
1204 FF,FF,FF,FF
1208 68,6C,68,FF
120C FF,38,FF,FF
The above program initializes 8279 in scanned keyboard 2 key lock-out. Press
two keys simultaneously and verify that only one key is accepted by 8279.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
78
INTERFACING AND PROGRAMMING 8279, 8259, AND 8253INTERFACING OF 8259 IN SPECIAL MASK MODE
ADDRESS LOPP MNEMONICS OP-CODE COMMANDS1200 MOV AL,FD BO FD MOVE DATA TO
ACCUMULATOR1202 OUT C2,AL E6 C2 SEND VALUE
TOOUTPUT PORT
1204 INT 2 CD 02 INTERUPT
ORG 10001000 MOV
C2,AL(17)B0 17 MOVE DATA TO
ACCUMULATOR1002 OUT C2,AL E6 C0 SEND VALUE
TOOUTPUT PORT
1004 MOVC2,AL(08)
B0 08 MOVE DATA TOACCUMULATOR
1006 OUT C2,AL E6 C2 SEND VALUETOOUTPUT PORT
1008 MOV AL,01 B0 01 MOVE DATA TOACCUMULATOR
100A OUT C2,AL E6 C2 SEND VALUETOOUTPUT PORT
100C MOV AL,FE B0 00 MOVE DATA TOACCUMULATOR
100E OUT C2,AL E6 C2 SEND VALUETOOUTPUT PORT
1010 MOV AL,68 BO 68 MOVE DATA TOACCUMULATOR
1012 OUT C0,AL E6 C0 SEND VALUETOOUTPUT PORT
1014 STI FB SET INTERRUPT
1015 JMP HERE EB FE JUMP HERE
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
79
Press the switch IRO. The CPU control is transferred to ISR. Since no EOI
command is given the 8259 will not accept further interrupts. However due
to special mask mode, 8259 will accept interrupt only at IRI.
VECTORED INTERUPT:ADDRESS DATA0020 000021 120022 000023 00
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
80
INTERFACING AND PROGRAMMING 8279, 8259, AND 8253GENERATION OF SQUARE WAVE USING 8253
ADDRESS MNEMONICS OPCODE COMMAND1000 ORG 100H
MOV AL,36B0 36 MOVE THE
VALUE TOACCUMULATOR
1002 OUT CE,AL E6 CE SEND DATA TOTHEOUTPUT PORT
1004 MOV AL,10 B0 10 MOVE THEVALUE TOACCUMULATOR
1006 OUT C8,AL E6 C8 SEND DATA TOTHEOUTPUT PORT
1008 MOV AL.00 B0 00 MOVE THEVALUE TOACCUMULATOR
100A OUT C8,AL E6 C8 SEND DATA TOTHEOUTPUT PORT
100C HLT F4 HALT
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
81
SERIAL COMMUNICATION BETWEEN TWO MP KITS USING 8251TRANSMITTER PROGRAM
ADDRESS MNEMONICS OP-CODE COMMANDS1000 MOV AL,36 BO 36 MOVE THE VALUE
TOACCUMULATOR
1002 OUT CE,AL E6 CE SEND DATA TOOUTPUT PORT
1004 MOV AL,10 B0 10 MOVE THE VALUETOACCUMULATOR
1006 OUT C8,AL E6 C8 SEND DATA TOOUTPUT PORT
1008 MOV AL,00 B0 00 MOVE THE VALUETOACCUMULATOR
100A OUT C8,AL E6 C8 SEND DATA TOOUTPUT PORT
100C MOV AL,4E B0 4E MOVE THE VALUETOACCUMULATOR
100E OUT C2,AL E6 C2 SEND DATA TOOUTPUT PORT
1010 MOV AL,37 B0 37 MOVE THE VALUETOACCUMULATOR
1012 OUT C2,AL E6 C2 SEND DATA TOOUTPUT PORT
1014 MOV AL,AA BO AA MOVE THE VALUETOACCUMULATOR
1016 OUT CO,AL E6 CO SEND DATA TOOUTPUT PORT
1018 INT 02 CD 02 INTERUPT
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
82
RECEIVER PROGRAMADDRESS MNEMONICS OP-CODE COMMANDS1200 IN AL,C0 E4 C0 INTERUPT
1202 MOV BX[1250] BB 50 12 MOVE THE VALUETO ADDRESS
1205 MOV BX,AL 88 07 MOVEACCUMULATORDATA TO BX
1207 INT 02 CD 02 INTERUPT
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
83
INTERFACING AND PROGRAMMING OF STEPPER MOTORSTEPPER MOTOR INTERFACING
AIMTo write an assembly language program to interface stepper motor
with 8086.
APPARATUS REQUIRED
8086 Microcontroller kit, Power chord, stepper motor, stepper motorinterface board
THEORYA motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a step-wise
manner from one equilibrium position to the next. Stepper Motors are used
very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator
poles. Each of the four poles has its own winding. The excitation of any one
winding generates a North Pole. A South Pole gets induced at the
diametrically opposite side. The rotor magnetic system has two end faces. It
is a permanent magnet with one face as South Pole and the other as North
Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited
with a DC current to run the motor in clockwise direction. By reversing the
phase sequence as A1, B2, A2, B1, anticlockwise stepping can be obtained.
2-PHASE SWITCHING SCHEMEIn this scheme, any two adjacent stator windings are energized. The
switching scheme is shown in the table given below. This scheme produces
more torque.
ANTICLOCKWISE CLOCKWISE
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
84
STEP
A1
A2 B1
B2 DATA STEP
A1
A2
B1
B2 DATA
1 1 0 0 1 9h 1 1 0 1 0 Ah2 0 1 0 1 5h 2 0 1 1 0 6h3 0 1 1 0 6h 3 0 1 0 1 5h4 1 0 1 0 Ah 4 1 0 0 1 9h
ADDRESS DECODING LOGICThe 74138 chip is used for generating the address decoding logic to
generate the device select pulses, CS1 & CS2 for selecting the IC 74175.The
74175 latches the data bus to the stepper motor driving circuitry.
Stepper Motor requires logic signals of relatively high power.
Therefore, the interface circuitry that generates the driving pulses uses
silicon Darlington pair transistors. The inputs for the interface circuit are
TTL pulses generated under software control using the Microcontroller Kit.
The TTL levels of pulse sequence from the data bus are translated to high
voltage output pulses using a buffer 7407 with open collector.
A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED
MEMORYADDRESS
LABEL MNEMONICS OPCODE
1000 START MOV D1 offsettable (1014)
BF,14,10
1003 MOV CL, 04 B1,04
1005 LOOP1 MOV AL,[D1] 8A,05
1007 OUTPORT1,AL
E6,C0
1009 MOV DX,1010 BA,10,10
100C DELAY DEC DX 4A
100D JNZ DELAY 75,FD
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
85
100F INC D1 47
1010 LOOP LOOP1 E2,F3
1012 JMP START EB,EC
1014 TABLE DB 09,05,06,0A
B-TO RUN STEPPER MOTOR AT FORWARD AND REVERSEDIRECTION
MEMORYADDRESS
LABEL MNEMONICS OPCODE
1000 START MOV BL 20H B3,20
1002 FORWD MOV D1,OFFSETFORW (1037)
BF,37,10
1005 CALL ROTATE E8,18 00
1008 DEC BL FE CB
100A JNZ FORWARD 75 F6
100C CALL DELAY E8 21 00
100F MOV BL 20 B3 20
1011 REVER MOV D1 ,OFFSETREV (103B)
BF 3B 10
1014 CALL ROTATE E8 09 00
1017 DEC BL FE CB
1019 JNZ REVER 75 F8
101B CALL DELAY E8 12 00
101E JMP START EB E0
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
86
1020 ROTATE MOV CL,04 B1 04
1022 REPT MOV AL,[D1] 8A 05
1024 OUT PORT1,AL E6 C0
1026 MOV DX,1010 BA 10,10
MEMORYADDRESS
LABEL MNEMONICS OPCODE
1029 DEC BX 4A
102A LOOP L1 JNZ LOOP 1 75 FD
102C INC D1 47
102D LOOP REPT E2 F3
102D RET C3
102F MOV DX FFFF BA FF, FF
1030 DEC DX 4A
1033 DELAY JNZ DELAY 75 FD
1036 RET C3
1037 FORW DB 09 05 06 0A103B REV DB 0A 06 05 09
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
87
INTERFACING 8255 WITH 8086
AIM:To interface programmable peripheral interface 8255 with 8086 and study its
characteristics in mode0
APPARATUS REQUIRED:
1. 8086 p kit
2. 8255 Interface board
3. DC regulated power supply
4. VXT parallel bus
I/O MODES:
Control Word:
MODE 0 – SIMPLE I/O MODE:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
88
This mode provides simple I/O operations for each of the three ports andis suitable for synchronous data transfer. In this mode, all the ports can be configuredeither as input or output port.
Let us initialize port A as input port
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODES1000 MOV SI , 1500 BE 00 151003 MOV AL,90 B0 901005 OUT C6,AL E6 C61007 IN AL,C0 E4 C01009 MOV [SI], AL 88 04100B HLT F4
MODE 0 STROBED I/O MODE:
Let us initialize port A as input port and port B as output port
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODES1000 MOV AL,90 B0 901002 OUT C6,AL E6 C61004 IN AL,C0 E4 C01006 OUT C2 AL E6 C21008 HLT F4
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
89
RESULT:
Thus 8255 are interfaced and their characteristic in mode0 was studied.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
90http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
91
BIOS/DOS CALLS – DISPLAY A MESSAGE
AIM:
To display a message on the CRT screen of a microcomputer using DOS
calls.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the
CRT.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
MSG DB 0DH, 0AH, “GOOD MORNING” , ODH, OAH, “$”
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AH, 09H
MOV DX, OFFSET MSG
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
92
BIOS/DOS CALLS – FILE CREATIONAIM:
To create a file using DOS calls.
ALGORITHM:
1. Initialize the data segment, file name and the message to be displayed.2. Set the file attribute to create a file using a DOS call.3. If the file is unable t o create a file display the message
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
FILENAME DB “SAMPLE.DAT”, “$”
DATA ENDSCODE SEGMENTSTART: MOV AX, DATA
MOV DS, AX
MOV DX, OFFSET FILENAME
MOV AH, 3CH
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
93
BIOS/DOS CALLS – KEYBOARD CONTROLAIM:
To interface a keyboard using DOS calls.
ALGORITHM:
1. Initialize the data segment, file name and the message to be displayed.2. Set the file attribute to create a file using a DOS call.3. If the file is unable t o create a file display the message
PROGRAM:
.Datamesg db 'Ten seconds have passed!',0Dh, 0Ah,'$'.Code;; pmesg - Prints the message pointed to by the DX register on the screen.;pmesg PROCmov ah, 09h ;DOS Print to screen function.int 21h ;Call DOS.ret ;Return after printing.pmesg ENDP;Test our procedure for printing a message.start: mov ax, @Data ;We're using the data segment now so wemov ds, ax ; need to initialize it!mov dx, offset mesg;Point DX at the message.call pmesg ;Print the message on the screen.call pmesg ; a few times.call pmesg ;mov ax, 4C00h ;DOS Exit function call, return code 0.int 21h ;Call DOS to exit.end start
RESULT:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
94
BIOS/DOS CALLS – ASCII EQUIVALENT OF A TEXT
AIM:
To display the ASCII equivalent of a text..
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for disk information.
3. Point to the message and run the interrupt to display the message in the
CRT.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
MSG DB 0DH, 0AH, “GOOD MORNING” , ODH, OAH, “$”
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV AH, 36H
MOV DX, OFFSET MSG
INT 21H
MOV AH, 4CH
INT 21H
CODE ENDS
END START
RESULT:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
95http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
96
SORTING THE DESCENDING ORDER USING MASM
AIM:
To write the program using MASM software for sorting the numbers in
descending order and verify the output.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the
message in the CRT
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
LIST DW 53H,25H,19H,02H
COUNT EQU 04
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV DX,COUNT-1
AGAIN 0:MOV CX,DX
MOV SI,OFFSET LIST
AGAIN 1:MOV AX,[SI]
CMP AX,[SI+2]
JNL PR1
XCHG [SI+2],AX
XCHG [SI],AX
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
97
PR1:ADD SI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
INT 21H
CODE ENDS
END START
RESULT:
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
98
LARGEST NUMBER IN AN ARRAY USING MASM SOFTWARE
AIM:
To find the largest number in an array using MASM software.
ALGORITHM:
i. Initialize the data segment and the message to be displayed.
ii. Set function value for display.
iii. Point to the message and run the interrupt to display the
message in the CRT
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
LIST DW 23H,56H,45H,52H
COUNT EQU 04
LARGEST DB 01H DUP(?)
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET LIST
MOV CL,COUNT
MOV AL,[SI]
AGAIN:CMP AL,[SI+1]
JNL NEXT
MOV AL,[SI+1]
NEXT:INC SI
DEC CL
JNZ AGAIN
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
99
MOV SI,OFFSET LARGEST
MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
100
DISPLAYING A STRING USING MASM SOFTWARE
AIM:
To display a string using MASM software.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
4. Set function value for display.
5. Point to the message and run the interrupt to display the message in the
CRT.
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
MESSAGE DB ODH,OAH,”STUDY OF MICROPROCESSOR IS
INTERESTING”,0DH,0AH,”$”
DATA ENDS
CODE SEGMENT
START: MOV AX,DATA
MOV DS,AX
MOV AH,09H
MOV DX,OFFSET MESSAGE
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
101
ARITHMETIC OPERATIONS USING MASM SOFTWARE
AIM:
To perform arithmetic operations such as addition,subtraction,
multiplication division operations using MASM software.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
2. Set function value for display.
3. Point to the message and run the interrupt to display the message in the
CRT.
PROGRAM:
ASSUME CS:CODE,DS:DATA
DATA SEGMENT
0PR1 EQU 98H
0PR2 EQU 49H
SUM DW 01 DUP(00)
SUBT DW 01 DUP(00)
PROD DW 01 DUP(00)
DWS DW 01 DUP(00)
DATA ENDS
CODE SEGMENT
START:MOV AX,DATA
MOV DS,AX
MOV BL,0PR2
XOR AL,AL
MOV AL,0PR1
ADD AL,BL
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
102
DAA
MOV BYTE PTR SUM,AL
JNC MSB0
INC [SUM+1]
MSB0:XOR AL,AL
MOV AL,0PR1
SUB AL,BL
DAS
MOV BYTE PTR SUBT,AL
JNB MSB1
INC [SUBT+1]
MSB1:XOR AL,AL
MOV AL,0PR1
MUL BL
MOV WORD PTR
PROD,AX
XOR AH,AH
MOV AL,0PR1
DIV BL
MOV WORD PTR
DIVS,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
103http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
104
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: aDATE:
ADDITION OF TWO 8-BIT NUMBERS USING 8051
AIMTo write an assembly language program to add the two 8-bit numbers
using microcontroller instruction set.
APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Add the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 ADD A, #data2 24, 02
6105 MOV DPTR, #6500H 90, 65, 00
6108 MOVX @DPTR, A F0
6109 LOOP SJMP LOOP 80, FE
OBSERVATION
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
105
INPUT OUTPUT
Address Data Address Data
61026500
6103
RESULT
Thus, the assembly language program to add the two 8-bit numbers
using 8051 instruction set was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
106
1. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: bDATE:
SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051
AIMTo write an assembly language program to subtract the two 8-bit
numbers using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Subtract the second data with Accumulator.
4. Store the sum in memory pointed by DPTR.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 SUBB A, #data2 94, 02
6105 MOV DPTR, #6500H 90, 65, 00
6108 MOVX @DPTR, A F0
6109 LOOP SJMP LOOP 80, FE
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
107
OBSERVATION
INPUT OUTPUT
Address Data Address Data
61026500
6103
RESULT
Thus, the assembly language program to subtract the two 8-bit
numbers was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
108
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: cDATE:
MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051
AIMTo write an assembly language program to multiply the two 8-bit
numbers using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The higher order of the result is in B-register.
6. The lower order of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
109
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,#data2 75, F0, 02
6106 MUL AB A4
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6102 6500
6103 6501
RESULT
Thus, the assembly language program to multiply the two 8-bit
numbers using 8051 instruction set was written and executed
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
110
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: dDATE:
DIVISION OF TWO 8-BIT NUMBERS USING 8051AIM
To write an assembly language program to divide the two 8-bit
numbers using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
3. Move the second data to B-register.
4. Multiply the second data with Accumulator.
5. The remainder of the result is in B-register.
6. The quotient of the result is in Accumulator.
7. Store the sum in memory pointed by DPTR.
PROGRAM
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
111
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 CLR C C3
6101 MOV A,#data1 74, 08
6103 MOV B,#data2 75, F0, 02
6106 DIV AB 84
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6102 6202
6105 6203
RESULT
Thus, the assembly language program to divide the two 8-bit numbers
using 8051 instruction set was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
112
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: eDATE:
ONE’S AND TWO’S COMPLEMENT USING 8051AIM
To write an assembly language program to find the 1’s and 2’s
complement of an 8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Complement the accumulator.
3. Move the one’s complement output to the memory 6500H.
4. Add 01H with accumulator.
5. Move the two’s complement output to the memory 6501H.PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 MOV A, #data 74, CC
6101 CPL A F4
6103 MOV DPTR, #6500H 90, 65, 00
6106 MOVX @DPTR, A F0
6107 INC A 04
610A INC DPTR A3
610B MOVX @DPTR, A F0
610C LOOP SJMP LOOP 80, FE
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
113
OBSERVATION
INPUT OUTPUT
Address Data Address Data
61016500
6501
RESULT
Thus the assembly language program to find the 1’s and 2’s
complement of an 8-bit number using 8051 instruction set was written and
executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
114
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: fDATE:
SETTING BITS IN AN 8 BIT NUMBERS USING 8051AIM
To write an assembly language program to find the Setting bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform OR operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 MOV A, #data1 74, 2F
6102 ORL A, #data2 44, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
OBSERVATION
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
115
INPUT OUTPUT
Address Data Address Data
61016500
6103
RESULT
Thus the assembly language program to Setting bits an
8-bit number using microcontroller instruction set was written and executed
successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
116
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: gDATE:
MASKING BITS IN AN 8 BIT NUMBERS USING 8051AIM
To write an assembly language program to find the Masking bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform AND operation with accumulator.
3. Move the accumulator output to the memory 6500H.
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE COMMENTS
6100 MOV A, #data1 74, 2F
6102 ANL A, #data2 54, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
OBSERVATION
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
117
INPUT OUTPUT
Address Data Address Data
61016500
6103
RESULT
Thus the assembly language program to masking bits an
8-bit number using microcontroller instruction set was written and executed
successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
118
PROGRAMS FOR SORTING AND SEARCHING (USING 8051)
EX NO: aDATE:
ARRANGE THE GIVEN NUMBER IN ASCENDING ORDERAIM
To write an assembly language program to sort an array of data in
ascending order using 8051 simulator tool.
APPARATUS REQUIRED
8051 Microcontroller KitALGORITHM
1. Load the count value from memory to A-register and store it in B-
register.
2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pair as data address pointer.
4. Set C-register as counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address
pointer.
6. Increment the HL pair (data address pointer).
7. Compare the data pointed by HL with accumulator.
8. If carry flag is set (if the content of accumulator is smaller than
memory) then go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the
accumulator.
10.Decrement C-register. If zero flag is reset go to step 6, otherwise,
go to next step.
11.Decrement B-register. If zero flag is reset go to step 3, otherwise,
go to next step.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
119
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 MOV R3, #04H 7B, 04
6102 MOV R4, #04H 7C, 04
6104 MOV DPTR, #6500H 90, 65, 00
6107 LOOP1 MOV R5, DPL AD, 82,
6109 MOV R6, DPH AE, 83
610B MOVX A, @DPTR E0
610C MOV B,A F5, F0
610E LOOP INC DPTR A3
610F MOVX A, @DPTR E0
6110 MOV R0, A F8
6111 CLR C C3
6112 SUBB A, B 95, F0
6114 JNC LOOP2 50,13
6116 EXCH PUSH DPL C0, 82
6118 PUSH DPH C0, 83
611A MOV DPL, R5 8D, 82
611C MOV DPH, R6 8E, 83
611E MOV A, R0 E8
611F MOVX A, @DPTR E0
6120 POP DPH D0, 83
6122 POP DPL D0, 82
6124 MOV A, B E5, F0
6126 MOVX @DPTR, A F0
6127 MOV B, R0 88, FO
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
120
6129 LOOP2 DJNZ R3, REPT DB, E3
612B DEC R4 1C
612C MOV A, R4 EC
612D MOV R3, A FB
612E INC R4 0C
612F MOV DPL, R5 8D, 82
6131 MOV DPH, R6 8E, 83
6133 INC DPTR A3
6134 DJNZ R4, LOOP1 DC, D1
6136 HLT SJMP HLT 80, FE
OBSERVATION
INPUT
(Before sorting)
OUTPUT
(After sorting)
Address Data Address Data
6500 05H 6500 05H
6501 0AH 6501 03H
6502 0CH 6502 06H
6503 06H 6503 08H
6504 03H 6504 0AH
6505 08H 6505 0CH
RESULTThus, the assembly language program to sort an array of data in ascending order
using 8051 simulator tools was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
121
PROGRAMS FOR SORTING AND SEARCHING (USING 8051)
EX NO: bDATE:ARRANGE THE GIVEN NUMBER IN DESCENDING ORDERAIM
To write an assembly language program to sort an array of data in
descending order using 8051 simulator tool.
APPARATUS REQUIRED
8051 Microcontroller KitALGORITHM
1. Load the count value from memory to A-register and store it in B-
register.
2. Decrement B-register (B is a count for (N-1) repetitions).
3. Set HL pair as data address pointer.
4. Set C-register as counter for (N-1) comparisons.
5. Load a data of the array in accumulator using the data address
pointer.
6. Increment the HL pair (data address pointer).
7. Compare the data pointed by HL with accumulator.
8. If carry flag is set (if the content of accumulator is smaller than
memory) then go to step 10, otherwise, go to next step.
9. Exchange the content of memory pointed by HL and the
accumulator.
10.Decrement C-register. If zero flag is reset go to step 6, otherwise,
go to next step.
11.Decrement B-register. If zero flag is reset go to step 3, otherwise,
go to next step.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
122
PROGRAM
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 MOV R3, #04H 7B, 04
6102 MOV R4, #04H 7C, 04
6104 MOV DPTR, #6500H 90, 65, 00
6107 LOOP1 MOV R5, DPL AD, 82,
6109 MOV R6, DPH AE, 83
610B MOVX A, @DPTR E0
610C MOV B,A F5, F0
610E LOOP INC DPTR A3
610F MOVX A, @DPTR E0
6110 MOV R0, A F8
6111 CLR C C3
6112 SUBB A, B 95, F0
6114 JNC LOOP2 40,13
6116 EXCH PUSH DPL C0, 82
6118 PUSH DPH C0, 83
611A MOV DPL, R5 8D, 82
611C MOV DPH, R6 8E, 83
611E MOV A, R0 E8
611F MOVX A, @DPTR E0
6120 POP DPH D0, 83
6122 POP DPL D0, 82
6124 MOV A, B E5, F0
6126 MOVX @DPTR, A F0
6127 MOV B, R0 88, F0
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
123
6129 LOOP2 DJNZ R3, REPT DB, E3
612B DEC R4 1C
612C MOV A, R4 EC
612D MOV R3, A FB
612E INC R4 0C
612F MOV DPL, R5 8D, 82
6131 MOV DPH, R6 8E, 83
6133 INC DPTR A3
6134 DJNZ R4, LOOP1 DC, D1
6136 HLT SJMP HLT 80, FE
OBSERVATION
INPUT
(Before sorting)
OUTPUT
(After sorting)
Address Data Address Data
6500 05H 6500 05H
6501 0AH 6501 0CH
6502 0CH 6502 0AH
6503 06H 6503 08H
6504 03H 6504 06H
6505 08H 6505 03H
RESULTThus the assembly language program to sort an array of data in descending
order using 8051 simulator tools was written and executed successfully.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
124
PROGRAMS FOR SORTING AND SEARCHING (USING 8051)
EX NO: c
DATE:LARGEST ELEMENT IN AN ARRAY
AIM
To write an assembly language program to find the largest number in
an array using 8051 simulator tools.
APPARATUS REQUIRED
8051 Microcontroller kit,
Power chord
ALGORITHM
1. Clear C-register for carry.
2. Move the first data from memory to accumulator and move it to B-
register.
3. Move the second data from memory to accumulator.
4. Add the content of B-register with Accumulator.
5. Check for carry. If carry=’1’ then go to step 6 else go to step 7.
6. Increment the C-register
7. Store the sum in memory.
8. Move the carry to accumulator and store in memory.
PROGRAM
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
125
MEMORY
ADDRESSLABEL MNEMONICS OP CODE
6100 MOV DPTR,#6500 90, 65, 00
6103 MOV 40,#00 75, 40, 00
6106 MOV R5,#05 7D, 05
6108 LOOP2 MOVX A,@DPTR E0
6109 CJNE A,40H,LOOP1 B5, 40, 08
610C LOOP3 INC DPTR A3
610D DJNZ R5, LOOP2 DD, F9
610F MOV A, 40H E5, 40
6111 MOVX @DPTR,A F0
6112 HLT SJMP HLT 80, FE
6114 LOOP1 JC LOOP3 40, F6
6116 MOV 40H,A F5, 40
6118 SJMP LOOP3 80, F2
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6500 04H
6500 0AH
6501 08H
6502 02H
6503 0AH
6504 06H
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
126
RESULT
Thus the assembly language program to find the largest number in an
array using 8051 simulator tools was written and executed successfully
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
127
INTERFACING OF 8279
ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b) USINGH 8051
ADDRESS LABEL MNEMONICS OP-CODE
4000 MOV DPTR,#FFC2 90 FF C2
4003 MOV R0,#00 78 004005 MOV R1,#44 79 444007 MOV A,#10 74 104009 MOVX@DPTR,A F0400A MOV A,#CC 74 CC400C MOVX@DPTR,A F0400D MOV A,#90 74 90401F MOVX@DPTR,A F04010 LOOP MOV DPH,R1 89 834012 MOV DPL,R0 88 824014 MOVX@DPTR E04015 MOV DPTR,FFC0 90 FF C0
4018 MOVX@DPTR,A F04019 LCALL DELAY 12 45 00401C INC R0 08401D CJNE R0,#0F,LOOP B8 0F F0
401A LJMP START 02 81 00
ORG 4500
ADDRESS LABEL MNEMONICS OP-CODE
4500 MOV R4,#A0 7C A04502 LOOP2 MOV R5,#FF 7D FF4504 LOOP1 NOP 004505 DJNZ R5,LOOP1 DD FD
4507 DJNZ R4,LOOP2 DC F9
4509 RET 22
LOOK-UP TABLE
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
128
ADDRESS DATA
4400 FF,FF,FF,FF
4404 FF,FF,FF,FF
4408 68,6C,68,FF
440C FF,38,FF,FF
RESULTThe above program initializes 8279 in scanned keyboard 2 key lock-out. Press two keyssimultaneously and verify that only one key is accepted by 8279
INTERFACING AND PROGRAMMING OF DC MOTOR SPEEDCONTROL
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
129
PROGRAM FOR DC MOTOR SPEED CONTROL
STKTOP: EQU 54H
CRLF: EQU 061DH
MSGOUT: EQU 0606H
RD79: EQU 0559H
RCVN: EQU 045FH
DELAY: EQU 0114H
CMDMOD: EQU 0771H
ORG 6A00HMOV SP,#STKTOP ;INIT STACK PTR
MOV A,#80H ;CONTROL WORD FOR 8255MOV DPTR,#280FH ;SET ALL PORTS AS O/P PORTSMOVX @DPTR,A ;
LOOP: LCALL CRLF ;CLEAR 7-SEG DISPLAYMOV DPTR,#MSG1 ;LCALL MSGOUT ;DIPLAY "DIR F/R"
TEST: LCALL RD79 ;LOOK FOR KEYBOARD I/PCJNE A,#46H,REV ;MOV B,#01H ;LJMP SPEED ;
REV: CJNE A,#52H,FIN1 ;IF REVERSE, SET PC1 HIGHMOV B,#02H ;LJMP SPEED ;
FIN1: CJNE A,#1BH,TEST ;IF "ESC" KEY PRESSED,CLR A ;TURN OFF THE MOTORMOV DPTR,#280EH ;GOTO COMMAND PROMPTMOVX @DPTR,A ;LJMP CMDMOD ;
SPEED: LCALL CRLF ;CLEAR 7-SEG DISPLAYMOV DPTR,#MSG2 ;DISPLAY "SPEED "MOV R6,#02H ;MOV R5,#0AH ;MOV R4,#00H ;MOV R3,#01H ;LCALL CRLF ;LCALL RCVN ;ROUTINE TO ACCEPT DATA BYTE
;FROM KEYBOARDMOV A,R3 ;MOVE KBD I/P FROM R3,ACJNE A,#50H,INVERT ;SJMP WAVE ;
INVERT: JC WAVE ;MOV A,B ;
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
130
ORL A,#08H ;MOV B,A ;
WAVE: MOV DPTR,#281BH ;FOR 8253: 4/4/02MOV A,#36H ;MOVX @DPTR,A ;COUNTER0 IN MODE 3MOV A,#00HCJNE A,R3,MOD2MOV A,#90HSJMP MOD0
MOD2: MOV A,#94H ;MOD0: MOVX @DPTR,A ;COUNTER2 IN MODE 2
MOV DPTR,#TABLE ;INI: MOVX A,@DPTR ;
CJNE A,R3,RDT ;RDT: JC NXTTB
MOV A,R3JZ NXTTBINC DPTR ;INC DPTR ;INC DPTR ;
INC DPTR ;SJMP INI ;
NXTTB: INC DPTR ;MOVX A,@DPTR ;PUSH DPL ;PUSH DPH ;MOV DPTR,#2818H ;MOVX @DPTR,A ;POP DPH ;POP DPL ;INC DPTR ;MOVX A,@DPTR ;PUSH DPL ;PUSH DPH ;MOV DPTR,#2818H ;MOVX @DPTR,A ;POP DPH ;POP DPL ;INC DPTR ;MOVX A,@DPTR ;PUSH DPL ;PUSH DPH ;MOV DPTR,#281AH ;MOVX @DPTR,A ;
POP DPH ;POP DPL ;MOV A,B ;TURN THE MOTOR ON i.e.MOV DPTR,#280EH ;SET DIRECTION
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
131
MOVX @DPTR,A ;CLR A ;MOV DPTR,#280CH ;SMALLEST COUNT TO TURNMOVX @DPTR,A ;MOTOR ONLJMP LOOP ;
MSG1: DFB "DIR F/R",03HMSG2: DFB "SPEED ",03H
DFB 00H,50HEND
INTERFACING AND PROGRAMMING OF STEPPER MOTORUSING 8051
STEPPER MOTOR INTERFACING
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
132
AIMTo write an assembly language program to interface stepper motor
with 8051.
APPARATUS REQUIRED
8081 Microcontroller kit, Power chord, stepper motor, stepper motorinterface board
THEORYA motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a step-wise
manner from one equilibrium position to the next. Stepper Motors are used
very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator
poles. Each of the four poles has its own winding. The excitation of any one
winding generates a North Pole. A South Pole gets induced at the
diametrically opposite side. The rotor magnetic system has two end faces. It
is a permanent magnet with one face as South Pole and the other as North
Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited
with a DC current to run the motor in clockwise direction. By reversing the
phase sequence as A1, B2, A2, B1, anticlockwise stepping can be obtained.
2-PHASE SWITCHING SCHEMEIn this scheme, any two adjacent stator windings are energized. The
switching scheme is shown in the table given below. This scheme produces
more torque.
ANTICLOCKWISE CLOCKWISESTE
PA1
A2 B1
B2 DATA STEP
A1
A2
B1
B2 DATA
1 1 0 0 1 9h 1 1 0 1 0 Ah
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
133
2 0 1 0 1 5h 2 0 1 1 0 6h3 0 1 1 0 6h 3 0 1 0 1 5h4 1 0 1 0 Ah 4 1 0 0 1 9h
ADDRESS DECODING LOGICThe 74138 chip is used for generating the address decoding logic to
generate the device select pulses; CS1 & CS2 for selecting the IC 74175.The
74175 latches the data bus to the stepper motor driving circuitry.
Stepper Motor requires logic signals of relatively high power.
Therefore, the interface circuitry that generates the driving pulses uses
silicon Darlington pair transistors. The inputs for the interface circuit are
TTL pulses generated under software control using the Microcontroller Kit.
The TTL levels of pulse sequence from the data bus are translated to high
voltage output pulses using a buffer 7407 with open collector.
ALGORITHM
1. Store the lookup table address in DPTR.
2. Move the content value (04H) to one of the register (R0).
3. Load the control word for motor rotation in accumulator.
4. PUSH the address in DPTR into stack.
5. Load FFC0 in to DPTR.
6. Call the delay program.
7. Send the control word for motor rotation to the external device.
8. POP up the values in stack and increment it.
9. Decrement the count in R0. If zero, go to next step, else proceed to
step 3.
10.Perform steps 1 to 9 repeatedly.ADDRESS LABEL MNEMONICS OPCODE
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
134
4100 START MOV DPTR,#4500 90 45 00
4103 MOV R0 #04 78 044105 MOVX A@DPTR E04106 PUSH DPH C0 834108 PUSH DPL C0 82410A MOV DPTR,#FFC0 90 FF C0
410D MOV R2 #04 7A 04410F MOV R1 #0F 7B 0F4111 DLY1 MOV R3 #0F 7B 0F4113 DLY DJNZ R3 DLY DB FE4115 DJNZ R1 DLY1 D9 FA4117 DJNZ R2 DLY1 DA F84119 MOVX@DPTR,A F0411A POP DPL D0 82411C POP DPH D0 83411E INC DPTR A3411F DJNZ R0 J0 D8 E44121 SJMP START 80 DD
SAWTOOTH WAVE GENERATION USING 8051AIM
To write an assembly language program to generate the saw tooth wave using
microcontroller instruction set.
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
135
APPARATUS REQUIRED8051 Microcontroller kit, Power chord, DAC Interface Card, CRO
ALGORITHM1. Move the port address of DAC to DPTR.
2. Load the initial value (00H) to accumulator.
3. Move the accumulator content to DAC.
4. Increment the accumulator content by 1.
5. Repeat steps 3 and 4.
PROGRAMORG 4100HDAC I EQU FFC0HADDRESS LABEL MNEMONICS OPCODE COMMENT4100 START MOV A,#00H 74 00 MOVE DATA
TO ACC4102 L1 MOV
DPTR,#DAC I90 FF C0 MOVE DATA
TO DPTR4105 MOVX@DPTR,A F0 MOVE DPTR
TO ACC4106 INC A 04 INCREMENT
ON ACC4107 JNZ L1 70 F9 IF JUMP NO
ZERO GO TOL1
4109 SJMP START 80 F5 SHORT JUMPTO START
OBSERVATION
S.No TIME PERIOD (msec) AMPLITUDE (volts)
1 1.2* 2 = 2.4mse 2.4 * 2 = 4.8 V
RESULT:Thus the assembly language program to generate the triangular wave using 8051
instruction set was written and executed successfully.
TRIANGULAR WAVE GENERATION USING 8051AIM
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
136
To write an assembly language program to generate the triangular
wave using microcontroller instruction set.
APPARATUS REQUIRED
8051 Microcontroller kit, Power chord, DAC Interface Card, CRO
ALGORITHM1. Move the port address of DAC to DPTR.
2. Load the initial value (00H) to accumulator.
3. Move the accumulator content to DAC.
4. Increment the accumulator content by 1.
5. If accumulator content is zero proceed to next step. Else go to step
3.
6. Load value (FF) to accumulator.
7. Move the accumulator content to DAC.
8. Decrement the accumulator content by 1.
9. If accumulator content is zero go to step2. Else go to step 7.
PROGRAMORG 4100HDAC I EQU FFC0H
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
137
ADDRESS LABEL MNEMONICS OPCODE COMMENT4100 START MOV A,#00H 74 00 MOVE DATA
TO ACC4102 L1 MOV
DPTR,#DAC I90 FF C0 MOVE DATA
TO DPTR4105 MOVX@DPTR,A F0 MOVE DPTR
TO ACC4106 INC A 04 INCREMENT
ON ACC4107 JNZ L1 70 F9 IF JUMP NO
ZERO GO TOL1
4109 MOV A,#FFH 70 FF MOVE DATATO ACC
410B L2 MOVX@DPTR,A F0 MOVE DPTRTO ACC
410C DEC A 14 DECREMENTON ACC
410D JNZ L2 70 FC IF JUMP NOZERO TO L2
410F SJMP START 80 EF SHORT JUMPTO START
OBSERVATION
S.No TIME PERIOD (msec) AMPLITUDE (volts)
1 1.6 * 2 = 3.2mse 2.5 * 2 = 5 V
RESULT
Thus the assembly language program to generate the triangular wave
using 8051 instruction set was written and executed successfully.
PROGRAMMING AND VERIFYING TIMER, INTERRUPTS ANDUART OPERATIONS IN 8051 MICROCONTROLLER
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
138
1-INTERFACING PROGRAM OF TIMER [8053] USINGMICROCONTROLLERA) SQUARE WAVE GENERATION MODEADDRESS LABEL MNEMONICS OPCODE COMMENT4100 MOV
DPTR,#FFCE90 FF CE MOVE DATA TO
DATA POINTER4103 MOV A,#36 74 36 MOVE DATA TO
ACCUMULATOR4105 MOVX@DPTR,A F0 MOVE DPTR TO
ACC4106 MOV A,#0A 74 0A MOVE DATA TO
ACC4108 MOV
DPTR,#FFC890 FF C8 MOVE DATATO
DPTR410B MOVX@DPTR,A F0 MOVE DPTR TO
ACC410C MOV A,#00 74 00 MOVE DATA TO
ACC410E MOVX
@DPTR,AF0 MOVE DPTR TO
ACC410F HERE: SJMP HERE 80 FE SHORT JUMP TO
HERE
7. PROGRAMMING AND VERIFYING TIMER, INTERRUPTS ANDUART OPERATIONS IN 8051 MICROCONTROLLER
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
139
1-INTERFACING PROGRAM OF TIMER [8053] USINGMICROCONTROLLERB) SQUARE WAVE GENERATION OF FREQUENCY 150 KHz AT CHANNEL 0ADDRESS LABEL MNEMONICS OPCODE COMMENT4100 MOV A,#36 74 36 MOVE DATA
TO ACC4102 MOV
DPTR,#FFCE90 FF CE MOVE DATA
TO DPTR4105 MOVX@DPTR,A F0 MOVE DPTR
TO ACC4106 MOV A,#12 74 12 MOVE DATA
TO ACC4108 MOV
DPTR,#FFC890 FF C8 MOVE
DATATODPTR
410B MOVX@DPTR,A F0 MOVE DPTRTO ACC
410C MOV A,#00 74 00 MOVE DATATO ACC
410E MOVX@DPTR,A
F0 MOVE DPTRTO ACC
410F HERE: SJMP HERE 80 FE SHORT JUMPTO HERE
7. PROGRAMMING AND VERIFYING TIMER, INTERRUPTS ANDUART OPERATIONS IN 8051 MICROCONTROLLER
http://csetube.co.nr/
http:/
/csetu
be.co
.nr/
CS2259 Microprocessors Laboratory
140
2-INTERFACING PROGRAM OF INTERRUPTS [8059] USINGMICROCONTROLLERTO PROGRAM 8259 IN POLLING MODE
ADDRESS LABEL MNEMONICS OPCODE4100 MOV 1E,#00 75 A8 004103 MOV A,#16 74 164105 MOV DPTR,#FFCO 90 FF C0
4108 MOV @DPTR,A F04109 MOV DPTR,#FFC2 90 FF C2
410C MOV A,#00 74 00410F MOV @DPTR,A F04110 MOV @DPTR,A F04111 MOV DPTR,#FFCO 90 FF C0
4114 MOV A,#40 74 404116 MOV @DPTR,A F04117 WAIT MOV A,#0C 74 0C4119 MOV @DPTR,A F0411A MOV A, @DPTR E0411B MOV R0,A F8411C JNB E0 WAIT 30 E0 F8411F MOV A,R0 F84120 ANL A,#07 54 074122 CJNE A,#00 HERE B4 00 03
4124 LCALL ISR 12 41 504127 HERE: SJMP HERE 80 FE
ISR ORG 4150ADDRESS LABEL MNEMONICS OPCODE4150 MOV A,#00 74 004152 LCALL 0020 12 00 204155 STOP SJMP STOP 80 FE
RESULT
http://csetube.co.nr/