Microprocessor
Microprocessor
Microprocessor
CS 2259-MICROPROCESSOR
LABORATORY
Approved by AICTE, New Delhi & Affiliated to Anna University
No 60, Avadi-Vel tech Road, Chennai – 600 062
PREPARED BY (HOD/ECE)
Mr. G VISHNU VARDHAN RAO Mr.RAMACHANDRAN M.TECH
Mr. D. RUBAN THOMAS
1
CS2259 Microprocessors Laboratory
CS 2259-MICROPROCESSOR
LABORATORY
Approved by AICTE, New Delhi & Affiliated to Anna University
No 60, Avadi-Vel tech Road, Chennai – 600 062
PREPARED BY (HOD/ECE)
Mr. C.S.SIVANTHIRAM Mr.RAMACHANDRAN M.TECH
Mr. D. RUBAN THOMAS
2
CS2259 Microprocessors Laboratory
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 the
processor.
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 8085
2. Programming with 8086-experiments including BIOS/DOS calls:
3. Keyboard control, Display, File Manipulation.
4. Interfacing with 8085/8086-8255,8253
5. Interfacing with 8085/8086-8279,8251
6. 8051 Microcontroller based experiments for Control Applications
7. Mini- Project
TOTAL: 45 PERIODS
3
CS2259 Microprocessors Laboratory
4
CS2259 Microprocessors Laboratory
5
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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.
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.
6
CS2259 Microprocessors Laboratory
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.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 LDA 6201 3A 01 62
6103 MOV B,A 47
6104 LDA 6200 3A 00 62
7
CS2259 Microprocessors Laboratory
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.
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.
8
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
9
CS2259 Microprocessors Laboratory
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)
10
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to multiply the two 8-bit
numbers was written and executed successfully.
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.
11
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
12
CS2259 Microprocessors Laboratory
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.
13
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
14
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 05H
6201 0AH
6202 03H
6300 0CH
6203 08H
6204 06H
6205 0CH
RESULT
Thus the assembly language program to search the largest data in an
array was written and executed successfully.
15
CS2259 Microprocessors Laboratory
16
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
17
CS2259 Microprocessors Laboratory
6200 05H
6201 0AH
6202 03H
6300 03H
6203 08H
6204 06H
6205 0CH
RESULT
Thus the assembly language program to search the smallest data in an
array was written and executed successfully.
18
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
19
CS2259 Microprocessors Laboratory
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
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
20
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to sort an array of data in
ascending order was written and executed successfully.
21
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
22
CS2259 Microprocessors Laboratory
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
23
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to sort an array of data in
descending order was written and executed successfully.
24
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
25
CS2259 Microprocessors Laboratory
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.
26
CS2259 Microprocessors Laboratory
27
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 30H 6201 01H
28
CS2259 Microprocessors Laboratory
6202 00H
RESULT
Thus the assembly language program to covert the HEX code to
ASCII code was written and executed successfully.
CONVERT THE HEX CODE TO BCD CODE USING 8085
AIM
To write an assembly language program to convert the HEXI code to
BCD code.
APPARATUS REQUIRED
29
CS2259 Microprocessors Laboratory
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
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
6100 MVI E,00H IE 00
6102 MOV D,E 53
6103 LDA 6200 3A 00 62
30
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
4201 55H (Tens and Units)
4200 55H
4202 00H (hundreds)
31
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to covert the HEX code to BCD code
was written and executed successfully.
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
32
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
33
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6200 10 6201 0AH
34
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to covert the HEX code to
ASCII code was written and executed successfully.
35
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
4100 START MVI A,00H 3E 00
4102 OUT CNT D3 C8
4104 ORI 08 F6 08
4106 OUT CNT D3 C8
4108 NOP 00
4109 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
36
CS2259 Microprocessors Laboratory
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
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
37
CS2259 Microprocessors Laboratory
OBSERVATION
38
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to interface ADC board with
8085 was written and executed successfully.
39
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
40
CS2259 Microprocessors Laboratory
OBSERVATION
RESULT
41
CS2259 Microprocessors Laboratory
42
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
43
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to generate triangular wave was
written and executed successfully.
44
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to generate saw tooth wave was
written and executed successfully
TRAFFIC LIGHT CONTROLLER USING 8085
AIM
To write an assembly language program to interface traffic light
controller with 8085 using 8255.
APPARATUS REQUIRED
45
CS2259 Microprocessors Laboratory
46
CS2259 Microprocessors Laboratory
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
47
CS2259 Microprocessors Laboratory
POSITION 2EH
0 0 1 0 1 1 1 0
1
POSITION 9DH
1 0 0 1 1 1 0 1
2
POSITION 2BH
0 0 1 0 1 0 1 1
3
POSITION 27H
0 0 1 0 0 1 1 1
4
48
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to interface traffic light
controller with 8085 using 8255 was written and executed successfully.
49
CS2259 Microprocessors Laboratory
8. Stop.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
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
50
CS2259 Microprocessors Laboratory
6C 1A 68 E8
RESULT
Thus the assembly language program to timer interface with 8085
using 8251 was written and executed successfully.
51
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to interface keyboard/display
board with 8085 using 8279 was written and executed successfully.
TIMER INTERFACE WITH 8085 USING 8254
AIM
To write an assembly language program to timer interface with 8085
using 8254.
52
CS2259 Microprocessors Laboratory
APPARATUS REQUIRED
8085 Microprocessor kit, Power chord, 8254 interface board.
ALGORITHM
1. 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
LABEL MNEMONICS OP CODE
ADDRESS
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
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
53
CS2259 Microprocessors Laboratory
AIM
To 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
LABEL MNEMONICS OP CODE
ADDRESS
54
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
2000 04H 3000 06H (Sum)
2001 04H 3001 06H (Sum)
2002 02H
3002 00 (Carry)
2004 02H
55
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to add the two 16-bit numbers
using 8085 simulator tool was written and executed successfully.
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
1000 START MVI C, 00
1008 LHLD 2000H
1000 XCHG
1005 LHLD 2002H
1008 MOV A, L
56
CS2259 Microprocessors Laboratory
1000 SUB E
1005 MOV L, A
1008 MOV A, H
1009 SBB D
1000 MOV H, A
1008 SHLD 3000H
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 02H
3002 00H (Borrow)
2004 02H
RESULT
57
CS2259 Microprocessors Laboratory
AIM
To 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
LABEL MNEMONICS OP CODE
ADDRESS
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
58
CS2259 Microprocessors Laboratory
1009 INX B
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 02H
3002 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.
59
CS2259 Microprocessors Laboratory
AIM
To 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
LABEL MNEMONICS OP CODE
ADDRESS
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
1000 JNC LOOP
1005 DCX B
1008 DAD D
60
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
2000 04H 3000 02H (Quotient)
2001 04H 3001 02H (Quotient)
2002 02H
3002 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.
61
CS2259 Microprocessors Laboratory
62
CS2259 Microprocessors Laboratory
CONTENT
WITH
ACCUMULATOR
OUT PUT:
SUBTRACT
1003 SUB AX[1102] 2B,06,02,11 MEMORY CONTENT
WITH
ACCUMULATOR
MOVE
1007 MOV [1200],AX A3,00,12 ACCUMULATOR
CONTENT TO
MEMORY
100A HLT F4
63
CS2259 Microprocessors Laboratory
STOP
OUT PUT:
MULTIPLY MEMORY
1003 MUL[1102] F7,26,02,11 CONTENT
WITH
ACCUMULATOR
MOVE
1007 MOV [1200],DX 87,16,00,12 ACCUMULATOR
CONTENT TO AX
REGISTER
64
CS2259 Microprocessors Laboratory
OUT PUT:
1003 DIV[1102]
F7,36,02,11 DIVIDE MEMORY
CONTENT
WITH
ACCUMULATOR
100B
MOV[1200],AX A3,00,12 MOVE CONTENT
OF AX
REGISTER TO
MEMORY
65
CS2259 Microprocessors Laboratory
OUT PUT:
66
CS2259 Microprocessors Laboratory
IN PUT:
IN PUT OUT PUT
ANALOG DIGITAL DATA
VOLTAGE
5V FF [1100]
67
CS2259 Microprocessors Laboratory
68
CS2259 Microprocessors Laboratory
69
CS2259 Microprocessors Laboratory
70
CS2259 Microprocessors Laboratory
1016 RET C3
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
71
CS2259 Microprocessors Laboratory
I/O MODES:
Control Word:
TRANSMITTER PROGRAM:
RECEIVER PROGRAM:
ADDRESS LABEL MNEMONICS OPCODES
1000 MOV AL,90 B0 90
1002 OUT 0F,AL E6 0F
1004 IN AL 0C E4 0C
1006 MOV BX[1250] BB 50 12
72
CS2259 Microprocessors Laboratory
1009 MOV BX AL 88 07
100B HLT F4
73
CS2259 Microprocessors Laboratory
SUB PROGARM:
ADDRESS LOOP MNEMONICS OP-CODE COMMANDS
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.
74
CS2259 Microprocessors Laboratory
ORG 1000
1000 MOV B0 17 MOVE DATA TO
C2,AL(17) ACCUMULATOR
1002 OUT C2,AL E6 C0 SEND VALUE
TO
75
CS2259 Microprocessors Laboratory
OUTPUT PORT
1004 MOV B0 08 MOVE DATA TO
C2,AL(08) ACCUMULATOR
1006 OUT C2,AL E6 C2 SEND VALUE
TO
OUTPUT PORT
1008 MOV AL,01 B0 01 MOVE DATA TO
ACCUMULATOR
100A OUT C2,AL E6 C2 SEND VALUE
TO
OUTPUT PORT
100C MOV AL,FE B0 00 MOVE DATA TO
ACCUMULATOR
100E OUT C2,AL E6 C2 SEND VALUE
TO
OUTPUT PORT
1010 MOV AL,68 BO 68 MOVE DATA TO
ACCUMULATOR
1012 OUT C0,AL E6 C0 SEND VALUE
TO
OUTPUT PORT
1014 STI FB SET INTERRUPT
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 DATA
0020 00
0021 12
0022 00
0023 00
76
CS2259 Microprocessors Laboratory
77
CS2259 Microprocessors Laboratory
ACCUMULATOR
100A OUT C8,AL E6 C8 SEND DATA TO
THE
OUTPUT PORT
100C HLT F4 HALT
78
CS2259 Microprocessors Laboratory
OUTPUT PORT
100C MOV AL,4E B0 4E MOVE THE VALUE
TO
ACCUMULATOR
100E OUT C2,AL E6 C2 SEND DATA TO
OUTPUT PORT
1010 MOV AL,37 B0 37 MOVE THE VALUE
TO
ACCUMULATOR
1012 OUT C2,AL E6 C2 SEND DATA TO
OUTPUT PORT
1014 MOV AL,AA BO AA MOVE THE VALUE
TO
ACCUMULATOR
1016 OUT CO,AL E6 CO SEND DATA TO
OUTPUT PORT
1018 INT 02 CD 02 INTERUPT
RECEIVER PROGRAM
ADDRESS MNEMONICS OP-CODE COMMANDS
1200 IN AL,C0 E4 C0 INTERUPT
79
CS2259 Microprocessors Laboratory
THEORY
A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a step-wise
manner from one equilibrium position to the next. Stepper Motors are used
80
CS2259 Microprocessors Laboratory
very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator
poles. Each of the four poles has its own winding. The excitation of any one
winding generates a North Pole. A South Pole gets induced at the
diametrically opposite side. The rotor magnetic system has two end faces. It
is a permanent magnet with one face as South Pole and the other as North
Pole.
The Stepper Motor windings A1, A2, B1, B2 are cyclically excited
with a DC current to run the motor in clockwise direction. By reversing the
phase sequence as A1, B2, A2, B1, anticlockwise stepping can be obtained.
2-PHASE SWITCHING SCHEME
In this scheme, any two adjacent stator windings are energized. The
switching scheme is shown in the table given below. This scheme produces
more torque.
ANTICLOCKWISE CLOCKWISE
STE A A2 B B2 DATA STE A A B B2 DATA
P 1 1 P 1 2 1
1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h
81
CS2259 Microprocessors Laboratory
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.
82
CS2259 Microprocessors Laboratory
100F INC D1 47
1008 DEC BL FE CB
100F MOV BL 20 B3 20
83
CS2259 Microprocessors Laboratory
1017 DEC BL FE CB
102C INC D1 47
102D RET C3
1030 DEC DX 4A
84
CS2259 Microprocessors Laboratory
1036 RET C3
1037 FORW DB 09 05 06 0A
103B REV DB 0A 06 05 09
APPARATUS REQUIRED:
1. 8086 µ p kit
2. 8255 Interface board
3. DC regulated power supply
4. VXT parallel bus
I/O MODES:
Control Word:
85
CS2259 Microprocessors Laboratory
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODES
1000 MOV SI , 1500 BE 00 15
1003 MOV AL,90 B0 90
1005 OUT C6,AL E6 C6
1007 IN AL,C0 E4 C0
1009 MOV [SI], AL 88 04
100B HLT F4
86
CS2259 Microprocessors Laboratory
PROGRAM:
87
CS2259 Microprocessors Laboratory
RESULT:
Thus 8255 are interfaced and their characteristic in mode0 was studied.
88
CS2259 Microprocessors Laboratory
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:
89
CS2259 Microprocessors Laboratory
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:
90
CS2259 Microprocessors Laboratory
INT 21H
CODE ENDS
END START
RESULT:
91
CS2259 Microprocessors Laboratory
RESULT:
92
CS2259 Microprocessors Laboratory
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:
RESULT:
93
CS2259 Microprocessors Laboratory
94
CS2259 Microprocessors Laboratory
95
CS2259 Microprocessors Laboratory
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
96
CS2259 Microprocessors Laboratory
XCHG [SI],AX
PR1:ADD SI,02
LOOP AGAIN1
DEC DX
JNZ AGAIN0
MOV AH,4CH
INT 21H
CODE ENDS
END START
RESULT:
97
CS2259 Microprocessors Laboratory
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
98
CS2259 Microprocessors Laboratory
DEC CL
JNZ AGAIN
MOV SI,OFFSET LARGEST
MOV [SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
99
CS2259 Microprocessors Laboratory
AIM:
To display a string using MASM software.
ALGORITHM:
1. Initialize the data segment and the message to be displayed.
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
100
CS2259 Microprocessors Laboratory
AIM:
To perform arithmetic operations such as addition,subtraction,
multiplication division operations using MASM software.
ALGORITHM:
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
101
CS2259 Microprocessors Laboratory
MOV BL,0PR2
XOR AL,AL
MOV AL,0PR1
ADD AL,BL
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
102
CS2259 Microprocessors Laboratory
103
CS2259 Microprocessors Laboratory
AIM
To write an assembly language program to add the two 8-bit numbers
using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
PROGRAM
MEMOR
Y LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
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
104
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6102
6500
6103
RESULT
Thus, the assembly language program to add the two 8-bit numbers
using 8051 instruction set was written and executed successfully.
105
CS2259 Microprocessors Laboratory
EX NO: b
DATE:
SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to subtract the two 8-bit
numbers using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
PROGRAM
MEMOR
Y LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
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
OBSERVATION
106
CS2259 Microprocessors Laboratory
INPUT OUTPUT
Address Data Address Data
6102
6500
6103
RESULT
Thus, the assembly language program to subtract the two 8-bit
numbers was written and executed successfully.
107
CS2259 Microprocessors Laboratory
EX NO: c
DATE:
MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051
AIM
To write an assembly language program to multiply the two 8-bit
numbers using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Clear C-register for carry.
2. Move the first data to Accumulator.
PROGRAM
MEMOR LABEL MNEMONICS OP CODE COMMENTS
108
CS2259 Microprocessors Laboratory
Y
ADDRESS
6100 CLR C C3
6101 MOV A,#data1 74, 04
6103 MOV B,#data2 75, F0, 02
6106 MUL AB A4
6107 MOV DPTR, #6500H 90, 65, 00
610A MOVX @DPTR, A F0
610B INC DPTR A3
610C MOV A, B E5, F0
610E MOVX @DPTR, A F0
610F LOOP SJMP LOOP 80, FE
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6102 6500
109
CS2259 Microprocessors Laboratory
6103 6501
RESULT
Thus, the assembly language program to multiply the two 8-bit
numbers using 8051 instruction set was written and executed
110
CS2259 Microprocessors Laboratory
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
MEMOR
Y LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
6100 CLR C C3
111
CS2259 Microprocessors Laboratory
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.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: e
DATE:
ONE’S AND TWO’S COMPLEMENT USING 8051
AIM
To write an assembly language program to find the 1’s and 2’s
complement of an 8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
112
CS2259 Microprocessors Laboratory
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Complement the accumulator.
ADDRESS
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
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6500
6101 6501
113
CS2259 Microprocessors Laboratory
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.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: f
DATE:
SETTING BITS IN AN 8 BIT NUMBERS USING 8051
AIM
To write an assembly language program to find the Setting bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
114
CS2259 Microprocessors Laboratory
PROGRAM
MEMOR
Y LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
6100 MOV A, #data1 74, 2F
6102 ORL A, #data2 44, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6101
6500
6103
115
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to Setting bits an
8-bit number using microcontroller instruction set was written and executed
successfully.
PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT
MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER
EX NO: g
DATE:
MASKING BITS IN AN 8 BIT NUMBERS USING 8051
AIM
To write an assembly language program to find the Masking bits an
8-bit number using microcontroller instruction set.
APPARATUS REQUIRED
1. 8051 Microcontroller kit
2. Power chord.
ALGORITHM
1. Move the data to Accumulator.
2. Perform AND operation with accumulator.
116
CS2259 Microprocessors Laboratory
PROGRAM
MEMOR
Y LABEL MNEMONICS OP CODE COMMENTS
ADDRESS
6100 MOV A, #data1 74, 2F
6102 ANL A, #data2 54, 7E
6104 MOV DPTR, #6500H 90, 65, 00
6107 MOVX @DPTR, A F0
6108 LOOP SJMP LOOP 80, FE
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6101
6500
6103
117
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to masking bits an
8-bit number using microcontroller instruction set was written and executed
successfully.
118
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
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
119
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
(Before sorting) (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
RESULT
Thus, the assembly language program to sort an array of data in ascending order
using 8051 simulator tools was written and executed successfully.
120
CS2259 Microprocessors Laboratory
EX NO: b
DATE:
ARRANGE THE GIVEN NUMBER IN DESCENDING ORDER
AIM
To write an assembly language program to sort an array of data in
descending order using 8051 simulator tool.
APPARATUS REQUIRED
8051 Microcontroller Kit
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.
PROGRAM
MEMORY LABEL MNEMONICS OP CODE
121
CS2259 Microprocessors Laboratory
ADDRESS
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
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
122
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
(Before sorting) (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
RESULT
Thus the assembly language program to sort an array of data in descending
order using 8051 simulator tools was written and executed successfully.
123
CS2259 Microprocessors Laboratory
PROGRAM
MEMORY
LABEL MNEMONICS OP CODE
ADDRESS
124
CS2259 Microprocessors Laboratory
OBSERVATION
INPUT OUTPUT
Address Data Address Data
6500 04H
6501 08H
6502 02H 6500 0AH
6503 0AH
6504 06H
125
CS2259 Microprocessors Laboratory
RESULT
Thus the assembly language program to find the largest number in an
array using 8051 simulator tools was written and executed successfully
INTERFACING OF 8279
ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b) USINGH 8051
ADDRESS LABEL MNEMONICS OP-CODE
4018 MOVX@DPTR,A F0
4019 LCALL DELAY 12 45 00
126
CS2259 Microprocessors Laboratory
401C INC R0 08
401D CJNE R0,#0F,LOOP B8 0F F0
ORG 4500
ADDRESS LABEL MNEMONICS OP-CODE
4500 MOV R4,#A0 7C A0
4502 LOOP2 MOV R5,#FF 7D FF
4504 LOOP1 NOP 00
4505 DJNZ R5,LOOP1 DD FD
4509 RET 22
LOOK-UP TABLE
ADDRESS DATA
4400 FF,FF,FF,FF
4404 FF,FF,FF,FF
4408 68,6C,68,FF
440C FF,38,FF,FF
RESULT
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
127
CS2259 Microprocessors Laboratory
ORG 6A00H
MOV SP,#STKTOP ;INIT STACK PTR
MOV A,#80H ;CONTROL WORD FOR 8255
MOV DPTR,#280FH ;SET ALL PORTS AS O/P PORTS
MOVX @DPTR,A ;
LOOP: LCALL CRLF ;CLEAR 7-SEG DISPLAY
128
CS2259 Microprocessors Laboratory
MOV DPTR,#MSG1 ;
LCALL MSGOUT ;DIPLAY "DIR F/R"
TEST: LCALL RD79 ;LOOK FOR KEYBOARD I/P
CJNE A,#46H,REV ;
MOV B,#01H ;
LJMP SPEED ;
REV: CJNE A,#52H,FIN1 ;IF REVERSE, SET PC1 HIGH
MOV B,#02H ;
LJMP SPEED ;
FIN1: CJNE A,#1BH,TEST ;IF "ESC" KEY PRESSED,
CLR A ;TURN OFF THE MOTOR
MOV DPTR,#280EH ;GOTO COMMAND PROMPT
MOVX @DPTR,A ;
LJMP CMDMOD ;
SPEED: LCALL CRLF ;CLEAR 7-SEG DISPLAY
MOV 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 KEYBOARD
MOV A,R3 ;MOVE KBD I/P FROM R3,A
CJNE A,#50H,INVERT ;
SJMP WAVE ;
INVERT: JC WAVE ;
MOV A,B ;
ORL A,#08H ;
MOV B,A ;
WAVE: MOV DPTR,#281BH ;FOR 8253: 4/4/02
MOV A,#36H ;
MOVX @DPTR,A ;COUNTER0 IN MODE 3
MOV A,#00H
CJNE A,R3,MOD2
MOV A,#90H
SJMP 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,R3
JZ NXTTB
INC DPTR ;
129
CS2259 Microprocessors Laboratory
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
MOVX @DPTR,A ;
CLR A ;
MOV DPTR,#280CH ;SMALLEST COUNT TO TURN
MOVX @DPTR,A ;MOTOR ON
LJMP LOOP ;
130
CS2259 Microprocessors Laboratory
THEORY
A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a step-wise
manner from one equilibrium position to the next. Stepper Motors are used
very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
131
CS2259 Microprocessors Laboratory
ANTICLOCKWISE CLOCKWISE
STE A A2 B B2 DATA STE A A B B2 DATA
P 1 1 P 1 2 1
1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h
132
CS2259 Microprocessors Laboratory
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.
133
CS2259 Microprocessors Laboratory
134
CS2259 Microprocessors Laboratory
DPTR,#DAC I TO DPTR
4105 MOVX@DPTR,A F0 MOVE DPTR
TO ACC
4106 INC A 04 INCREMENT
ON ACC
4107 JNZ L1 70 F9 IF JUMP NO
ZERO GO TO
L1
4109 SJMP START 80 F5 SHORT JUMP
TO 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.
3.
6. Load value (FF) to accumulator.
135
CS2259 Microprocessors Laboratory
PROGRAM
ORG 4100H
DAC I EQU FFC0H
ADDRESS LABEL MNEMONICS OPCODE COMMENT
4100 START MOV A,#00H 74 00 MOVE DATA
TO ACC
4102 L1 MOV 90 FF C0 MOVE DATA
DPTR,#DAC I TO DPTR
4105 MOVX@DPTR,A F0 MOVE DPTR
TO ACC
4106 INC A 04 INCREMENT
ON ACC
4107 JNZ L1 70 F9 IF JUMP NO
ZERO GO TO
L1
4109 MOV A,#FFH 70 FF MOVE DATA
TO ACC
410B L2 MOVX@DPTR,A F0 MOVE DPTR
TO ACC
410C DEC A 14 DECREMENT
ON ACC
410D JNZ L2 70 FC IF JUMP NO
ZERO TO L2
410F SJMP START 80 EF SHORT JUMP
136
CS2259 Microprocessors Laboratory
TO START
OBSERVATION
RESULT
Thus the assembly language program to generate the triangular wave
using 8051 instruction set was written and executed successfully.
137
CS2259 Microprocessors Laboratory
138
CS2259 Microprocessors Laboratory
139
CS2259 Microprocessors Laboratory
RESULT
140