Вы находитесь на странице: 1из 140

CS2259 Microprocessors Laboratory

VEL TECH HIGH TECH Dr.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-MICROPROCESSOR LABORATORY
Approved by AICTE, New Delhi & Affiliated to Anna University
No 60, Avadi-Vel tech Road, Chennai 600 062

PREPARED BY E.JAYAPRAKASH N.PRABHAKARAN MUBEEN MUBARAK

ht

tp

://

cs

et

ub

e.c

o.
(HOD/ECE) ESTHER RANI.P

nr

http://csetube.co.nr/

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

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 15 nos. 5. Stepper motor interfacing module 5 nos. 6. Traffic light controller interfacing module 5 nos. 7. ADC, DAC interfacing module 5 nos. 8. CROs 5 nos.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

ADDITION OF TWO 8-BIT NUMBERS WITH CARRY USING 8085 To write an assembly language program to add the two 8-bit numbers

AIM 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 B3. Move the second data from memory to accumulator. 5. Check for carry. If carry=1 then go to step 6 else go to step 7. 7. Store the sum in memory. 8. Move the carry to accumulator and store in memory. 9. Stop. register.

ht

tp

://

6. Increment the C-register

cs

et

ub

e.c

4. Add the content of B-register with Accumulator.

o.

nr

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6104 6107 6109 610A 610D 610E 6111 6112 6115 OBSERVATION

LABEL

MNEMONICS LDA 6200 MOV B,A LDA 6201 MVI C,00 ADD B JNC LOOP INR C MOV A,C HLT

OP CODE 3A 00 62 47 3A 01 62 0E 00 80 D2 0E 61 0C 32 02 62 79 32 03 62 76

INPUT Address 6200 6201 Data 02H 05H Address 6202 6203

ht

tp

://

cs

et
OUTPUT Data 07H

ub

STA 6203

e.c

o.

nr

LOOP

STA 6202

(sum)

00H (carry)

RESULT

Thus the assembly language program to add the two 8-bit

numbers was written and executed successfully.

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

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. B-register. 2. Move the subtrahend from memory to accumulator and move it to

01H.

7. Store the Difference in memory. 8. Move the sign to accumulator and store in memory. 9. Stop.

ht

tp

6. Increment the C-register. Complement the accumulator and add

://

5. Check for carry. If carry=1 then go to step 6 else go to step 7.

cs

et

4. Subtract the content of B-register from Accumulator.

ub

e.c

3. Move the minuend from memory to accumulator.

o.

nr

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6104 6107 6109 610A 610D 610E 610F 6111 6114 6115 6118 OBSERVATION INPUT Address 6200 6201 RESULT

LABEL

MNEMONICS LDA 6201 MOV B,A LDA 6200 MVI C,00 SUB B JNC LOOP INR C ADI 01H CMA

OP CODE 3A 01 62 47 3A 00 62 0E 00 90 D2 11 61 0C 2F C6 01 32 02 62 79 32 03 62 76

ht

tp

://

cs

STA 6203 HLT

et

MOV A,C

ub

LOOP

STA 6202

e.c
OUTPUT 02H 00H

Data 04H 02H

Address 6202 6203

o.

nr

/
Data

(Difference) (sign)

Thus the assembly language program to subtract the two 8-bit numbers was written and executed successfully.

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

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). 4. Move the first data to B-register. 5. Increment the pointer. 3. Clear the accumulator.

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.

ht

tp

8. Check for carry, if carry = 1, go to step 9,or carry = 0, go to step

://

7. Add the content of D-register to accumulator.

cs

et

6. Move the second data to D-register from memory (multiplicand).

ub

e.c

o.

nr

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6105 6106 6107 6108 6109 610A 610D 610E 610F 6112 6113 6114 6115 6116 OBSERVATION INPUT Address 6200 6201

LABEL

MNEMONICS LXI H, 6200 MVI C,00 XRA A MOV B,M INX H MOV D,M JNC AHEAD

OP CODE 21 00 62 0E,00 AF 23 B8 56 82 D2 0E 61 0C 05 C2 09 61 23 77 23 71 76

ht

tp

://

cs

JNZ REPT INX H MOV M,A INX H MOV M,C HLT

et

AHEAD

DCR B

ub
OUTPUT

INR C

Data 02H 04H

Address 6202 6203

e.c

o.

nr

REPT

ADD D

Data 08H (LSB of product) 00H (MSB of product)

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

RESULT Thus the assembly language program to multiply the two 8-bit numbers was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

10

CS2259 Microprocessors Laboratory

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. 3. Clear C-register to account for quotient. 2. Load the dividend in 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.

ht

tp

5. Subtract the content of B register from accumulator.

://

step.

cs

et

If divisor is less than dividend, go to step 8, otherwise go to next

ub

e.c

4. Check whether divisor is less than dividend

o.

nr

http://csetube.co.nr/

11

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6104 6107 6109 610A 610D 610E 610F 6112 6115 6116 6119 OBSERVATION INPUT Address 6200 6201 RESULT

LABEL

MNEMONICS LDA 4201 MOV B,A LDA 4200 MVI C,00

OP CODE 3A 01 42 47 3A 00 42 0E 00 B8 DA 12 61 90 0C C3 09 61 32 03 42 79 32 02 62 76

AGAIN

CMP B JC STORE INR C SUB B

ht

tp

://

cs

MOV A,C STA 6202 HLT

et

STORE

STA 6203

ub

JNC AGAIN

e.c

Data 08H 02H

Address 6202 6203

o.
OUTPUT Data

nr

04H (Quotient) 00H (Remainder)

Thus the assembly language program to divide the two 8-bit numbers was written and executed successfully.
12

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

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 2. Move the count to B-register. 3. Increment the pointer. 5. Decrement the count. 4. Get the first data in accumulator. 6. Increment the pointer. 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. pair.

7. Compare the content of memory addressed by HL pair with that of

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

13

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6104 6105 6106 6107 6108 6109 610C 611D 610E 6111 6114 OBSERVATION
INPUT Address 6200 6201 6202 6203 6204 6205

LABEL

MNEMONICS LXI H,6200 MOV B,M INX H MOV A,M DCR B

OP CODE 21 00 62 46 23 7E 05 23 BE D2 OD 61 7E 05 C2 07 61 32 00 63 76

LOOP

INX H CMP M MOV A,M JNC AHEAD

ht

tp

://

cs

STA 6300 HLT

et

JNZ LOOP

ub

AHEAD

DCR B

e.c
OUTPUT

Data 05H 0AH 03H 08H 06H 0CH

Address

o.

nr

Data

6300

0CH

http://csetube.co.nr/

14

CS2259 Microprocessors Laboratory

RESULT Thus the assembly language program to search the largest data in an array was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

15

CS2259 Microprocessors Laboratory

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 2. Move the count to B-register. 3. Increment the pointer. 5. Decrement the count. 4. Get the first data in accumulator. 6. Increment the pointer. 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. pair.

7. Compare the content of memory addressed by HL pair with that of

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

16

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6104 6105 6106 6107 6108 6109 610C 611D 610E 6111 6114 OBSERVATION INPUT Address 6200 6201 6202 6203 6204 6205

LABEL

MNEMONICS LXI H,6200 MOV B,M INX H MOV A,M DCR B

OP CODE 21 00 62 46 23 7E 05 23 BE DA OD 61 7E 05 C2 07 41 32 00 63 76

LOOP

INX H CMP M MOV A,M JC AHEAD

://

ht

tp

cs

et
Data 05H 0AH 03H 08H 06H 0CH

JNZ LOOP STA 6300 HLT

ub

AHEAD

DCR B

e.c
OUTPUT

Address

o.
Data 03H

6300

nr

http://csetube.co.nr/

17

CS2259 Microprocessors Laboratory

RESULT Thus the assembly language program to search the smallest data in an array was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

18

CS2259 Microprocessors Laboratory

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 Bregister. 2. Decrement B-register (B is a count for (N-1) repetitions). 4. Set C-register as counter for (N-1) comparisons. pointer. 3. Set HL pair as data address pointer.

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.

ht

tp

7. Compare the data pointed by HL with accumulator.

://

6. Increment the HL pair (data address pointer).

cs

et

ub

e.c

5. Load a data of the array in accumulator using the data address

o.

nr

http://csetube.co.nr/

19

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6103 6104 6105 6108 6109 610A 610B 610C 611D 610E 6111 6112 6113 6114 6115 6116 6117 611A 611B 611E

LABEL

MNEMONICS LDA,6200 MOV B,A DCR B

OP CODE 3A 00 62 47 05 21 00 62 4E 0D 23 7E 23 BE DA 16 61 56 77 2B 72 23 0D C2 0B 61 05 C2 05 61 76

LOOP2

LXI H,6200 MOV C,M DCR C INX H INX H

ht

tp

AHEAD

://

cs

MOV D,M MOV M,A DCX H MOV M,D INX H DCR C JNZ LOOP1 DCR B JNZ LOOP2 HLT

et

JC AHEAD

ub

CMP M

e.c

o.

nr

LOOP1

MOV A,M

http://csetube.co.nr/

20

CS2259 Microprocessors Laboratory

OBSERVATION INPUT (Before sorting) Address 6200 6201 6202 6203 6204 Data 04H 0AH 0CH 06H 03H OUTPUT (After sorting) Address 6200 6201 6202 6203 6204 Data 04H 03H 06H 0AH 0CH

RESULT Thus the assembly language program to sort an array of data in ascending order was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

21

CS2259 Microprocessors Laboratory

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 Bregister. 2. Decrement B-register (B is a count for (N-1) repetitions). 4. Set C-register as counter for (N-1) comparisons. pointer. 3. Set HL pair as data address pointer.

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.

ht

tp

7. Compare the data pointed by HL with accumulator.

://

6. Increment the HL pair (data address pointer).

cs

et

ub

e.c

5. Load a data of the array in accumulator using the data address

o.

nr

http://csetube.co.nr/

22

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 6100 6103 6104 6105 6108 6109 610A 610B 610C 611D 610E 6111 6112 6113 6114 6115 6116 6117 611A 611B 611E AHEAD LOOP1 LOOP2 LABEL MNEMONICS LDA,6200 MOV B,A DCR B LXI H,6200 MOV C,M DCR C MOV A,M CMP M INX H INX H OP CODE 3A 00 62 47 05 21 00 62 4E 0D 23 7E 23 BE D2 16 61 56 77 2B 72 23 0D C2 0B 61 05 C2 05 61 76

ht

tp

://

cs

JNC AHEAD MOV D,M MOV M,A DCX H MOV M,D INX H DCR C JNZ LOOP1 DCR B JNZ LOOP2 HLT

et

ub

e.c

o.

nr

http://csetube.co.nr/

23

CS2259 Microprocessors Laboratory

OBSERVATION INPUT (Before sorting) Address 6200 6201 6202 6203 6204 Data 04H 0AH 0CH 06H 03H OUTPUT (After sorting) Address 6200 6201 6202 6203 6204 Data 04H 0CH 0AH 06H 03H

RESULT Thus the assembly language program to sort an array of data in descending order was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

24

CS2259 Microprocessors Laboratory

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. 3. Set BC pair as pointer for binary (Hexa) array. 5. Call subroutine BIN to find the binary (Hexa) value. memory. 2. Set D-register as counter for number of data in the array.

7. Increment BC pair. step.

8. Decrement D-register. If ZF = 0, then go to step 4. if ZF = 1, then 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.

ht

tp

://

6. The binary (Hexa) value available in A-register is stored in

cs

et

ub

e.c

4. Increment HL pair and move a data of ASCII array to A-register.

o.

nr

http://csetube.co.nr/

25

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 6100 6103 6104 6107 6108 6109 610C 611D 610E 610F 6112 6113 6115 6117 6118 611A BIN LABEL MNEMONICS LXI H,6200 MOV D,M LXI B,6300 INX H MOV A,M CALL BIN INX B STAX B DCR D OP CODE 21 00 62 56 01 00 63 23 7E CD 13 61 02 03 15 C2 07 61 76 D6 07 FE 0A D8 D6 07 C9

ht

tp

://

cs

HLT SUI 30 CPI 0A RC SUI 07 RET

et

JNZ LOOP

ub

e.c

o.

nr

http://csetube.co.nr/

26

CS2259 Microprocessors Laboratory

OBSERVATION INPUT Address 6200 6201 Data 01 0A Address 6202 6203 OUTPUT Data 30H 41H

RESULT Thus the assembly language program to covert the ASCII code to HEX code was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

27

CS2259 Microprocessors Laboratory

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. 3. Call subroutine code to find the ASCII value of the lower nibble 4. Move B register to A register Mask the 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. 2. Mask the upper nibble of HEX data.

ht

tp

://

5. Rotate the upper nibble to lower nibble

cs

et

ub

e.c

and store in memory.

o.

nr

http://csetube.co.nr/

28

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 6100 6103 6104 6106 6109 610C 610D 610F 6110 6111 6112 6113 6116 6119 611A 611C 611F 6121 6123 CODE LABEL MNEMONICS LDA 4200 MOV B,A ANI 0F CALL CODE STA 4201 MOV A,B RLC RLC ANI F0 RLC OP CODE 3A 00 62 47 E6 0F CD 1A 61 32 01 62 78 E6 F0 07 07 07 07 CD 1A 41 32 02 62 76 FE 0A DA 21 62 C6 07 C6 30 C9

ht

tp

://

cs

RLC CALL CODE STA 4202 HLT CPI 0AH JC SKIP ADI 07H ADI 30H RET

et

ub

e.c

o.

nr

http://csetube.co.nr/

29

CS2259 Microprocessors Laboratory

OBSERVATION INPUT Address 6200 Data 30H Address 6201 6202 OUTPUT Data 01H 00H

RESULT Thus the assembly language program to covert the HEX code to ASCII code was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

30

CS2259 Microprocessors Laboratory

AIM

CONVERT THE HEX CODE TO BCD CODE USING 8085 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. go to next step. 4. Subtract 64H from A register. 6. Go to step 3 go to next step 5. Increment E register 3. Compare A-register with 64H. If carry=1 then go to step 7 else

8. Subtract 0AH from A register. 9. Increment D register and Go to step 7 10.Save the units, tens and hundreds. 11.Stop

ht

tp

7. Compare A register with 0AH. If carry=1 then go to step 10 else

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

31

CS2259 Microprocessors Laboratory

PROGRAM
MEMORY ADDRESS 6100 6102 6103 6106 6108 610B 610D 610E 6111 6113 6116 6118 6119 611C 611D 611E 611F 6120 6121 6122 6123 6126 6127 612A UNIT TEN HUNDRED LABEL MNEMONICS MVI E,00H MOV D,E LDA 6200 CPI 64H JC TEN SUI 64H INR E JMP HUNDRED JC UNIT INR D OP CODE IE 00 53 3A 00 62 FE 64 DA 11 61 D6 64 1C C3 06 61 FE 0A DA 1C 61 D6 0A 14 C3 11 61 4F 7A 07 07 07 07 81 32 01 62 7B 32 02 62 76

ht

tp

://

cs

JMP TEN MOV C,A MOV A,D RLC RLC RLC RLC ADD C STA 6201 MOV A,E STA 6202 HLT

et

ub

SUI 0AH

e.c

o.

nr

CPI 0AH

http://csetube.co.nr/

32

CS2259 Microprocessors Laboratory

OBSERVATION INPUT Address 4200 Data 55H Address 4201 4202 OUTPUT Data 55H (Tens and Units) 00H (hundreds)

RESULT Thus the assembly language program to covert the HEX code to BCD code was written and executed successfully.
33

http://csetube.co.nr/

ht

tp

://

cs

et

ub

e.c

o.

nr

CS2259 Microprocessors Laboratory

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. 3. Rotate the upper nibble to lower nibble and save in B register. 5. Move 0Ah to C register. 2. Mask the lower nibble of BCD data

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

ht

tp

7. Decrement the C-register. If C=0 then go to next step else go to

://

6. Add B register to A register.

cs

et

ub

e.c

4. Clear the accumulator.

o.

nr

http://csetube.co.nr/

34

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 6100 6103 6104 6106 6107 6108 6109 610A 610B 610C 610E 610F 6110 6113 6114 6115 6117 6118 611B LABEL MNEMONICS LDA 6200 MOV E,A ANI 0FH RLC RLC RLC MOV B,A RLC XRA A OP CODE 3A 00 62 5F E6 F0 07 07 07 07 47 AF 0E 0A 80 0D C2 0E 61 47 7B E6 F0 80 32 01 62 76

ht

tp

://

cs

ADD B DCR C JNZ REP MOV B,A MOV A,E ANI 0FH ADD B STA 6201 HLT

et

MVI C,0AH

ub

e.c

o.

nr

http://csetube.co.nr/

35

CS2259 Microprocessors Laboratory

OBSERVATION INPUT Address 6200 Data 10 Address 6201 OUTPUT Data 0AH

RESULT Thus the assembly language program to covert the HEX code to ASCII code was written and executed successfully.
http://csetube.co.nr/
36

ht

tp

://

cs

et

ub

e.c

o.

nr

CS2259 Microprocessors Laboratory

AIM 8085.

ADC INTERFACING USING 8085 To write an assembly language program to interface ADC board with

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. 5. Find the display value for the input. 7. Go to step 1.

ht

tp

8. Stop.

://

cs

et

ub

6. Move this value to the display board.

e.c

o.

nr

4. If the signal is valid go to next step else go to step 3.

http://csetube.co.nr/

37

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 4100 4102 4104 4106 4108 4109 410A 410B 410D 410F 4110 4111 4114 4116 4117 4118 4119 411B 411D 411F 4121 4124 LOOP 4112 LABEL START MNEMONICS MVI A,00H OUT CNT ORI 08 OUT CNT NOP NOP NOP ANI F7 NOP NOP OUT CNT NOP OP CODE 3E 00 D3 C8 F6 08 D3 C8 00 00 00 E6 F7

/ nr

o.

D3 C8 00 00 00 3E 10 D3 C8 00 00 00 3E 20 D3 C8 DB C0 E6 01 C2 1D 41 DB C4

ht

tp

://

cs

MVI A,10H OUT CNT NOP NOP NOP MVI A,20H OUT CNT IN EOC ANI 01 JNZ LOOP IN DATA

et

ub

e.c

http://csetube.co.nr/

38

CS2259 Microprocessors Laboratory

4126 4127

MOV B,A LXI H,8200 MVI A,94 OUT CNT MOV A,B ANI 0F RRC RRC RRC RRC MOV A,M MOV L,A

47 21 00 42 3E 94 D3 01 78 E6 0F 07 07 07 07

412A 412C 412E 412F 4131 4132 4133 4134 4135 4136 4137 4139 413A 413C 413D 413E 4140 4143 4200

/ nr

o.

6F 7E D3 00 78 E6 0F 6F 7E D3 00 C3 10 41 76 0C 9F 4A 0B 99 29 28 8F 08 89 88 38 6C 1A 68 E8

ht

tp

://

MOV A,B ANI 0F MOV L,A MOV A,M OUT DAT JMP START HLT

cs

et

OUT DATA

ub

e.c

http://csetube.co.nr/

39

CS2259 Microprocessors Laboratory

OBSERVATION

S.No

ANALOG INPUT

DIGITAL OUTPUT

RESULT Thus the assembly language program to interface ADC board with 8085 was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

40

CS2259 Microprocessors Laboratory

AIM

SQUARE WAVE GENERATION WITH 8085 USING DAC 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. 5. Get the data to accumulator for 0 volts 4. Call the delay routine for required time interval. 6. Move this data to DAC kit. 8. Go to the first step. 9. Stop.

ht

tp

://

cs

et

7. Call the delay routine for required time interval.

ub

e.c

o.

nr

http://csetube.co.nr/

41

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 4100 4102 4104 4107 4109 410B 410E 4111 4120 4121 4123 4126 4127 4128 4129 412C 412D 4130 4131 LOOP3 LOOP2 DELAY LABEL START MNEMONICS MVI A,FFH OUT C0 CALL DELAY MVI A, 00H OUT C0 CALL DELAY HLT JMP START PUSH B OP CODE 3E FF D3 C0 CD 3E 00 D3 C0 CD 20 41 C3 00 41 76 C5 0E 05 11 FF FF 1B 7A B3 C2 26 41 0D C2 23 41 C1 C9

ht

tp

://

cs

LXI D,FFFFH DCX D MOV A,D ORA E JNZ LOOP2 DCR C JNZ LOOP3 POP B RET

et

MVI C,05

ub

e.c

o.

nr

http://csetube.co.nr/

42

CS2259 Microprocessors Laboratory

OBSERVATION S.No 1 TIME PERIOD (msec) 1.6 * 2 = 3.2mse AMPLITUDE (volts) 2.5 * 2 = 5 V

RESULT Thus the assembly language program to generate square wave was written and executed successfully.
http://csetube.co.nr/
43

ht

tp

://

cs

et

ub

e.c

o.

nr

CS2259 Microprocessors Laboratory

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. 5. Get the data to accumulator for 5 volts 7. Decrement the accumulator. 9. Go to the step 1. 10.Stop.

ht

tp

8. If ACC=00then go to step 9 else step 6

://

cs

et

ub

6. Move this data to DAC kit.

e.c

o.

nr

4. If ACC=00then go to step 5 else step 2

http://csetube.co.nr/

44

CS2259 Microprocessors Laboratory

PROGRAM MEMORY ADDRESS 4100 4101 4103 4104 4107 4109 410B 410C 410F OBSERVATION S.No 1 LOOP1 LABEL START LOOP MNEMONICS XRA A OUT C0 INR A JNZ LOOP MVI A,FFH OUT C0 JNZ LOOP1 DCR A OP CODE AF D3 C0 3C C2 01 41 3E FF D3 C0 3D C2 09 41 C3 00 41

1.2* 2 = 2.4mse

ht

TIME PERIOD (msec)

://

cs

et
AMPLITUDE (volts) 2.4 * 2 = 4.8 V RESULT Thus the assembly language program to generate triangular wave was written and executed successfully.

tp

ub

JMP START

e.c

o.

nr

http://csetube.co.nr/

45

CS2259 Microprocessors Laboratory

SAWTOOTH WAVE GENERATION USING DAC USING 8085 AIM 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. 5. Stop. PROGRAM MEMORY ADDRESS 8100 8101 8103 8104 8107 OBSERVATION S.No 1 RESULT Thus the assembly language program to generate saw tooth wave was written and executed successfully TIME PERIOD (msec) 1.4 * 2 = 2.8mse AMPLITUDE (volts) 2.4 * 2 = 4.8 V LABEL 4. Go to the step 2

et

LOOP

ht

START

tp

://

cs

MNEMONICS

ub

e.c

o.
OP CODE AF D3 C0 3C C2 01 81 76 XRA A OUT C0 INR A JMP LOOP HLT

nr

http://csetube.co.nr/

46

CS2259 Microprocessors Laboratory

AIM

TRAFFIC LIGHT CONTROLLER USING 8085

To write an assembly language program to interface traffic light

controller with 8085 using 8255. APPARATUS REQUIRED 8085 Microprocessor kit, Power chord, Traffic light interface board ALGORITHM 1. Find the control word for 8255 and data corresponding to the given conditions 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. 5. Move the next data to accumulator and place in port-B. 7. Call the delay routine. step 3. PROGRAM MEMORY ADDRESS 4100 4103 4104 4106 4108
4109 410A

9. Go to step 1 and Stop

LABEL START

ht

tp

8. Decrement the C-register. If C=0 then go to next step else go to

://

cs

MNEMONICS LXI H,4500H MOV A,M OUT CONT MIV C, 04H

et

ub

6. Move the next data to accumulator and place in port-C.

e.c

o.

nr

4. Move the first data to accumulator and place in port-A.

OP CODE 21, 00, 45 7E D3, 0F 0E, 04 23


7E D3, 0C

LOOP

INX H
MOV A, M OUT PORTA

http://csetube.co.nr/

47

CS2259 Microprocessors Laboratory 410C INX H 410D 410E 4110 4111 4112 4114 4117 4118 411B 411E 4200 4202 4205 4206 4207 4208 420B 420C 420F 4500 4504 4507 DELAY LOOP2 LOOP1 MOV A, M OUT PORTB INX H MOV A, M OUT PORTC CALL DELAY DCR C JNZ LOOP JMP START HLT DELAY PROGRAM LXI D, FFFFH MOV A, D MVI C, 05H DCX D ORA E

23 7E D3, 0D 23 7E D3, 0E CD, 00, 42 0D C2, 08, 41 C3, 00, 41 76 0E, 05 11, FF, FF 1B 7A B3 C2, 05, 42 0D C2, 02, 42 C9 80, 84, 2E, 4C 84, 9D, 90, 93 2B, 10, 64, 27, 12

ht

tp

PORT A [ {D0 - D20}0 - OFF & 1 ON ] D8 D7 D6 D5 D4 D3 D2 D1

://

JNZ LOOP1 DCR C JNZ LOOP2 RET INPUT DATA

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

48

CS2259 Microprocessors Laboratory 0 0 POSITION 1 1 POSITION 2 POSITION 3 POSITION 4 1 1 0 0 0 1 0 0 1

0 0 1 0

0 0 0 0

1 1 0 1

0 0 1 0

0 0 1 0

84H 84H 93H 64H

PORT B [ {DL1 - DL8}0 - GREEN & 1 RED ] D20 D19 D18 D17 DL78 DL56 DL34 DL12
POSITION 1 POSITION 2 POSITION 3 POSITION 4 0 1 0 0 0 0 0 0 1 0 1 1 0 1 0 0

1 1

1 1

1 0 1 1

0 1 1 1

2EH 9DH 2BH 27H

e.c
D16 D15

ht

PORT C [ {D0 - D20}0 - OFF & 1 ON ]

tp

D14
0 0 0 0

://

cs

et
D13
0 1 1 1

ub

o.

D12
1 0 0 0

nr
0 1 D11
1 0 0 0

/
D10
0 0 0 1

D9
0 0 0 0

POSITION 1 POSITION 2 POSITION 3 POSITION 4

0 1 0 0

1 0 0 0

4CH 90H 10H 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/

49

CS2259 Microprocessors Laboratory

AIM

TIMER INTERFACE WITH 8085 USING 8251 To write an assembly language program to timer interface with 8085

using 8251. APPARATUS REQUIRED ALGORITHM


8085 Microprocessor kit, Power chord, keyboard/display interface board. 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. 7. Move this value to the display board 8. Stop. 6. Find the display value for the pressed key.

4100 4103 4105 4107 4109 410B 410D 410F 4111 4112 4114

ht

ADDRESS

tp

LABEL

://

MEMORY

cs

PROGRAM

et
MNEMONICS

ub

e.c

o.
OP CODE 21 50 41 16 08 3E 10 D3 C2 3E,CC D3 C2 3E,90 D3 C2 7E D3 C0 23
50

LXI H,CLEAR MVI B,08 MVI A,10H OUT CNT MVI A,CC OUT CNT MVI A,90H OUT CNT MOV A,M

BACK

OUT DAT INX H

http://csetube.co.nr/

nr

CS2259 Microprocessors Laboratory

4115 4112 4114 4117 4118 4119

DCR B JNZ BACK IN CNT ANI 07H JZ LOOP MVI A,40H OUT CNT IN DAT ANI 0FH MOV L,A MOV A,M MVI H,82H OUT DAT

05 C2 12 41 DB C2 E6 07 CA 19 41 3E 40 D3 C2 DB C0 E6 0F 6F 26 82 7E D3 C0 C3 19 41 FF FF FF FF FF FF FF FF 0C 9F 4A 0B 99 29 28 8F 08 89 88 38 6C 1A 68 E8

LOOP

411C 411F 4120 4121 4123 4126 4127 4128 4129 4150 8200

RESULT Thus the assembly language program to timer interface with 8085 using 8251 was written and executed successfully.

ht

tp

://

cs

HLT

et

JMP LOOP

ub

e.c

o.

nr

http://csetube.co.nr/

51

CS2259 Microprocessors Laboratory

KEYBOARD/DISPLAY INTERFACE WITH 8085 USING 8279 AIM To write an assembly language program to interface keyboard/display board with 8085 using 8279. APPARATUS REQUIRED
8085 Microprocessor kit, Power chord, keyboard/display 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 5. If any key pressed go to next step else go to step 4. 7. Move this value to the display board and Stop. 4. Scan the key board continuously.

ADDRESS 4100 4103 4105 4107 4109 410B 410D 410F 4111 4112

ht

LABEL

tp

MEMORY

://

PROGRAM

cs

et

MNEMONICS LXI H,CLEAR MVI B,08 MVI A,10H OUT CNT MVI A,CC OUT CNT MVI A,90H OUT CNT MOV A,M

ub

6. Find the display value for the pressed key.

e.c

o.

nr
OP CODE 21 50 41 16 08 3E 10 D3 C2 3E,CC D3 C2 3E,90 D3 C2 7E D3 C0

BACK

OUT DAT

http://csetube.co.nr/

52

CS2259 Microprocessors Laboratory

4114 4115 4112 4114 4117 4118 4119

INX H DCR B JNZ BACK

23 05 C2 12 41 DB C2 E6 07 CA 19 41 3E 40 D3 C2 DB C0 E6 0F 6F 26 82 7E D3 C0 C3 19 41 FF FF FF FF FF FF FF FF 0C 9F 4A 0B 99 29 28 8F 08 89 88 38 6C 1A 68 E8

LOOP

IN CNT ANI 07H JZ LOOP MVI A,40H OUT CNT IN DAT ANI 0FH MVI H,82H OUT DAT MOV L,A MOV A,M

411C 411F 4120 4121 4123 4126 4127 4128 4129 4150 4200

tp

RESULT Thus the assembly language program to interface keyboard/display board with 8085 using 8279 was written and executed successfully.

ht

://

cs

JMP LOOP HLT

et

ub

e.c

o.

nr

http://csetube.co.nr/

53

CS2259 Microprocessors Laboratory

TIMER INTERFACE WITH 8085 USING 8254 AIM To write an assembly language program to timer interface with 8085 using 8254. 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. 7. Move this value to the display board and Stop.

MEMORY ADDRESS 4100 4103 4105 4107 4109 410B 410D 410F 4111

LABEL

ht

tp

PROGRAM

://

cs

et

6. Find the display value for the pressed key.

MNEMONICS LXI H,CLEAR MVI B,08 MVI A,10H OUT CNT MVI A,CC OUT CNT MVI A,90H OUT CNT MOV A,M

ub

e.c

o.
OP CODE 21 50 41 16 08 3E 10 D3 C2 3E,CC D3 C2 3E,90 D3 C2 7E

nr

http://csetube.co.nr/

54

CS2259 Microprocessors Laboratory

4112 4114 4115 4112 4114 4117 4118 4119

BACK

OUT DAT INX H DCR B JNZ BACK

D3 C0 23 05 C2 12 41 DB C2 E6 07 CA 19 41 3E 40 D3 C2 DB C0 E6 0F 6F 26 82 7E D3 C0 C3 19 41 FF FF FF FF FF FF FF FF 0C 9F 4A 0B 99 29 28 8F 08 89 88 38 6C 1A 68 E8

LOOP

IN CNT ANI 07H JZ LOOP MVI A,40H OUT CNT IN DAT MOV L,A ANI 0FH MVI H,82H

411C 411F 4120 4121 4123 4126 4127 4128 4129 4150 8200

tp

ht

RESULT Thus the assembly language program to timer interface with 8085 using 8254 was written and executed successfully.
55

http://csetube.co.nr/

://

cs

OUT DAT JMP LOOP HLT

et

MOV A,M

ub

e.c

o.

nr

CS2259 Microprocessors Laboratory

ADDITION OF TWO 16-BIT NUMBERS USING 8085 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. PROGRAM MEMORY ADDRESS 1000 1005 1008 1000 1005 1008 1000 1005 1008 1009 LOOP

ht

tp

START

LHLD 2000H XCHG LHLD 2002H MVI A, 00H DAD D JNC LOOP INR A SHLD 3000H STA 3002H HLT

://

cs

et

LABEL

MNEMONICS

ub

e.c

o.
OP CODE

nr

4. Store the sum & carry in separate memory locations.

http://csetube.co.nr/

56

CS2259 Microprocessors Laboratory

OBSERVATION INPUT Address 2000 2001 2002 2004 Data 04H 04H 02H 02H Address 3000 3001 3002 06H 06H 00 OUTPUT Data (Sum) (Sum) (Carry)

RESULT Thus the assembly language program to add the two 16-bit numbers using 8085 simulator tool was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

57

CS2259 Microprocessors Laboratory

AIM

SUBTRACTION OF TWO 16-BIT NUMBERS USING 8085 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. 5. Store the difference and borrow in different memory locations. PROGRAM MEMORY ADDRESS 1000 1008 1000 1005 1008 1000 1005 1008 1009 1000 1008 4. Subtract subtrahend from minuend.

START

ht

tp

LABEL

://

cs

et
MNEMONICS

ub

e.c

o.

nr

/
OP CODE

MVI C, 00 LHLD 2000H XCHG LHLD 2002H MOV A, L SUB E MOV L, A MOV A, H SBB D MOV H, A SHLD 3000H
58

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

1000 1005 1008 1005 1008

JNC LOOP INR C MOV A, C STA 3000H HLT

LOOP

OBSERVATION INPUT Address 2000 2001 2002 2004 Data 04H 04H 02H 02H Address 3000 3001 3002 02H 02H OUTPUT Data (Difference) (Difference) (Borrow)

RESULT Thus the assembly language program to subtract the two 16-bit numbers using 8085 simulator tool was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

00H

http://csetube.co.nr/

59

CS2259 Microprocessors Laboratory

MULTIPLICATION OF TWO 16-BIT NUMBERS USING 8085 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. PROGRAM MEMORY ADDRESS 1000 1008 1000 1005 1008 1000 1005 1008 1009

ht

START

tp

://

LHLD 2000H SPHL LHLD 20002 XCHG LXI H, 0000H LXI B, 0000H DAD SP JNC NEXT INX B

cs

et

LABEL

MNEMONICS

ub

e.c

o.
OP CODE

nr

4. Store the result in consecutive memory locations.

http://csetube.co.nr/

60

CS2259 Microprocessors Laboratory

1000 1008 1000 1005 1008 1005 1008 1008 1005 1008 OBSERVATION

NEXT

DCX D MOV A,E ORA D JNZ LOOP SHLD 3000H MOV A, C STA 3001H MOV A, B

Address 2000 2001 2002 2004

Data 04H 04H 02H 02H

ht

INPUT

://

cs

et
OUTPUT Data 08H 08H 00H (Multiply) (Multiply) (Carry) 3000 3001 3002

tp

Address

RESULT Thus the assembly language program to multiply the two 16-bit numbers using 8085 simulator tool was written and executed successfully.

ub

HLT

e.c

o.

STA3002H

nr

http://csetube.co.nr/

61

CS2259 Microprocessors Laboratory

DIVISION OF TWO 16-BIT NUMBERS USING 8085

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 4. Count the number of subtraction which equals the quotient. PROGRAM MEMORY ADDRESS 1000 1008 1000 1005 1008 1000 1005 1008 1009 1000 1008 LOOP less than divisor. 5. Store the result in memory.

START

ht

tp

LABEL

cs

et
MNEMONICS

ub

e.c

o.

nr

/
OP CODE

://

LHLD 3000H XCHG LHLD 3002H LXI B, 0000H MOV A, L SUB E MOV L, A MOV A, H SBB D MOV H, A INX B

http://csetube.co.nr/

62

CS2259 Microprocessors Laboratory

1000 1005 1008 1005 1008 1008 1005 1008 1009

JNC LOOP DCX B DAD D SHLD 3000H MOV A, C STA 3001H MOV A, B STA 3002H HLT

2004

02H

RESULT Thus the assembly language program to divide the two 16-bit numbers using 8085 simulator tool was written and executed successfully.

ht

2002

02H

tp

://

2001

04H

cs

et

2000

04H

3000 3001 3002

ub

Address

Data

Address

e.c

o.

INPUT

nr

OBSERVATION

OUTPUT Data 02H (Quotient) 02H (Quotient) 00H (Remainder)

http://csetube.co.nr/

63

CS2259 Microprocessors Laboratory

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

64

CS2259 Microprocessors Laboratory

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


A-ADDITION OF TWO 16-BIT NUMBERS ADDRESS 1000 1003 MNEMONICS MOV AX,[1100] ADD AX,[1102] OP-CODE A1,00,11 03,06,02,11 COMMANDS

MOVE THE DATA TO ACCUMULATOR ADD MEMORY CONTENT WITH ACCUMULATOR MOVE ACCUMULATOR CONTENT TO MEMORY STOP

OUT PUT: IN PUT ADDRESS 1100 1101 1102 1103 DATA 02 02 02 02 OUT PUT ADDRESS 1200 1201 DATA 04 04

ht

tp

://

cs

et

100A

ub

e.c
HLT F4

o.

nr

1007

MOV [1200],AX

A3,00,12

http://csetube.co.nr/

65

CS2259 Microprocessors Laboratory

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


B-SUBTRACTION OF TWO 16-BIT NUMBERS

ADDRESS
1000

MOV AX[1100]

MNEMONICS

A1,00,11

OP-CODE

MOVE THE DATA TO ACCUMULATOR SUBTRACT MEMORY CONTENT WITH ACCUMULATOR MOVE ACCUMULATOR CONTENT TO MEMORY

COMMANDS

1003

SUB AX[1102]

2B,06,02,11

1007

MOV [1200],AX

A3,00,12

100A

HLT

e.c

o.
F4
STOP

IN PUT ADDRESS 1100 1101 1102 1103

DATA 04 02 04 02

ht

OUT PUT:

tp

://

cs

et
OUT PUT ADDRESS 1200 1201 DATA 02 02

ub

nr

http://csetube.co.nr/

66

CS2259 Microprocessors Laboratory

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


C-MULTIPLICATION OF TWO 16-BIT NUMBERS ADDRESS 1000 MNEMONICS MOV AX[1100] OP-CODE A1,00,11
MOVE THE DATA TO ACCUMULATOR MULTIPLY MEMORY CONTENT WITH ACCUMULATOR MOVE ACCUMULATOR CONTENT TO AX REGISTER

COMMANDS

1003

MUL[1102]

F7,26,02,11

1007

MOV [1200],DX

87,16,00,12

100B

MOV[1202],AX

e.c

o.
A3,02,12 OUT PUT: IN PUT ADDRESS 1100 1101 1102 1103 DATA 02 02 02 02

nr ht tp ://
100E HLT

/ cs et ub
F4 OUT PUT ADDRESS 1200 1201 1202 1203 DATA 00 04 08 04

MOVE ACCUMULATOR CONTENT TO DX REGISTER STOP

http://csetube.co.nr/

67

CS2259 Microprocessors Laboratory

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS (USING 8086)


D-DIVISION OF TWO 16-BIT NUMBERS ADDRESS 1000 MNEMONICS MOV AX[1100] OP-CODE A1,00,11 COMMANDS MOVE THE DATA TO ACCUMULATOR DIVIDE MEMORY CONTENT WITH ACCUMULATOR MOVE ACCUMULATOR CONTENT TO DX REGISTER

1003

DIV[1102]

F7,36,02,11

100E OUT PUT: IN PUT ADDRESS 1100 1101 1102 1103 DATA 04 04 02 02

HLT

ht

tp

://

MOV[1200],AX

cs

100B

et
A3,00,12

ub

e.c

o.
F4 OUT PUT ADDRESS 1200 1201 1202 1203 DATA 02 02 00 00

nr

1007

MOV [1200],DX

87,16,00,12

MOVE CONTENT OF AX REGISTER TO MEMORY STOP

http://csetube.co.nr/

68

CS2259 Microprocessors Laboratory

INTERFACING ADC AND DAC (I) PROGRAM FOR ANALOG-DIGITAL CONVERTER


MEMORY ADDRESS 1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1014 1016 1018 101A 101C 101E 1021 1023 LOOP MNEMONICS MOV AL,03 OUT C8,AL MOV AL,23 OUT C8,AL MOV AL,03 OUT C8,AL MOV AL,01 OUT DO, AL OPCODE B0, 03 E6, C8 B0, 23 E6, C8 B0, 03 E6,C8 COMMENTS Move to accumulator move the value to register move the value to B0 move the value to main memory Move the value from main memory to accumulator move the value to main memory move to register move to memory Move to accumulator Move from accumulator. to register increment the value move to register Compare the value of accumulator. an memory jump no zero increment loop condition move to memory move to register stop

OUT D0,AL IN AL E0 AND AL,01 CMP AL,01 JNZ LOOP IN AL,C0 MOV BX,1100 MOV[BX],AL HLT

ht

tp

MOV AL,00

://

cs

et

ub
F4

B0, 01

E6, D0 B0, 00 E6, D0 E4 ,E0 24, 01 3C ,01 75, F8 E4, C0 BB,00,11 88, 07

e.c

o.

nr

http://csetube.co.nr/

69

CS2259 Microprocessors Laboratory IN PUT ANALOG VOLTAGE 5V

IN PUT: OUT PUT DIGITAL DATA FF [1100]

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

70

CS2259 Microprocessors Laboratory

INTERFACING ADC AND DAC PROGRAM FOR DIGITAL- ANALOG CONVERTER GENERATION OF SAWTOOTH WAVE
MEMORY ADDRESS 1000 1002 1004 1006 1008 100A LABEL START L1 MNEMONICS MOV AL, 00 OUT C0,AL INC AL JNZ L1 JMP START OPCODE B0,00 E6 ,C0 FE ,C0 75, FA COMMENTS move to AL reg move to CO increment AL register jump no carry jump to start Return

ht

tp

://

cs

et

ub

RET

e.c

o.

nr
C3

EB ,F6

http://csetube.co.nr/

71

CS2259 Microprocessors Laboratory

INTERFACING ADC AND DAC PROGRAM FOR DIGITAL- ANALOG CONVERTER B- GENERATION OF SQUARE WAVE
MEMORY ADDRESS 1000 1002 1004 1007 1009 100B 100E 1010 DELAY LABEL START MNEMONICS MOV AL,00 OUT C8,AL CALL DELAY MOV AL,FF OUT C8, AL CALL DELAY OPCODE B0,00 E6 ,C8 E8 ,09 ,00 B0, FF COMMENTS move to AL reg. move to C8 call the delay move to FF reg. move to C8 call the delay jump to start declare the data to accumulator move to loop return

1013 1015

L1

ht

tp

MOV CX, 05, FF LOOP L1 RET

cs

et

JMP START

ub

e.c

://

o.

nr
C3

E6 ,C8 E8 ,02 ,00 EB,F0 B9, FF, 05

E2 ,FE

http://csetube.co.nr/

72

CS2259 Microprocessors Laboratory

INTERFACING ADC AND DAC PROGRAM FOR DIGITAL- ANALOG CONVERTER C- GENERATION OF TRIANGULAR WAVE MEMORY ADDRESS
1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1014 1016 L2

LABEL

MNEMONICS

OPCODE
B3,00 88,D8 E6,C8

COMMENTS
Move to accumulator move to BL reg move to C8 increment value of BL reg. jump no zero move to FF reg. Move to accumulator. move to C8 decrement value of BL reg. jump no carry jump start return

START L1

MOV BL,00 MOV AL,BL OUT C8,AL INC BL JNZ L1

o.

nr

FE,C3 75,F8 B3,FF 88,D8 E6,C8

ht

tp

://

cs

MOV AL,BL OUT C8,AL DEC BL JNC L2 JMP START RET

et

ub

MOV BL,FF

e.c

FE,CB 75,F8 EB,EA C3

http://csetube.co.nr/

73

CS2259 Microprocessors Laboratory

PARALLEL COMMUNICATION BETWEEN TWO MP KITS USING 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

ht

tp

://

cs

et

ub

e.c

Control Word:

o.

nr

I/O MODES:

http://csetube.co.nr/

74

CS2259 Microprocessors Laboratory TRANSMITTER PROGRAM: ADDRESS 1000 1002 1004 1006 1008 LABEL MNEMONICS MOV AL,80 OUT 0F,AL MOV AL,05 (DATA) OUT 0C,AL HLT OPCODES B0 80 E6 0F B0 05 E6 0C F4

RECEIVER PROGRAM: ADDRESS 1000 1002 1004 1006 1009 100B LABEL MNEMONICS MOV AL,90 OUT 0F,AL IN AL 0C MOV BX[1250] MOV BX AL HLT OPCODES B0 90 E6 0F E4 0C BB 50 12 88 07 F4

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

75

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING 8279, 8259, AND 8253 INTERFACING OF 8279 ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b)
ADDRESS 1000 1003 1006 1008 100A 100C 100E 1010 1012 1014 1016 1019 NEXT LOOP MNEMONICS START MOV SI,1200 MOV CX,000F MOV AL,10 OUT C2,AL MOV AL,CC OUT C2,AL MOV AL,90 OUT C2,AL MOV AL,[SI] OUT CO,AL OP-CODE BE 00 12 B9 0F 00 B0 10 E6 C2 B0 CC E6 C2 B0 90 E6,C2 COMMANDS SET MODE COUNT AND DISPLAY MOVE 000F DATA IN CX SET ACC DATA CLEAR DISPLAY MOVE CC DATA IN AL SET PORT DATA WRITE DISPLAY CLEAR DISPLAY IN RAM LOP FOR THE PRESSING OF KEY SET TO READ FIFO RAM CALL DISPLAY DATA GET THE CORRESPONDING CODE FORM LOOKUP TABLE GO TO NEXT JUMP START

ub

101A 101C SUB PROGARM: ADDRESS 1500 1503 1504 1506 LOOP DELAY

LOOP NEXT JMP START

ht

INC SI

tp

://

CALL DELAY

cs

et

MNEMONICS MOV DX,A0FF DEC DX JNZ LOOP1 RET

e.c
46

8A 04

E6 C0 E8 E7 04

E2 F6 EB E2

o.

nr

OP-CODE BA FF 0A 4A 75 FD C3

COMMANDS MOVE THE VALUE TO DX REGISTER DECREMENT DX JUMP NO ZERO RETURN

http://csetube.co.nr/

76

CS2259 Microprocessors Laboratory LOOK-UP TABLE ADDRESS 1200 1204 1208 120C DATA FF,FF,FF,FF FF,FF,FF,FF 68,6C,68,FF 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.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

77

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING 8279, 8259, AND 8253 INTERFACING OF 8259 IN SPECIAL MASK MODE
ADDRESS 1200 1202 1204 1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1014 1015 LOPP MNEMONICS OP-CODE MOV AL,FD BO FD OUT C2,AL INT 2 MOV C2,AL(17) OUT C2,AL MOV C2,AL(08) OUT C2,AL MOV AL,01 ORG 1000 E6 C2 CD 02 B0 17 E6 C0 COMMANDS MOVE DATA TO ACCUMULATOR SEND VALUE TO OUTPUT PORT INTERUPT MOVE DATA TO ACCUMULATOR SEND VALUE TO OUTPUT PORT MOVE DATA TO ACCUMULATOR SEND VALUE TO OUTPUT PORT MOVE DATA TO ACCUMULATOR SEND VALUE TO OUTPUT PORT MOVE DATA TO ACCUMULATOR SEND VALUE TO OUTPUT PORT MOVE DATA TO ACCUMULATOR SEND VALUE TO OUTPUT PORT SET INTERRUPT JUMP HERE

et

ub ht tp
OUT C2,AL MOV AL,FE OUT C2,AL MOV AL,68 OUT C0,AL STI JMP HERE

://

cs

e.c

o.
FB

E6 C2 B0 01 E6 C2 B0 00 E6 C2 BO 68 E6 C0

EB FE

nr

B0 08

http://csetube.co.nr/

78

CS2259 Microprocessors Laboratory

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 0020 0021 0022 0023 DATA 00 12 00 00

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

79

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING 8279, 8259, AND 8253


GENERATION OF SQUARE WAVE USING 8253 MNEMONICS ORG 100H MOV AL,36 OUT CE,AL MOV AL,10 OUT C8,AL MOV AL.00 OUT C8,AL HLT OPCODE B0 36 E6 CE B0 10 E6 C8 B0 00 E6 C8 ADDRESS 1000 1002 1004 1006 1008 100A 100C COMMAND MOVE THE VALUE TO ACCUMULATOR SEND DATA TO THE OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO THE OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO THE OUTPUT PORT HALT

ht

tp

://

cs

et

ub
F4

e.c

o.

nr

http://csetube.co.nr/

80

CS2259 Microprocessors Laboratory

SERIAL COMMUNICATION BETWEEN TWO MP KITS USING 8251


ADDRESS 1000 1002 1004 1006 1008 100A 100C 100E 1010 1012 1014 1016 1018 TRANSMITTER PROGRAM MNEMONICS OP-CODE MOV AL,36 BO 36 OUT CE,AL MOV AL,10 OUT C8,AL MOV AL,00 OUT C8,AL MOV AL,4E OUT C2,AL MOV AL,37 E6 CE B0 10 E6 C8 B0 00 E6 C8 COMMANDS MOVE THE VALUE TO ACCUMULATOR SEND DATA TO OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO OUTPUT PORT MOVE THE VALUE TO ACCUMULATOR SEND DATA TO OUTPUT PORT INTERUPT

MOV AL,AA OUT CO,AL INT 02

ht

OUT C2,AL

tp

://

cs

et

ub

E6 C2 B0 37 E6 C2 BO AA E6 CO CD 02

e.c

o.

B0 4E

nr

http://csetube.co.nr/

81

CS2259 Microprocessors Laboratory

RECEIVER PROGRAM
ADDRESS 1200 1202 1205 1207 MNEMONICS IN AL,C0 MOV BX[1250] MOV BX,AL INT 02 OP-CODE E4 C0 BB 50 12 88 07 CD 02 COMMANDS INTERUPT MOVE THE VALUE TO ADDRESS MOVE ACCUMULATOR DATA TO BX INTERUPT

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

82

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING OF STEPPER MOTOR STEPPER MOTOR INTERFACING AIM To write an assembly language program to interface stepper motor

with 8086. APPARATUS REQUIRED 8086 Microcontroller kit, Power chord, stepper motor, stepper motor interface board 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 very wisely in position control systems like printers, disk drives, process The basic two-phase stepper motor consists of two pairs of stator 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
83

http://csetube.co.nr/

ht

tp

://

poles. Each of the four poles has its own winding. The excitation of any one

cs

et

ub

control machine tools, etc.

e.c

o.

nr

manner from one equilibrium position to the next. Stepper Motors are used

CS2259 Microprocessors Laboratory

STE P 1 2 3 4

A 1 1 0 0 1

A2 0 1 1 0

B 1 0 0 1 1

B2 1 1 0 0

DATA 9h 5h 6h Ah

STE P 1 2 3 4

A 1 1 0 0 1

A 2 0 1 1 0

B 1 1 1 0 0

B2 0 0 1 1

DATA Ah 6h 5h 9h

ADDRESS DECODING LOGIC The 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 TTL pulses generated under software control using the Microcontroller Kit. voltage output pulses using a buffer 7407 with open collector.
A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED MEMORY ADDRESS 1000 1003 1005 1007 1009 100C 100D DELAY LOOP1 LABEL START

ht

tp

://

cs

et

ub

The TTL levels of pulse sequence from the data bus are translated to high

MNEMONICS MOV D1 offset table (1014) MOV CL, 04 MOV AL,[D1] OUT PORT1,AL MOV DX,1010 DEC DX JNZ DELAY

e.c

o.

nr

silicon Darlington pair transistors. The inputs for the interface circuit are

OPCODE BF,14,10 B1,04 8A,05 E6,C0 BA,10,10 4A 75,FD

http://csetube.co.nr/

84

CS2259 Microprocessors Laboratory 100F 1010 1012 1014 TABLE

INC D1 LOOP LOOP1 JMP START DB

47 E2,F3 EB,EC 09,05,06,0A

B-TO RUN STEPPER MOTOR AT FORWARD AND REVERSE DIRECTION MEMORY LABEL MNEMONICS OPCODE ADDRESS 1000 START MOV BL 20H B3,20

100C 100F 1011 1014 1017 1019 101B 101E

ht

tp

100A

cs

1008

ub

DEC BL JNZ FORWARD CALL DELAY MOV BL 20

e.c

1005

CALL ROTATE

o.

nr

1002

FORWD

MOV D1,OFFSET FORW (1037)

BF,37,10 E8,18 00 FE CB 75 F6 E8 21 00 B3 20 BF 3B 10 E8 09 00 FE CB 75 F8 E8 12 00 EB E0

REVER

://

et

MOV D1 ,OFFSET REV (103B) CALL ROTATE DEC BL JNZ REVER CALL DELAY JMP START

http://csetube.co.nr/

85

CS2259 Microprocessors Laboratory 1020 ROTATE 1022 1024 1026 REPT

MOV CL,04 MOV AL,[D1] OUT PORT1,AL MOV DX,1010

B1 04 8A 05 E6 C0 BA 10,10

MEMORY ADDRESS 1029 102A 102C 102D 102D 102F 1030 1033 1036 1037 103B

LABEL

MNEMONICS DEC BX

OPCODE 4A 75 FD 47

LOOP L1

JNZ LOOP 1 INC D1

cs

et

ub

RET

e.c

o.

LOOP REPT

nr

/
E2 F3 C3 BA FF, FF 4A 75 FD C3 09 05 06 0A 0A 06 05 09

ht
DELAY FORW REV

tp
DEC DX JNZ DELAY RET DB DB

://

MOV DX FFFF

http://csetube.co.nr/

86

CS2259 Microprocessors Laboratory

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: 87

http://csetube.co.nr/

ht

tp

://

cs

et

ub

e.c

o.

nr

CS2259 Microprocessors Laboratory This mode provides simple I/O operations for each of the three ports and is suitable for synchronous data transfer. In this mode, all the ports can be configured either as input or output port. Let us initialize port A as input port PROGRAM: ADDRESS 1000 1003 1005 1007 1009 100B LABEL MNEMONICS MOV SI , 1500 MOV AL,90 OUT C6,AL IN AL,C0 MOV [SI], AL HLT OPCODES BE 00 15 B0 90 E6 C6 E4 C0 88 04 F4

MODE 0 STROBED I/O MODE: Let us initialize port A as input port and port B as output port PROGRAM: ADDRESS 1000 1002 1004 1006 1008 LABEL

MNEMONICS MOV AL,90 OUT C6,AL IN AL,C0 OUT C2 AL HLT

e.c

o.
OPCODES B0 90 E6 C6 E4 C0 E6 C2 F4

ht

tp

://

cs

et

ub

nr

http://csetube.co.nr/

88

CS2259 Microprocessors Laboratory

RESULT: Thus 8255 are interfaced and their characteristic in mode0 was studied.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

89

CS2259 Microprocessors Laboratory

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

90

CS2259 Microprocessors Laboratory

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 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:

ht

tp

://

MSG DB 0DH, 0AH, GOOD MORNING , ODH, OAH, $

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

91

CS2259 Microprocessors Laboratory

BIOS/DOS CALLS FILE CREATION


AIM: 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 ENDS CODE SEGMENT START: MOV AX, DATA MOV DS, AX MOV AH, 3CH INT 21H INT 21H CODE ENDS END START MOV AH, 4CH

MOV DX, OFFSET FILENAME

RESULT:

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

92

CS2259 Microprocessors Laboratory AIM:

BIOS/DOS CALLS KEYBOARD CONTROL

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: .Data mesg db 'Ten seconds have passed!',0Dh, 0Ah,'$' .Code ; ; pmesg - Prints the message pointed to by the DX register on the screen. ; pmesg PROC mov 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 we mov 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:

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

93

CS2259 Microprocessors Laboratory

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 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:

ht

tp

://

cs

et

ub

MSG DB 0DH, 0AH, GOOD MORNING , ODH, OAH, $

e.c

o.

nr

http://csetube.co.nr/

94

CS2259 Microprocessors Laboratory

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

95

CS2259 Microprocessors Laboratory 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 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 LIST DW 53H,25H,19H,02H

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

96

CS2259 Microprocessors Laboratory PR1:ADD SI,02 LOOP AGAIN1 DEC DX JNZ AGAIN0 MOV AH,4CH INT 21H CODE ENDS END START

RESULT:

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

97

CS2259 Microprocessors Laboratory LARGEST NUMBER IN AN ARRAY USING MASM SOFTWARE AIM: To find the largest number in an array using MASM software.

ALGORITHM: i. ii. iii. Initialize the data segment and the message to be displayed. Set function value for display. Point to the message and run the interrupt to display the message in the CRT

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

ht

tp

://

cs

et

ub

e.c

o.

PROGRAM:

nr

http://csetube.co.nr/

98

CS2259 Microprocessors Laboratory MOV SI,OFFSET LARGEST MOV [SI],AL MOV AH,4CH INT 21H CODE ENDS END START

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

99

CS2259 Microprocessors Laboratory 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

CODE SEGMENT MOV DS,AX MOV AH,09H

START: MOV AX,DATA

MOV DX,OFFSET MESSAGE INT 21H MOV AH,4CH INT 21H CODE ENDS END START

ht

DATA ENDS

tp

://

INTERESTING,0DH,0AH,$

cs

MESSAGE DB ODH,OAH,STUDY OF MICROPROCESSOR IS

et

ub

e.c

o.

nr

http://csetube.co.nr/

100

CS2259 Microprocessors Laboratory 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

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

101

CS2259 Microprocessors Laboratory 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 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 MOV AL,0PR1

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

102

CS2259 Microprocessors Laboratory

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

103

CS2259 Microprocessors Laboratory

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER EX NO: a DATE: ADDITION OF TWO 8-BIT NUMBERS USING 8051 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 2. Move the first data to Accumulator.

ht

MEMORY ADDRESS 6100 6101 6103 6105 6108 6109

LABEL

tp

MNEMONICS

://

PROGRAM

cs

et

4. Store the sum in memory pointed by DPTR.

ub

3. Add the second data with Accumulator.

e.c

o.
OP CODE C3 74, 04 24, 02 90, 65, 00 F0 80, FE

nr

1. Clear C-register for carry.

COMMENTS

CLR C MOV A,#data1 ADD A, #data2 MOV DPTR, #6500H MOVX @DPTR, A LOOP SJMP LOOP

OBSERVATION
104

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

INPUT

OUTPUT Address 6500 Data

Address 6102 6103

Data

RESULT Thus, the assembly language program to add the two 8-bit numbers using 8051 instruction set was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

105

CS2259 Microprocessors Laboratory

1. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER 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. 1. Clear C-register for carry. ALGORITHM 2. Move the first data to Accumulator.

MEMORY ADDRESS 6100 6101 6103 6105 6108 6109

LABEL

ht

PROGRAM

tp

MNEMONICS CLR C MOV A,#data1 SUBB A, #data2 MOV DPTR, #6500H MOVX @DPTR, A

://

4. Store the sum in memory pointed by DPTR.

cs

et

3. Subtract the second data with Accumulator.

ub

e.c
OP CODE C3 74, 04 94, 02 90, 65, 00 F0 80, FE

o.

nr

COMMENTS

LOOP

SJMP LOOP

http://csetube.co.nr/

106

CS2259 Microprocessors Laboratory

OBSERVATION INPUT Address 6102 6103 Data Address 6500 OUTPUT Data

RESULT Thus, the assembly language program to subtract the two 8-bit numbers was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

107

CS2259 Microprocessors Laboratory

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER 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. 1. Clear C-register for carry. ALGORITHM 2. Move the first data to Accumulator.

6. The lower order of the result is in Accumulator. 7. Store the sum in memory pointed by DPTR.

PROGRAM

ht

5. The higher order of the result is in B-register.

tp

://

4. Multiply the second data with Accumulator.

cs

et

3. Move the second data to B-register.

ub

e.c

o.

nr

http://csetube.co.nr/

108

MEMORY ADDRESS 6100 6101 6103 6106 6107 610A 610B 610C 610E 610F

CS2259 Microprocessors Laboratory

LABEL

MNEMONICS CLR C MOV A,#data1 MOV B,#data2 MUL AB MOV DPTR, #6500H MOVX @DPTR, A INC DPTR MOV A, B MOVX @DPTR, A

OP CODE C3 74, 04 75, F0, 02 A4 90, 65, 00 F0 A3 E5, F0 F0 80, FE

COMMENTS

Address 6102 6103

Data

ht

INPUT

://

cs

et
OUTPUT Address 6500 6501 Data

OBSERVATION

RESULT Thus, the assembly language program to multiply the two 8-bit numbers using 8051 instruction set was written and executed

tp

ub

e.c

o.

LOOP

SJMP LOOP

nr

http://csetube.co.nr/

109

CS2259 Microprocessors Laboratory

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER EX NO: d DATE: DIVISION OF TWO 8-BIT NUMBERS USING 8051 AIM 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 2. Move the first data to Accumulator.

7. Store the sum in memory pointed by DPTR.

PROGRAM
110

http://csetube.co.nr/

ht

6. The quotient of the result is in Accumulator.

tp

5. The remainder of the result is in B-register.

://

cs

4. Multiply the second data with Accumulator.

et

ub

3. Move the second data to B-register.

e.c

o.

nr

1. Clear C-register for carry.

MEMORY ADDRESS 6100 6101 6103 6106 6107 610A 610B 610C 610E 610F

CS2259 Microprocessors Laboratory

LABEL

MNEMONICS CLR C MOV A,#data1 MOV B,#data2 DIV AB MOV DPTR, #6500H MOVX @DPTR, A INC DPTR MOV A, B MOVX @DPTR, A

OP CODE C3 74, 08 75, F0, 02 84 90, 65, 00 F0 A3 E5, F0 F0 80, FE

COMMENTS

6102 6105

ht

Address

Data

://

INPUT

cs

et
OUTPUT Data Address 6202 6203

OBSERVATION

RESULT Thus, the assembly language program to divide the two 8-bit numbers using 8051 instruction set was written and executed successfully.

tp

ub

e.c

o.

LOOP

SJMP LOOP

nr

http://csetube.co.nr/

111

CS2259 Microprocessors Laboratory

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER EX NO: e DATE: AIM

ONES AND TWOS COMPLEMENT USING 8051

To write an assembly language program to find the 1s and 2s

complement of an 8-bit number using microcontroller instruction set. APPARATUS REQUIRED 1. 8051 Microcontroller kit 2. Power chord. ALGORITHM 2. Complement the accumulator. 4. Add 01H with accumulator.

MEMORY ADDRESS 6100 6101 6103 6106 6107 610A 610B 610C

LABEL

ht

5. Move the twos complement output to the memory 6501H. PROGRAM

tp

MNEMONICS MOV A, #data CPL A MOV DPTR, #6500H MOVX @DPTR, A INC A INC DPTR MOVX @DPTR, A

://

cs

et
OP CODE 74, CC F4 90, 65, 00 F0 04 A3 F0 80, FE

ub

3. Move the ones complement output to the memory 6500H.

e.c

o.

nr

1. Move the data to Accumulator.

COMMENTS

LOOP

SJMP LOOP

http://csetube.co.nr/

112

CS2259 Microprocessors Laboratory

OBSERVATION Address 6101

INPUT Data Address 6500 6501

OUTPUT Data

RESULT Thus the assembly language program to find the 1s and 2s complement of an 8-bit number using 8051 instruction set was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

113

CS2259 Microprocessors Laboratory

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 2. Perform OR operation with accumulator.

ht

MEMORY ADDRESS 6100 6102 6104 6107 6108

LABEL

tp

MNEMONICS

://

PROGRAM

cs

et
OP CODE 74, 2F 44, 7E 90, 65, 00 F0 80, FE

ub

3. Move the accumulator output to the memory 6500H.

e.c

o.

nr

1. Move the data to Accumulator.

COMMENTS

MOV A, #data1 ORL A, #data2 MOV DPTR, #6500H MOVX @DPTR, A LOOP SJMP LOOP

OBSERVATION
114

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

INPUT Address 6101 6103 Data Address 6500

OUTPUT Data

RESULT Thus the assembly language program to Setting bits an 8-bit number using microcontroller instruction set was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

115

CS2259 Microprocessors Laboratory

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 2. Perform AND operation with accumulator.

ht

MEMORY ADDRESS 6100 6102 6104 6107 6108

LABEL

tp

MNEMONICS

://

PROGRAM

cs

et
OP CODE 74, 2F 54, 7E 90, 65, 00 F0 80, FE

ub

3. Move the accumulator output to the memory 6500H.

e.c

o.

nr

1. Move the data to Accumulator.

COMMENTS

MOV A, #data1 ANL A, #data2 MOV DPTR, #6500H MOVX @DPTR, A LOOP SJMP LOOP

OBSERVATION
116

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

INPUT Address 6101 6103 Data Address 6500

OUTPUT Data

RESULT Thus the assembly language program to masking bits an 8-bit number using microcontroller instruction set was written and executed successfully.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

117

CS2259 Microprocessors Laboratory

PROGRAMS FOR SORTING AND SEARCHING (USING 8051)

EX NO: a DATE: ARRANGE THE GIVEN NUMBER IN ASCENDING ORDER AIM To write an assembly language program to sort an array of data in ascending 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 Bregister. 3. Set HL pair as data address pointer. 2. Decrement B-register (B is a count for (N-1) repetitions).

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.

ht

tp

6. Increment the HL pair (data address pointer).

://

pointer.

cs

et

5. Load a data of the array in accumulator using the data address

ub

e.c

4. Set C-register as counter for (N-1) comparisons.

o.

nr

http://csetube.co.nr/

118

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6102 6104 6107 6109 610B 610C 610E 610F 6110 6111 6112 6114 6116 6118 611A 611C 611E 611F 6120 6122 6124 6126 6127

LABEL

MNEMONICS MOV R3, #04H MOV R4, #04H MOV DPTR, #6500H

OP CODE 7B, 04 7C, 04 90, 65, 00 AD, 82, AE, 83 E0 F5, F0 A3 E0 F8 C3 95, F0 50,13 C0, 82 C0, 83 8D, 82 8E, 83 E8 E0 D0, 83 D0, 82 E5, F0 F0 88, FO
119

LOOP1

MOV R5, DPL MOV R6, DPH MOVX A, @DPTR MOV B,A MOVX A, @DPTR CLR C

EXCH

ht

tp

http://csetube.co.nr/

://

cs

SUBB A, B JNC LOOP2 PUSH DPL PUSH DPH MOV DPL, R5 MOV DPH, R6 MOV A, R0 MOVX A, @DPTR POP DPH POP DPL MOV A, B MOVX @DPTR, A MOV B, R0

et

ub

MOV R0, A

e.c

o.

nr

LOOP

INC DPTR

CS2259 Microprocessors Laboratory

6129

LOOP2

DJNZ R3, REPT DEC R4 MOV A, R4 MOV R3, A INC R4 MOV DPL, R5 MOV DPH, R6 INC DPTR DJNZ R4, LOOP1

DB, E3 1C EC FB 0C 8D, 82 8E, 83 A3 DC, D1 80, FE

612B 612C 612D 612E 612F 6131 6133 6134 6136 OBSERVATION (Before sorting) Address 6500 6501 6502 6503 6504 6505 Data 05H 0AH 0CH 06H 03H 08H HLT

SJMP HLT

ub cs et

INPUT

e.c ://
Address 6500 6501 6502 6503 6504 6505

o.
OUTPUT Data 05H 03H 06H 08H 0AH 0CH (After sorting)

RESULT
Thus, the assembly language program to sort an array of data in ascending order using 8051 simulator tools was written and executed successfully .

ht

tp

nr

http://csetube.co.nr/

120

CS2259 Microprocessors Laboratory

PROGRAMS FOR SORTING AND SEARCHING (USING 8051)

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 Bregister. 3. Set HL pair as data address pointer. 2. Decrement B-register (B is a count for (N-1) repetitions).

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.

ht

tp

6. Increment the HL pair (data address pointer).

://

pointer.

cs

et

5. Load a data of the array in accumulator using the data address

ub

e.c

4. Set C-register as counter for (N-1) comparisons.

o.

nr

http://csetube.co.nr/

121

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY ADDRESS 6100 6102 6104 6107 6109 610B 610C 610E 610F 6110 6111 6112 6114 6116 6118 611A 611C 611E 611F 6120 6122 6124 6126 6127

LABEL

MNEMONICS MOV R3, #04H MOV R4, #04H MOV DPTR, #6500H

OP CODE 7B, 04 7C, 04 90, 65, 00 AD, 82, AE, 83 E0 F5, F0 A3 E0 F8 C3 95, F0 40,13 C0, 82 C0, 83 8D, 82 8E, 83 E8 E0 D0, 83 D0, 82 E5, F0 F0 88, F0
122

LOOP1

MOV R5, DPL MOV R6, DPH MOVX A, @DPTR MOV B,A MOVX A, @DPTR CLR C

EXCH

ht

tp

http://csetube.co.nr/

://

cs

SUBB A, B JNC LOOP2 PUSH DPL PUSH DPH MOV DPL, R5 MOV DPH, R6 MOV A, R0 MOVX A, @DPTR POP DPH POP DPL MOV A, B MOVX @DPTR, A MOV B, R0

et

ub

MOV R0, A

e.c

o.

nr

LOOP

INC DPTR

CS2259 Microprocessors Laboratory

6129

LOOP2

DJNZ R3, REPT DEC R4 MOV A, R4 MOV R3, A INC R4 MOV DPL, R5 MOV DPH, R6 INC DPTR DJNZ R4, LOOP1

DB, E3 1C EC FB 0C 8D, 82 8E, 83 A3 DC, D1 80, FE

612B 612C 612D 612E 612F 6131 6133 6134 6136 OBSERVATION (Before sorting) Address 6500 6501 6502 6503 6504 6505 Data 05H 0AH 0CH 06H 03H 08H HLT

SJMP HLT

ub cs et

INPUT

e.c ://
Address 6500 6501 6502 6503 6504 6505

o.
OUTPUT Data 05H 0CH 0AH 08H 06H 03H (After sorting)

RESULT
Thus the assembly language program to sort an array of data in descending order using 8051 simulator tools was written and executed successfully .

ht

tp

nr

http://csetube.co.nr/

123

CS2259 Microprocessors Laboratory

PROGRAMS FOR SORTING AND SEARCHING (USING 8051)

EX NO: c DATE: AIM LARGEST ELEMENT IN AN ARRAY

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 2. Move the first data from memory to accumulator and move it to B3. Move the second data from memory to 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. 1. Clear C-register for carry. register.

PROGRAM

ht

tp

://

4. Add the content of B-register with Accumulator.

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

124

CS2259 Microprocessors Laboratory

MEMORY ADDRESS 6100 6103 6106 6108 6109 610C 610D 610F 6111 6112 6114 6116 6118 OBSERVATION

LABEL

MNEMONICS MOV DPTR,#6500 MOV 40,#00 MOV R5,#05

OP CODE 90, 65, 00 75, 40, 00 7D, 05 E0 B5, 40, 08 A3 DD, F9 E5, 40 F0 80, FE 40, F6 F5, 40 80, F2

LOOP2 MOVX A,@DPTR CJNE A,40H,LOOP1 LOOP3 INC DPTR DJNZ R5, LOOP2 MOVX @DPTR,A LOOP1 JC LOOP3 MOV A, 40H HLT SJMP HLT

INPUT Address 6500 6501 6502 6503 6504 Data 04H 08H 02H 0AH 06H 6500 Address

ht

tp

://

MOV 40H,A SJMP LOOP3

cs

et

ub

e.c

o.

nr
OUTPUT

Data

0AH

http://csetube.co.nr/

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

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

126

CS2259 Microprocessors Laboratory INTERFACING OF 8279 ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b) USINGH 8051 ADDRESS 4000 4003 4005 4007 4009 400A 400C 400D 401F 4010 4012 4014 4015 4018 4019 401C 401D 401A ORG 4500 ADDRESS 4500 4502 4504 4505 4507 4509 LABEL LOOP2 LOOP1 MNEMONICS MOV R4,#A0 MOV R5,#FF NOP DJNZ R5,LOOP1 DJNZ R4,LOOP2 RET OP-CODE 7C A0 7D FF 00 DD FD DC F9 22 LABEL MNEMONICS MOV DPTR,#FFC2 MOV R0,#00 MOV R1,#44 MOV A,#10 MOVX@DPTR,A MOV A,#CC MOVX@DPTR,A MOV A,#90 MOVX@DPTR,A MOV DPH,R1 MOV DPL,R0 MOVX@DPTR MOV DPTR,FFC0 OP-CODE 90 FF C2 78 00 79 44 74 10 F0 74 CC F0 74 90 F0 89 83 88 82 E0 90 FF C0 F0 12 45 00 08 B8 0F F0 02 81 00

LOOP

ht

tp

://

cs

LOOK-UP TABLE 127

http://csetube.co.nr/

et

ub

MOVX@DPTR,A LCALL DELAY INC R0 CJNE R0,#0F,LOOP LJMP START

e.c

o.

nr

CS2259 Microprocessors Laboratory ADDRESS DATA 4400 4404 4408 440C FF,FF,FF,FF FF,FF,FF,FF 68,6C,68,FF 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

INTERFACING AND PROGRAMMING OF DC MOTOR SPEED CONTROL

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

128

CS2259 Microprocessors Laboratory 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 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 ; LCALL CRLF ;CLEAR 7-SEG DISPLAY MOV DPTR,#MSG1 ; LCALL MSGOUT ;DIPLAY "DIR F/R" LCALL RD79 ;LOOK FOR KEYBOARD I/P CJNE A,#46H,REV ; MOV B,#01H ; LJMP SPEED ; CJNE A,#52H,FIN1 ;IF REVERSE, SET PC1 HIGH MOV B,#02H ; LJMP SPEED ; 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 ; 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 ; JC WAVE ; MOV A,B ;

TEST:

FIN1:

SPEED:

INVERT:

ht

tp

REV:

://

cs

et

ub

e.c

o.

LOOP:

nr

http://csetube.co.nr/

129

CS2259 Microprocessors Laboratory 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 ; 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

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

130

CS2259 Microprocessors Laboratory MOVX @DPTR,A ; CLR A ; MOV DPTR,#280CH ;SMALLEST COUNT TO TURN MOVX @DPTR,A ;MOTOR ON LJMP LOOP ; MSG1: MSG2: DFB "DIR F/R",03H DFB "SPEED ",03H DFB 00H,50H END

INTERFACING AND PROGRAMMING OF STEPPER MOTOR USING 8051 STEPPER MOTOR INTERFACING
http://csetube.co.nr/
131

ht

tp

://

cs

et

ub

e.c

o.

nr

CS2259 Microprocessors Laboratory

AIM

To write an assembly language program to interface stepper motor

with 8051. APPARATUS REQUIRED 8081 Microcontroller kit, Power chord, stepper motor, stepper motor interface board 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 The basic two-phase stepper motor consists of two pairs of stator winding generates a North Pole. A South Pole gets induced at the 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 STE A A2 B B2 P 1 1 1 1 0 0 1 CLOCKWISE DATA STE A A P 1 2 9h 1 1 0 control machine tools, etc.

ht

tp

://

diametrically opposite side. The rotor magnetic system has two end faces. It

cs

et

ub

poles. Each of the four poles has its own winding. The excitation of any one

e.c

o.

nr

/
B 1 1

B2 0

DATA Ah
132

http://csetube.co.nr/

CS2259 Microprocessors Laboratory

2 3 4

0 0 1

1 1 0

0 1 1

1 0 0

5h 6h Ah

2 3 4

0 0 1

1 1 0

1 0 0

0 1 1

6h 5h 9h

ADDRESS DECODING LOGIC The 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. voltage output pulses using a buffer 7407 with open collector. 1. Store the lookup table address in DPTR. 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. The TTL levels of pulse sequence from the data bus are translated to high ALGORITHM

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

ht

tp

://

2. Move the content value (04H) to one of the register (R0).

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

133

CS2259 Microprocessors Laboratory 4100 START MOV DPTR,#4500 4103 4105 4106 4108 410A 410D 410F 4111 4113 4115 4117 4119 411A 411C 411E 411F 4121 MOV R0 #04 MOVX A@DPTR PUSH DPH PUSH DPL MOV DPTR,#FFC0 MOV R2 #04 MOV R1 #0F MOV R3 #0F DJNZ R3 DLY DJNZ R1 DLY1 DJNZ R2 DLY1 MOVX@DPTR,A POP DPL POP DPH INC DPTR DJNZ R0 J0 SJMP START

90 45 00 78 04 E0 C0 83 C0 82 90 FF C0 7A 04 7B 0F 7B 0F DB FE D9 FA DA F8 F0 D0 82 D0 83 A3 D8 E4 80 DD

DLY1 DLY

AIM

SAWTOOTH WAVE GENERATION USING 8051


To write an assembly language program to generate the saw tooth wave using

microcontroller instruction set.

ht

tp

://

cs

et

ub

e.c

o.

nr

http://csetube.co.nr/

134

CS2259 Microprocessors Laboratory

APPARATUS REQUIRED ALGORITHM

8051 Microcontroller kit, Power chord, DAC Interface Card, CRO 1. 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.

PROGRAM

ORG 4100H DAC I EQU FFC0H ADDRESS LABEL 4100 START 4102 4105 4106 4107 4109 L1

MNEMONICS MOV A,#00H MOV DPTR,#DAC I MOVX@DPTR,A

OPCODE 74 00

tp

://

OBSERVATION S.No 1 RESULT: TIME PERIOD (msec) 1.2* 2 = 2.4mse

ht

SJMP START

cs

JNZ L1

et

ub

INC A

e.c

o.

AMPLITUDE (volts) 2.4 * 2 = 4.8 V

Thus the assembly language program to generate the triangular wave using 8051 instruction set was written and executed successfully.

AIM

TRIANGULAR WAVE GENERATION USING 8051

nr

/
F0 04

90 FF C0

70 F9 80 F5

COMMENT MOVE DATA TO ACC MOVE DATA TO DPTR MOVE DPTR TO ACC INCREMENT ON ACC IF JUMP NO ZERO GO TO L1 SHORT JUMP TO START

http://csetube.co.nr/

135

CS2259 Microprocessors Laboratory

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 ALGORITHM 1. 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. 7. Move the accumulator content to DAC. 9. If accumulator content is zero go to step2. Else go to step 7.

PROGRAM

ORG 4100H DAC I EQU FFC0H

ht

tp

://

cs

et

ub

8. Decrement the accumulator content by 1.

e.c

o.

nr

6. Load value (FF) to accumulator.

http://csetube.co.nr/

136

CS2259 Microprocessors Laboratory ADDRESS LABEL MNEMONICS 4100 START MOV A,#00H 4102 4105 4106 4107 4109 410B 410C 410D 410F L2 L1 MOV DPTR,#DAC I MOVX@DPTR,A INC A JNZ L1 MOV A,#FFH MOVX@DPTR,A DEC A JNZ L2 SJMP START

OPCODE 74 00 90 FF C0 F0 04 70 F9 70 FF F0 14

1.6 * 2 = 3.2mse

ht

tp

S.No

TIME PERIOD (msec)

://

cs

et

OBSERVATION

ub

e.c

o.

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 AND UART OPERATIONS IN 8051 MICROCONTROLLER
137

http://csetube.co.nr/

nr

70 FC 80 EF

COMMENT MOVE DATA TO ACC MOVE DATA TO DPTR MOVE DPTR TO ACC INCREMENT ON ACC IF JUMP NO ZERO GO TO L1 MOVE DATA TO ACC MOVE DPTR TO ACC DECREMENT ON ACC IF JUMP NO ZERO TO L2 SHORT JUMP TO START

AMPLITUDE (volts) 2.5 * 2 = 5 V

CS2259 Microprocessors Laboratory 1-INTERFACING PROGRAM OF TIMER [8053] USING MICROCONTROLLER A) SQUARE WAVE GENERATION MODE ADDRESS LABEL MNEMONICS OPCODE 4100 MOV 90 FF CE DPTR,#FFCE 4103 MOV A,#36 74 36 4105 4106 4108 410B 410C 410E 410F HERE: MOVX@DPTR,A F0 MOV A,#0A 74 0A

MOV 90 FF C8 DPTR,#FFC8 MOVX@DPTR,A F0 MOV A,#00 MOVX @DPTR,A SJMP HERE 74 00

7. PROGRAMMING AND VERIFYING TIMER, INTERRUPTS AND UART OPERATIONS IN 8051 MICROCONTROLLER
138

http://csetube.co.nr/

ht

tp

://

cs

et

ub

e.c

o.

nr
80 FE

F0

COMMENT MOVE DATA TO DATA POINTER MOVE DATA TO ACCUMULATOR MOVE DPTR TO ACC MOVE DATA TO ACC MOVE DATATO DPTR MOVE DPTR TO ACC MOVE DATA TO ACC MOVE DPTR TO ACC SHORT JUMP TO HERE

7. PROGRAMMING AND VERIFYING TIMER, INTERRUPTS AND UART OPERATIONS IN 8051 MICROCONTROLLER
http://csetube.co.nr/
139

ht

tp

://

cs

et

ub

CS2259 Microprocessors Laboratory 1-INTERFACING PROGRAM OF TIMER [8053] USING MICROCONTROLLER B) SQUARE WAVE GENERATION OF FREQUENCY 150 KHz AT CHANNEL 0 ADDRESS LABEL MNEMONICS OPCODE COMMENT 4100 MOV A,#36 74 36 MOVE DATA TO ACC 4102 MOV 90 FF CE MOVE DATA DPTR,#FFCE TO DPTR 4105 MOVX@DPTR,A F0 MOVE DPTR TO ACC 4106 MOV A,#12 74 12 MOVE DATA TO ACC 4108 MOV 90 FF C8 MOVE DPTR,#FFC8 DATATO DPTR 410B MOVX@DPTR,A F0 MOVE DPTR TO ACC 410C MOV A,#00 74 00 MOVE DATA TO ACC 410E MOVX F0 MOVE DPTR @DPTR,A TO ACC 410F HERE: SJMP HERE 80 FE SHORT JUMP TO HERE

e.c

o.

nr

CS2259 Microprocessors Laboratory 2-INTERFACING PROGRAM OF INTERRUPTS [8059] USING MICROCONTROLLER TO PROGRAM 8259 IN POLLING MODE ADDRESS 4100 4103 4105 4108 4109 410C 410F 4110 4111 4114 4116 4117 4119 411A 411B 411C 411F 4120 4122 4124 4127 ISR ORG 4150 ADDRESS 4150 4152 4155 LABEL MNEMONICS MOV 1E,#00 MOV A,#16 MOV DPTR,#FFCO MOV @DPTR,A MOV DPTR,#FFC2 MOV A,#00 MOV @DPTR,A MOV @DPTR,A MOV DPTR,#FFCO MOV A,#40 MOV @DPTR,A MOV A,#0C MOV @DPTR,A MOV A, @DPTR MOV R0,A JNB E0 WAIT MOV A,R0 ANL A,#07 CJNE A,#00 HERE LCALL ISR SJMP HERE MNEMONICS MOV A,#00 LCALL 0020 SJMP STOP OPCODE 75 A8 00 74 16 90 FF C0 F0 90 FF C2 74 00 F0 F0 90 FF C0 74 40 F0 74 0C F0 E0 F8 30 E0 F8 F8 54 07 B4 00 03 12 41 50 80 FE OPCODE 74 00 12 00 20 80 FE

HERE: LABEL STOP

RESULT

ht

tp

://

cs

et

ub

e.c

WAIT

o.

nr

http://csetube.co.nr/

140

Вам также может понравиться