CS 2259-MICROPROCESSOR LABORATORY

185
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 1

Transcript of CS 2259-MICROPROCESSOR LABORATORY

Page 1: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

VEL TECH HIGH TECHDr.RANGARAJAN Dr.SAKUNTHALA

ENGINEERING COLLEGE(ISO 9001: 2000 Certified Institution & NBA Accredited)

(Owned by VEL Sree Dr.RANGARAJAN Dr. Sakunthala Rangarajan Educational Academy1997)

CS 2259-MICROPROCESSOR LABORATORY

Approved by AICTE, New Delhi & Affiliated to Anna UniversityNo 60, Avadi-Vel tech Road, Chennai – 600 062

PREPARED BY (HOD/ECE)E.JAYAPRAKASH ESTHER RANI.PN.PRABHAKARANMUBEEN MUBARAK

1

Page 2: CS 2259-MICROPROCESSOR LABORATORY

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 80852. Programming with 8086-experiments including BIOS/DOS calls:3. Keyboard control, Display, File Manipulation.4. Interfacing with 8085/8086-8255,82535. Interfacing with 8085/8086-8279,82516. 8051 Microcontroller based experiments for Control Applications7. Mini- Project

TOTAL: 45 PERIODS

List of equipments/components for 30 students (two per batch)1. 8085 Trainer Kit with onboard 8255, 8253, 8279 and 8251 – 15 nos.2. TASM/MASM simulator in PC (8086 programs) – 30 nos.3. 8051 trainer kit – 15 nos.4. Interfacing with 8086 – PC add-on cards with 8255, 8253, 8279 and 8251 – 15nos.5. Stepper motor interfacing module – 5 nos.6. Traffic light controller interfacing module – 5 nos.7. ADC, DAC interfacing module – 5 nos.8. CRO’s – 5 nos.

2

Page 3: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

3

Page 4: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

ADDITION OF TWO 8-BIT NUMBERS WITH CARRY USING 8085

AIM

To write an assembly language program to add the two 8-bit numbers

with carry.

APPARATUS REQUIRED

1. 8085 Microprocessor kit

2. Power chord

ALGORITHM

1. Clear C-register for carry.

2. Move the first data from memory to accumulator and move it to B-

register.

3. Move the second data from memory to accumulator.

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

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

6. Increment the C-register

7. Store the sum in memory.

8. Move the carry to accumulator and store in memory.

9. Stop.

4

Page 5: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA 6200 3A 00 62

6103 MOV B,A 47

6104 LDA 6201 3A 01 62

6107 MVI C,00 0E 00

6109 ADD B 80

610A JNC LOOP D2 0E 61

610D INR C 0C

610E LOOP STA 6202 32 02 62

6111 MOV A,C 79

6112 STA 6203 32 03 62

6115 HLT 76

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 02H 6202 07H (sum)

6201 05H 6203 00H (carry)

5

Page 6: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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.

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.

6

Page 7: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA 6201 3A 01 62

6103 MOV B,A 47

6104 LDA 6200 3A 00 62

6107 MVI C,00 0E 00

6109 SUB B 90

610A JNC LOOP D2 11 61

610D INR C 0C

610E CMA 2F

610F ADI 01H C6 01

6111 LOOP STA 6202 32 02 62

6114 MOV A,C 79

6115 STA 6203 32 03 62

6118 HLT 76

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 04H 6202 02H (Difference)

6201 02H 6203 00H (sign)

7

Page 8: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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.

5. Increment the pointer.

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

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

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

10.

9. Increment the C- register.

10.Decrement B- registers (count).

11.Check whether count has reached zero. If ZF = 0, repeat step 7

through 11, or if ZF = 1 go to next step.

12.Increment the pointer and store LSB of the product in memory.

13.Increment the pointer and store MSB of the product in memory.

14.Stop.

8

Page 9: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LXI H, 6200 21 00 62

6103 MVI C,00 0E,00

6105 XRA A AF

6106 MOV B,M 23

6107 INX H B8

6108 MOV D,M 56

6109 REPT ADD D 82

610A JNC AHEAD D2 0E 61

610D INR C 0C

610E AHEAD DCR B 05

610F JNZ REPT C2 09 61

6112 INX H 23

6113 MOV M,A 77

6114 INX H 23

6115 MOV M,C 71

6116 HLT 76

9

Page 10: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 02H 6202 08H (LSB of product)

6201 04H 6203 00H (MSB of product)

10

Page 11: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

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

numbers was written and executed successfully.

DIVISION OF TWO 8-BIT NUMBERS WITH BORROW

AIM

To write an assembly language program to divide the two 8-bit

numbers with remainder.

APPARATUS REQUIRED

1. 8085 Microprocessor kit

2. Power chord

ALGORITHM

1. Load the divisor in accumulator and move it to B- register.

2. Load the dividend in accumulator.

3. Clear C-register to account for quotient.

4. Check whether divisor is less than dividend

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

step.

5. Subtract the content of B register from accumulator.

6. Increment the content of C-register (quotient).

7. Go to step 4.

8. Store the content of accumulator (remainder) in memory.

9. Move the content of C-register (quotient) to accumulator and store

in memory.

11

Page 12: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

10.Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA 4201 3A 01 42

6103 MOV B,A 47

6104 LDA 4200 3A 00 42

6107 MVI C,00 0E 00

6109 AGAIN CMP B B8

610A JC STORE DA 12 61

610D SUB B 90

610E INR C 0C

610F JNC AGAIN C3 09 61

6112 STORE STA 6203 32 03 42

6115 MOV A,C 79

6116 STA 6202 32 02 62

6119 HLT 76

12

Page 13: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 08H 6202 04H (Quotient)

6201 02H 6203 00H (Remainder)

RESULT

Thus the assembly language program to divide the two 8-bit numbers

was written and executed successfully.

MAXIMUM OF NUMBER IN THE ARRAY USING 8085

AIM

To write an assembly language program to search the maximum of

number data in the array.

APPARATUS REQUIRED

1. 8085 Microprocessor kit

2. Power chord

ALGORITHM

1. Load the address of the first element of the array in HL register

pair.

2. Move the count to B-register.

3. Increment the pointer.

4. Get the first data in accumulator.

5. Decrement the count.

6. Increment the pointer.

13

Page 14: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

accumulator.

8. If carry=0, go to step 10, or if carry= 1, go to step 9.

9. Move the content memory addressed HL to accumulator.

10.Decrement the count.

11.Check for zero of the count. If ZF = 0, go to step 6, or If ZF = 1, go

to next step.

12.Store the smallest data in memory.

13.Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LXI H,6200 21 00 62

6103 MOV B,M 46

6104 INX H 23

6105 MOV A,M 7E

6106 DCR B 05

6107 LOOP INX H 23

6108 CMP M BE

6109 JNC AHEAD D2 OD 61

610C MOV A,M 7E

611D AHEAD DCR B 05

610E JNZ LOOP C2 07 61

6111 STA 6300 32 00 63

14

Page 15: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6114 HLT 76

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 05H

6300 0CH

6201 0AH

6202 03H

6203 08H

6204 06H

6205 0CH

15

Page 16: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to search the largest data in an

array was written and executed successfully.

MINIMUM OF NUMBER IN THE ARRAY USING 8085

AIM

To write an assembly language program to search the minimum of

number in the array.

APPARATUS REQUIRED

8085 Microprocessor kit

Power chord

ALGORITHM

1. Load the address of the first element of the array in HL register

pair.

2. Move the count to B-register.

3. Increment the pointer.

4. Get the first data in accumulator.

5. Decrement the count.

16

Page 17: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6. Increment the pointer.

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

accumulator.

8. If carry=1,, go to step 10, or if carry= 0, go to step 9.

9. Move the content memory addressed HL to accumulator.

10.Decrement the count.

11.Check for zero of the count. If ZF = 0, go to step 6, or If ZF = 1, go

to next step.

12.Store the smallest data in memory.

13.Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LXI H,6200 21 00 62

6103 MOV B,M 46

6104 INX H 23

6105 MOV A,M 7E

6106 DCR B 05

6107 LOOP INX H 23

6108 CMP M BE

6109 JC AHEAD DA OD 61

610C MOV A,M 7E

611D AHEAD DCR B 05

17

Page 18: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

610E JNZ LOOP C2 07 41

6111 STA 6300 32 00 63

6114 HLT 76

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 05H

6300 03H

6201 0AH

6202 03H

6203 08H

6204 06H

6205 0CH

18

Page 19: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to search the smallest data in an

array was written and executed successfully.

ARRANGE THE GIVEN NUMBER IN ASCENDING ORDER USING

8085

AIM

To write an assembly language program to sort an array of data in ascending

order.

ALGORITHM

1. Load the count value from memory to A-register and store it in B-

register.

2. Decrement B-register (B is a count for (N-1) repetitions).

3. Set HL pair as data address pointer.

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

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

pointer.

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

19

Page 20: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

7. Compare the data pointed by HL with accumulator.

8. If carry flag is set (if the content of accumulator is smaller than

memory) then go to step 10, otherwise, go to next step.

9. Exchange the content of memory pointed by HL and the

accumulator.

10.Decrement C-register. If zero flag is reset go to step 6, otherwise,

go to next step.

11.Decrement B-register. If zero flag is reset go to step 3, otherwise,

go to next step.

12.Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA,6200 3A 00 62

6103 MOV B,A 47

6104 DCR B 05

6105 LOOP2 LXI H,6200 21 00 62

6108 MOV C,M 4E

6109 DCR C 0D

610A INX H 23

610B LOOP1 MOV A,M 7E

610C INX H 23

611D CMP M BE

20

Page 21: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

21

Page 22: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to sort an array of data in

ascending order was written and executed successfully.

ARRANGE THE GIVEN NUMBER IN DESCENDING ORDER

USING 8085

AIM

To write an assembly language program to sort an array of data in

descending order.

ALGORITHM

1. Load the count value from memory to A-register and store it in B-

register.

2. Decrement B-register (B is a count for (N-1) repetitions).

3. Set HL pair as data address pointer.

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

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

pointer.

22

Page 23: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

7. Compare the data pointed by HL with accumulator.

8. If carry flag is reset (if the content of accumulator is larger than

memory) then go to step 10, otherwise, go to next step.

9. Exchange the content of memory pointed by HL and the

accumulator.

10.Decrement C-register. If zero flag is reset go to step 6, otherwise,

go to next step.

11.Decrement B-register. If zero flag is reset go to step 3, otherwise,

go to next step.

12.Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA,6200 3A 00 62

6103 MOV B,A 47

6104 DCR B 05

6105 LOOP2 LXI H,6200 21 00 62

6108 MOV C,M 4E

6109 DCR C 0D

610A INX H 23

610B LOOP1 MOV A,M 7E

610C INX H 23

23

Page 24: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

611D CMP M BE

610E JNC AHEAD D2 16 61

6111 MOV D,M 56

6112 MOV M,A 77

6113 DCX H 2B

6114 MOV M,D 72

6115 INX H 23

6116 AHEAD DCR C 0D

6117 JNZ LOOP1 C2 0B 61

611A DCR B 05

611B JNZ LOOP2 C2 05 61

611E HLT 76

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

24

Page 25: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to sort an array of data in

descending order was written and executed successfully.

CONVERT THE ASCII CODE TO HEX CODE USING 8085

AIM

To write an assembly language program to convert the ASCII code to

HEX code.

APPARATUS REQUIRED

8085 Microprocessor kit

Power chord

ALGORITHM

1. Set HL pair as pointer for ASCII array.

2. Set D-register as counter for number of data in the array.

3. Set BC pair as pointer for binary (Hexa) array.

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

25

Page 26: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Call subroutine BIN to find the binary (Hexa) value.

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

memory.

7. Increment BC pair.

8. Decrement D-register. If ZF = 0, then go to step 4. if ZF = 1, then

step.

Algorithm for subroutine BIN

1. Subtract 30 from A-register.

2. Compare the content of A-register with 0A.

3. If CY = 1, go to step 5. If CY = 0, go to next step.

4. Subtract 07 from A-register.

5. Return to main program.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LXI H,6200 21 00 62

6103 MOV D,M 56

6104 LXI B,6300 01 00 63

6107 INX H 23

6108 MOV A,M 7E

6109 CALL BIN CD 13 61

610C STAX B 02

611D INX B 03

26

Page 27: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 01 6202 30H

6201 0A 6203 41H

27

Page 28: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to covert the ASCII code to

HEX code was written and executed successfully.

CONVERT THE HEX CODE TO ASCII CODE USING 8085

AIM

To write an assembly language program to convert the HEXI code to

ASCII code.

APPARATUS REQUIRED

8085 Microprocessor kit

Power chord

ALGORITHM

1. Load the given data in A register and move to B register.

2. Mask the upper nibble of HEX data.

3. Call subroutine code to find the ASCII value of the lower nibble

and store in memory.

28

Page 29: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4. Move B register to A register Mask the lower nibble .

5. Rotate the upper nibble to lower nibble

6. Call subroutine code to find the ASCII value of the upper nibble

and store in memory.

Algorithm for subroutine CODE

1. Compare the content of A-register with 0A.

2. If CY = 1, go to step 4. If CY = 0, go to next step.

3. Add 07H to A register.

4. Add 30H to A register

5. Return to main program.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA 4200 3A 00 62

6103 MOV B,A 47

6104 ANI 0F E6 0F

6106 CALL CODE CD 1A 61

6109 STA 4201 32 01 62

610C MOV A,B 78

610D ANI F0 E6 F0

610F RLC 07

29

Page 30: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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 30H6201 01H

6202 00H

30

Page 31: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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 8085AIM To write an assembly language program to convert the HEXI code to

BCD code.

APPARATUS REQUIRED

8085 Microprocessor kit

Power chord

ALGORITHM

1. Clear D and E registers to count for hundreds and tens.

2. Load the HEX data in A register.

3. Compare A-register with 64H. If carry=’1’ then go to step 7 else

go to next step.

31

Page 32: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4. Subtract 64H from A register.

5. Increment E register

6. Go to step 3

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

go to next step

8. Subtract 0AH from A register.

9. Increment D register and Go to step 7

10.Save the units, tens and hundreds.

11.Stop

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 MVI E,00H IE 00

6102 MOV D,E 53

6103 LDA 6200 3A 00 62

6106 HUNDRED CPI 64H FE 64

6108 JC TEN DA 11 61

610B SUI 64H D6 64

610D INR E 1C

610E JMP HUNDRED C3 06 61

6111 TEN CPI 0AH FE 0A

6113 JC UNIT DA 1C 61

32

Page 33: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6116 SUI 0AH D6 0A

6118 INR D 14

6119 JMP TEN C3 11 61

611C UNIT MOV C,A 4F

611D MOV A,D 7A

611E RLC 07

611F RLC 07

6120 RLC 07

6121 RLC 07

6122 ADD C 81

6123 STA 6201 32 01 62

6126 MOV A,E 7B

6127 STA 6202 32 02 62

612A HLT 76

OBSERVATION

INPUT OUTPUT

Address Data Address Data

4200 55H4201 55H (Tens and Units)

4202 00H (hundreds)

33

Page 34: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to covert the HEX code to BCD code

was written and executed successfully.

CONVERT THE BCD CODE TO HEX CODE USING 8085

AIM

To write an assembly language program to convert the BCD code to

HEX code.

APPARATUS REQUIRED

1. 8085 Microprocessor kit

2. Power chord

ALGORITHM

1. Get the BCD data in A register and save in B register.

2. Mask the lower nibble of BCD data

3. Rotate the upper nibble to lower nibble and save in B register.

4. Clear the accumulator.

34

Page 35: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Move 0Ah to C register.

6. Add B register to A register.

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

step 6.

8. Save the product in B register.

9. Get the BCD data in A register and mask the upper nibble.

10.Add the units to product.

11.Store the HEX value.

12.Stop

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 LDA 6200 3A 00 62

6103 MOV E,A 5F

6104 ANI 0FH E6 F0

6106 RLC 07

6107 RLC 07

6108 RLC 07

6109 RLC 07

610A MOV B,A 47

35

Page 36: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

610B XRA A AF

610C MVI C,0AH 0E 0A

610E ADD B 80

610F DCR C 0D

6110 JNZ REP C2 0E 61

6113 MOV B,A 47

6114 MOV A,E 7B

6115 ANI 0FH E6 F0

6117 ADD B 80

6118 STA 6201 32 01 62

611B HLT 76

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6200 10 6201 0AH

36

Page 37: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to covert the HEX code to

ASCII code was written and executed successfully.

ADC INTERFACING USING 8085AIM

To write an assembly language program to interface ADC board with

8085.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord, ADC interface board.

ALGORITHM

1. Find the data for corresponding channel.

2. Move the control word to accumulator and place in ADC.

3. Get the signal from ADC.

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

37

Page 38: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Find the display value for the input.

6. Move this value to the display board.

7. Go to step 1.

8. Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 START MVI A,00H 3E 004102 OUT CNT D3 C84104 ORI 08 F6 084106 OUT CNT D3 C84108 NOP 004109 NOP 00

410A NOP 00

410B ANI F7 E6 F7

410D OUT CNT D3 C8

38

Page 39: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

410F NOP 00

4110 NOP 00

4111 NOP 00

4112 MVI A,10H 3E 10

4114 OUT CNT D3 C8

4116 NOP 00

4117 NOP 00

4118 NOP 00

4119 MVI A,20H 3E 20

411B OUT CNT D3 C8

411D LOOP IN EOC DB C0

411F ANI 01 E6 01

4121 JNZ LOOP C2 1D 41

4124 IN DATA DB C4

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

39

Page 40: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4136 MOV A,M 7E

4137 OUT DATA D3 00

4139 MOV A,B 78

413A ANI 0F E6 0F

413C MOV L,A 6F

413D MOV A,M 7E

413E OUT DAT D3 00

4140 JMP START C3 10 41

4143 HLT 76

4200 0C 9F 4A 0B

99 29 28 8F

08 89 88 38

6C 1A 68 E8

OBSERVATION

S.No ANALOG INPUT DIGITAL OUTPUT

40

Page 41: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULTThus the assembly language program to interface ADC board with

8085 was written and executed successfully.

SQUARE WAVE GENERATION WITH 8085 USING DAC AIM

To write an assembly language program to generate square wave with

amplitude of 5 volts.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord, DAC interface chord.

ALGORITHM

1. Clear the accumulator.

2. Get the data to accumulator for 5 volts

3. Move this data to DAC kit.

4. Call the delay routine for required time interval.

5. Get the data to accumulator for 0 volts

41

Page 42: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6. Move this data to DAC kit.

7. Call the delay routine for required time interval.

8. Go to the first step.

9. Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 START MVI A,FFH 3E FF

4102 OUT C0 D3 C0

4104 CALL DELAY CD

4107 MVI A, 00H 3E 00

4109 OUT C0 D3 C0

410B CALL DELAY CD 20 41

410E JMP START C3 00 41

4111 HLT 76

42

Page 43: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

OBSERVATION

S.No TIME PERIOD (msec) AMPLITUDE (volts)

1 1.6 * 2 = 3.2mse 2.5 * 2 = 5 V

43

Page 44: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to generate square wave was

written and executed successfully.

TRIANGULAR WAVE GENERATION WITH 8085 USING DAC

AIM

To write an assembly language program to generate triangular wave

with amplitude of 5 volts.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord, DAC interface chord.

ALGORITHM

1. Clear the accumulator.

2. Move this data to DAC kit.

3. Increment the accumulator.

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

44

Page 45: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Get the data to accumulator for 5 volts

6. Move this data to DAC kit.

7. Decrement the accumulator.

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

9. Go to the step 1.

10.Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 START XRA A AF

4101 LOOP OUT C0 D3 C0

4103 INR A 3C

4104 JNZ LOOP C2 01 41

4107 MVI A,FFH 3E FF

4109 LOOP1 OUT C0 D3 C0

410B DCR A 3D

45

Page 46: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

410C JNZ LOOP1 C2 09 41

410F JMP START C3 00 41

OBSERVATION

S.No TIME PERIOD (msec) AMPLITUDE (volts)

1 1.2* 2 = 2.4mse 2.4 * 2 = 4.8 V

46

Page 47: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to generate triangular wave was

written and executed successfully.

SAWTOOTH WAVE GENERATION USING DAC USING 8085AIM

To write an assembly language program to generate saw tooth wave

with amplitude of 5 volts.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord, DAC interface chord.

ALGORITHM

1. Clear the accumulator.

2. Move this data to DAC kit.

3. Increment the accumulator.

4. Go to the step 2

47

Page 48: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

8100 START XRA A AF

8101 LOOP OUT C0 D3 C0

8103 INR A 3C

8104 JMP LOOP C2 01 81

8107 HLT 76

OBSERVATION

S.No TIME PERIOD (msec) AMPLITUDE (volts)

1 1.4 * 2 = 2.8mse 2.4 * 2 = 4.8 V

RESULT

Thus the assembly language program to generate saw tooth wave was

written and executed successfully

TRAFFIC LIGHT CONTROLLER USING 8085AIM

To write an assembly language program to interface traffic light

controller with 8085 using 8255.

APPARATUS REQUIRED8085 Microprocessor kit, Power chord, Traffic light interface board

ALGORITHM1. Find the control word for 8255 and data corresponding to the given

condition’s and load this data in to the memory location.

2. Get the number of conditions in the C-register.

3. Move the control word to accumulator and place in 8255.

48

Page 49: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

5. Move the next data to accumulator and place in port-B.

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

7. Call the delay routine.

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

step 3.

9. Go to step 1 and Stop

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 START LXI H,4500H 21, 00, 45

4103 MOV A,M 7E

4104 OUT CONT D3, 0F

4106 MIV C, 04H 0E, 04

4108 LOOP INX H 23

4109 MOV A, M 7E

410A OUT PORTA D3, 0C

410C INX H 23

410D MOV A, M 7E

410E OUT PORTB D3, 0D

4110 INX H 23

4111 MOV A, M 7E

4112 OUT PORTC D3, 0E

4114 CALL DELAY CD, 00, 42

4117 DCR C 0D

4118 JNZ LOOP C2, 08, 41

411B JMP START C3, 00, 41

411E HLT 76

49

Page 50: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

DELAY PROGRAM

4200 DELAY MVI C, 05H 0E, 05

4202 LOOP2 LXI D, FFFFH 11, FF, FF

4205 LOOP1 DCX D 1B

4206 MOV A, D 7A

4207 ORA E B3

4208 JNZ LOOP1 C2, 05, 42

420B DCR C 0D

420C JNZ LOOP2 C2, 02, 42

420F RET C9

INPUT DATA

4500 80, 84, 2E, 4C

4504 84, 9D, 90, 93

4507 2B, 10, 64, 27, 12

PORT A [ {D0 - D20}………0 - OFF & 1 – ON ]

D8 D7 D6 D5 D4 D3 D2 D1

POSITION 1 1 0 0 0 0 1 0 0 84H

POSITION 2 1 0 0 0 0 1 0 0 84H

POSITION 3 1 0 0 1 0 0 1 1 93H

POSITION 4 0 1 1 0 0 1 0 0 64H

PORT B [ {DL1 - DL8}………0 - GREEN & 1 – RED ]

D20 D19 D18 D17 DL78 DL56 DL34 DL12

POSITION

10 0 1 0 1 1 1 0

2EH

50

Page 51: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

POSITION

21 0 0 1 1 1 0 1

9DH

POSITION

30 0 1 0 1 0 1 1

2BH

POSITION

40 0 1 0 0 1 1 1

27H

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

D16 D15 D14 D13 D12 D11 D10 D9

POSITION

10 1 0 0 1 1 0 0

4CH

POSITION

21 0 0 1 0 0 0 0

90H

POSITION

30 0 0 1 0 0 0 0

10H

POSITION

40 0 0 1 0 0 1 0

12H

51

Page 52: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus the assembly language program to interface traffic light

controller with 8085 using 8255 was written and executed successfully.

TIMER INTERFACE WITH 8085 USING 8251AIM

To write an assembly language program to timer interface with 8085

using 8251.

APPARATUS REQUIRED8085 Microprocessor kit, Power chord, keyboard/display interface board.

ALGORITHM1. Find the control words for 8279 and data corresponding to the key and load

this data in to the memory location.2. Move the control word to accumulator and place in 8279.

3. Clear all the display

4. Scan the key board continuously.

5. If any key pressed go to next step else go to step 4.

6. Find the display value for the pressed key.

52

Page 53: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

7. Move this value to the display board

8. Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 LXI H,CLEAR 21 50 41

4103 MVI B,08 16 08

4105 MVI A,10H 3E 10

4107 OUT CNT D3 C2

4109 MVI A,CC 3E,CC

410B OUT CNT D3 C2

410D MVI A,90H 3E,90

410F OUT CNT D3 C2

4111 MOV A,M 7E

4112 BACK OUT DAT D3 C0

4114 INX H 23

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

53

Page 54: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4123 MVI H,82H 26 82

4126 MOV A,M 7E

4127 OUT DAT D3 C0

4128 JMP LOOP C3 19 41

4129 HLT

4150 FF FF FF FF

FF FF FF FF

8200 0C 9F 4A 0B

99 29 28 8F

08 89 88 38

6C 1A 68 E8

RESULT

Thus the assembly language program to timer interface with 8085

using 8251 was written and executed successfully.

KEYBOARD/DISPLAY INTERFACE WITH 8085 USING 8279AIM

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

4. Scan the key board continuously.

54

Page 55: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. If any key pressed go to next step else go to step 4.

6. Find the display value for the pressed key.

7. Move this value to the display board and Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 LXI H,CLEAR 21 50 41

4103 MVI B,08 16 08

4105 MVI A,10H 3E 10

4107 OUT CNT D3 C2

4109 MVI A,CC 3E,CC

410B OUT CNT D3 C2

410D MVI A,90H 3E,90

410F OUT CNT D3 C2

4111 MOV A,M 7E

4112 BACK OUT DAT D3 C0

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

55

Page 56: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4121 MOV L,A 6F

4123 MVI H,82H 26 82

4126 MOV A,M 7E

4127 OUT DAT D3 C0

4128 JMP LOOP C3 19 41

4129 HLT

4150 FF FF FF FF

FF FF FF FF

4200 0C 9F 4A 0B

99 29 28 8F

08 89 88 38

6C 1A 68 E8

RESULT

Thus the assembly language program to interface keyboard/display

board with 8085 using 8279 was written and executed successfully.

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

56

Page 57: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4. Scan the key board continuously.

5. If any key pressed go to next step else go to step 4.

6. Find the display value for the pressed key.

7. Move this value to the display board and Stop.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

4100 LXI H,CLEAR 21 50 41

4103 MVI B,08 16 08

4105 MVI A,10H 3E 10

4107 OUT CNT D3 C2

4109 MVI A,CC 3E,CC

410B OUT CNT D3 C2

410D MVI A,90H 3E,90

410F OUT CNT D3 C2

4111 MOV A,M 7E

4112 BACK OUT DAT D3 C0

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

57

Page 58: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4120 ANI 0FH E6 0F

4121 MOV L,A 6F

4123 MVI H,82H 26 82

4126 MOV A,M 7E

4127 OUT DAT D3 C0

4128 JMP LOOP C3 19 41

4129 HLT

4150 FF FF FF FF

FF FF FF FF

8200 0C 9F 4A 0B

99 29 28 8F

08 89 88 38

6C 1A 68 E8

RESULT

Thus the assembly language program to timer interface with 8085

using 8254 was written and executed successfully.

ADDITION OF TWO 16-BIT NUMBERS USING 8085

AIMTo write an assembly language program to add the two 16-bit

numbers using microprocessor instruction set.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord.

ALGORITHM

1. Initialize memory pointer to data location.

2. Get the first number from memory and store in Register pair.

3. Get the second number in memory and add it to the Register pair.

58

Page 59: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

1000 START LHLD 2000H

1005 XCHG

1008 LHLD 2002H

1000 MVI A, 00H

1005 DAD D

1008 JNC LOOP

1000 INR A

1005 LOOP SHLD 3000H

1008 STA 3002H

1009 HLT

OBSERVATION

INPUT OUTPUT

Address Data Address Data

2000 04H 3000 06H (Sum)

2001 04H 3001 06H (Sum)

2002 02H3002 00 (Carry)

2004 02H

59

Page 60: CS 2259-MICROPROCESSOR LABORATORY

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.

SUBTRACTION OF TWO 16-BIT NUMBERS USING 8085AIM

To write an assembly language program to subtract the two 16-bit

numbers using microprocessor simulator tool.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord.

ALGORITHM

1. Initialize memory pointer to data location.

2. Get the subtrahend from memory and transfer it to register pair.

3. Get the minuend from memory and store it in another register pair.

4. Subtract subtrahend from minuend.

60

Page 61: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Store the difference and borrow in different memory locations.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

1000 START MVI C, 00

1008 LHLD 2000H

1000 XCHG

1005 LHLD 2002H

1008 MOV A, L

1000 SUB E

1005 MOV L, A

1008 MOV A, H

1009 SBB D

1000 MOV H, A

1008 SHLD 3000H

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)

61

Page 62: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

2001 04H 3001 02H (Difference)

2002 02H3002 00H (Borrow)

2004 02H

RESULT

Thus the assembly language program to subtract the two 16-bit

numbers using 8085 simulator tool was written and executed successfully.

MULTIPLICATION OF TWO 16-BIT NUMBERS USING 8085

AIMTo write an assembly language program to multiply the two 16-bit

numbers using microprocessor simulator tool.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord.

ALGORITHM

1. Get the multiplier and multiplicand.

2. Initialize a register to store partial product.

3. Add multiplicand, multiplier times.

4. Store the result in consecutive memory locations.

62

Page 63: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

1000START LHLD 2000H

1008SPHL

1000LHLD 20002

1005XCHG

1008LXI H, 0000H

1000LXI B, 0000H

1005DAD SP

1008JNC NEXT

1009INX B

1000NEXT DCX D

1008MOV A,E

1000ORA D

1005JNZ LOOP

1008SHLD 3000H

1005MOV A, C

1008STA 3001H

1008MOV A, B

1005STA3002H

63

Page 64: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

1008HLT

OBSERVATION

INPUT OUTPUT

Address Data Address Data

2000 04H 3000 08H (Multiply)

2001 04H 3001 08H (Multiply)

2002 02H3002 00H (Carry)

2004 02H

RESULT

Thus the assembly language program to multiply the two 16-bit

numbers using 8085 simulator tool was written and executed successfully.

DIVISION OF TWO 16-BIT NUMBERS USING 8085

AIMTo write an assembly language program to divide the two 16-bit

numbers using microprocessor simulator tool.

APPARATUS REQUIRED

8085 Microprocessor kit, Power chord.

ALGORITHM

1. Get the dividend and divisor.

2. Initialize the register for quotient.

3. Repeatedly subtract divisor from dividend till dividend becomes

less than divisor.

4. Count the number of subtraction which equals the quotient.

64

Page 65: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

5. Store the result in memory.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

1000 START LHLD 3000H

1008 XCHG

1000 LHLD 3002H

1005 LXI B, 0000H

1008 MOV A, L

1000 SUB E

1005 MOV L, A

1008 MOV A, H

1009 SBB D

1000 MOV H, A

1008 LOOP INX B

1000 JNC LOOP

1005 DCX B

1008 DAD D

1005 SHLD 3000H

1008 MOV A, C

1008 STA 3001H

1005 MOV A, B

1008 STA 3002H

1009 HLT

OBSERVATION

65

Page 66: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INPUT OUTPUT

Address Data Address Data

2000 04H 3000 02H (Quotient)

2001 04H 3001 02H (Quotient)

2002 02H3002 00H (Remainder)

2004 02H

RESULT

Thus the assembly language program to divide the two 16-bit numbers

using 8085 simulator tool was written and executed successfully.

66

Page 67: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS

(USING 8086)

A-ADDITION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS1000 MOV AX,[1100] A1,00,11 MOVE THE DATA TO

ACCUMULATOR

1003 ADD AX,[1102] 03,06,02,11 ADD MEMORY CONTENTWITH ACCUMULATOR

1007 MOV [1200],AX A3,00,12 MOVE ACCUMULATORCONTENT TO MEMORY

67

Page 68: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100A HLT F4 STOP

OUT PUT:

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS

(USING 8086)

B-SUBTRACTION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS1000

1003

1007

100A

MOV AX[1100]

SUB AX[1102]

MOV [1200],AX

HLT

A1,00,11

2B,06,02,11

A3,00,12

F4

MOVE THE DATA TO ACCUMULATOR

SUBTRACT MEMORY CONTENT WITH ACCUMULATOR

MOVE ACCUMULATOR CONTENT TO MEMORY

STOP

OUT PUT ADDRESS

DATA

1200 041201 04

IN PUT ADDRESS

DATA

1100 021101 021102 021103 02

68

Page 69: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OUT PUT:

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS

(USING 8086)

C-MULTIPLICATION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS 1000

1003

1007

100B

MOV AX[1100]

MUL[1102]

MOV [1200],DX

MOV[1202],AX

A1,00,11

F7,26,02,11

87,16,00,12

A3,02,12

MOVE THE DATA TO ACCUMULATOR

MULTIPLY MEMORY CONTENT WITH ACCUMULATOR

MOVE ACCUMULATOR CONTENT TO AX REGISTER

MOVE ACCUMULATOR

OUT PUT ADDRESS

DATA

1200 021201 02

IN PUT ADDRESS

DATA

1100 041101 021102 041103 02

69

Page 70: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100E HLT F4

CONTENT TO DX REGISTER

STOP

OUT PUT:

PROGRAMS FOR 16 BIT ARITHMETIC OPERATIONS

(USING 8086)

D-DIVISION OF TWO 16-BIT NUMBERS

ADDRESS MNEMONICS OP-CODE COMMANDS1000

1003

1007

MOV AX[1100]

DIV[1102]

MOV [1200],DX

A1,00,11

F7,36,02,11

87,16,00,12

MOVE THE DATA TO ACCUMULATOR

DIVIDE MEMORY CONTENT WITH ACCUMULATOR

MOVE ACCUMULATOR CONTENT TO DX REGISTER

OUT PUT ADDRESS

DATA

1200 001201 041202 081203 04

IN PUT ADDRESS

DATA

1100 021101 021102 021103 02

70

Page 71: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100B

100E

MOV[1200],AX

HLT

A3,00,12

F4

MOVE CONTENT OF AXREGISTER TO MEMORY

STOP

OUT PUT:

INTERFACING ADC AND DAC

(I) PROGRAM FOR ANALOG-DIGITAL CONVERTER

MEMORY ADDRESS

MNEMONICS OPCODE COMMENTS

1000 MOV AL,03 B0, 03

Move to accumulator

1002 OUT C8,AL E6, C8move the value to register

1004 MOV AL,23 B0, 23move the value to B0

1006 OUT C8,AL E6, C8move the value to main memory

1008 MOV AL,03 B0, 03Move the value from main memory to accumulator

100A OUT C8,AL E6,C8move the value to main memorymove to register

OUT PUT ADDRESS

DATA

1200 021201 021202 001203 00

IN PUT ADDRESS

DATA

1100 041101 041102 021103 02

71

Page 72: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100C MOV AL,01 B0, 01

100E OUT DO, AL E6, D0move to memory

1010 MOV AL,00 B0, 00Move to accumulator

1012 OUT D0,AL E6, D0Move from accumulator. to register

1014 LOOP IN AL E0 E4 ,E0increment the value

1016 AND AL,01 24, 01move to register

1018 CMP AL,01 3C ,01Compare the value of accumulator. an memory

101A JNZ LOOP 75, F8jump no zero

101C IN AL,C0 E4, C0increment loop condition

101E MOV BX,1100 BB,00,11move to memory

1021 MOV[BX],AL 88, 07move to register

1023 HLT F4stop

IN PUT:IN PUT ANALOG VOLTAGE

OUT PUT DIGITAL DATA

5V FF [1100]

72

Page 73: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INTERFACING ADC AND DAC

PROGRAM FOR DIGITAL- ANALOG CONVERTER

GENERATION OF SAWTOOTH WAVE

MEMORY ADDRESS

LABEL MNEMONICS OPCODE COMMENTS

1000 START MOV AL, 00 B0,00 move to AL reg

1002 L1 OUT C0,AL E6 ,C0 move to CO

1004 INC AL FE ,C0 increment AL register

1006 JNZ L1 75, FA jump no carry

1008 JMP START EB ,F6 jump to start

73

Page 74: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100A RET C3 Return

INTERFACING ADC AND DAC

PROGRAM FOR DIGITAL- ANALOG CONVERTERB- GENERATION OF SQUARE WAVE

MEMORY ADDRESS

LABEL MNEMONICS OPCODE COMMENTS

1000START

MOV AL,00 B0,00move to AL reg.

1002 OUT C8,AL E6 ,C8 move to C8

1004 CALL DELAY E8 ,09 ,00 call the delay

1007 MOV AL,FF B0, FFmove to FF reg.

1009 OUT C8, AL E6 ,C8 move to C8

100B CALL DELAY E8 ,02 ,00 call the delay

74

Page 75: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100E JMP START EB,F0 jump to start

1010 DELAY MOV CX, 05, FF

B9, FF, 05 declare the data to accumulator

1013 L1 LOOP L1 E2 ,FE move to loop

1015 RET C3 return

INTERFACING ADC AND DAC

PROGRAM FOR DIGITAL- ANALOG CONVERTERC- GENERATION OF TRIANGULAR WAVE

MEMORY ADDRESS

LABEL MNEMONICS OPCODE COMMENTS

1000START MOV BL,00

B3,00 Move to accumulator

1002 L1 MOV AL,BL 88,D8move to BL reg

1004 OUT C8,AL E6,C8move to C8

1006 INC BL FE,C3increment value

of BL reg.

1008 JNZ L1 75,F8jump no zero

100A MOV BL,FF B3,FFmove to FF reg.

75

Page 76: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100C L2 MOV AL,BL 88,D8Move to

accumulator.

100E OUT C8,AL E6,C8move to C8

1010 DEC BL FE,CBdecrement value

of BL reg.

1012 JNC L2 75,F8jump no carry

1014 JMP START EB,EAjump start

1016 RET C3return

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

76

Page 77: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

I/O MODES:

Control Word:

TRANSMITTER PROGRAM:

ADDRESS LABEL MNEMONICS OPCODES1000 MOV AL,80 B0 801002 OUT 0F,AL E6 0F1004 MOV AL,05 (DATA) B0 051006 OUT 0C,AL E6 0C1008 HLT F4

RECEIVER PROGRAM:

ADDRESS LABEL MNEMONICS OPCODES1000 MOV AL,90 B0 901002 OUT 0F,AL E6 0F1004 IN AL 0C E4 0C1006 MOV BX[1250] BB 50 12

77

Page 78: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

1009 MOV BX AL 88 07100B HLT F4

INTERFACING AND PROGRAMMING 8279, 8259, AND 8253INTERFACING OF 8279

ROLLING DISPLAY (DISPLAY MESSAGE IS ECE- b)

ADDRESS LOOP MNEMONICS OP-CODE COMMANDS1000 START MOV SI,1200 BE 00 12 SET MODE

COUNT AND DISPLAY

1003 MOV CX,000F B9 0F 00 MOVE 000F DATA IN CX

1006 MOV AL,10 B0 10 SET ACC DATA1008 OUT C2,AL E6 C2 CLEAR DISPLAY100A MOV AL,CC B0 CC MOVE CC DATA

IN AL100C OUT C2,AL E6 C2 SET PORT DATA

78

Page 79: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100E MOV AL,90 B0 90 WRITE DISPLAY1010 OUT C2,AL E6,C2 CLEAR DISPLAY

IN RAM1012 NEXT MOV AL,[SI] 8A 04 LOP FOR THE

PRESSING OF KEY

1014 OUT CO,AL E6 C0 SET TO READ FIFO RAM

1016 CALL DELAY E8 E7 04 CALL DISPLAY DATA

1019 INC SI 46 GET THE CORRESPONDING CODE FORM LOOKUP TABLE

101A LOOP NEXT E2 F6 GO TO NEXT101C JMP START EB E2 JUMP START

SUB PROGARM:

ADDRESS LOOP MNEMONICS OP-CODE COMMANDS

1500 DELAY MOV DX,A0FF BA FF 0A MOVE THE VALUE TODX REGISTER

1503 DEC DX 4A DECREMENT DX

1504 JNZ LOOP1 75 FD JUMP NO ZERO

1506 RET C3 RETURN

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.

79

Page 80: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING 8279, 8259, AND 8253INTERFACING OF 8259 IN SPECIAL MASK MODE

ADDRESS LOPP MNEMONICS OP-CODE COMMANDS1200 MOV AL,FD BO FD MOVE DATA TO

ACCUMULATOR1202 OUT C2,AL E6 C2 SEND VALUE

TO OUTPUT PORT

1204 INT 2 CD 02 INTERUPT

ORG 10001000 MOV

C2,AL(17)B0 17 MOVE DATA TO

ACCUMULATOR1002 OUT C2,AL E6 C0 SEND VALUE

TO

80

Page 81: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OUTPUT PORT1004 MOV

C2,AL(08)B0 08 MOVE DATA TO

ACCUMULATOR1006 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

1015 JMP HERE EB FE JUMP HERE

Press the switch IRO. The CPU control is transferred to ISR. Since no EOI

command is given the 8259 will not accept further interrupts. However due

to special mask mode, 8259 will accept interrupt only at IRI.

VECTORED INTERUPT:ADDRESS DATA0020 000021 120022 000023 00

81

Page 82: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING 8279, 8259, AND 8253GENERATION OF SQUARE WAVE USING 8253

ADDRESS MNEMONICS OPCODE COMMAND1000 ORG 100H

MOV AL,36B0 36 MOVE THE

VALUE TOACCUMULATOR

1002 OUT CE,AL E6 CE SEND DATA TO THEOUTPUT PORT

1004 MOV AL,10 B0 10 MOVE THE VALUE TOACCUMULATOR

1006 OUT C8,AL E6 C8 SEND DATA TO THEOUTPUT PORT

1008 MOV AL.00 B0 00 MOVE THE VALUE TO

82

Page 83: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

ACCUMULATOR100A OUT C8,AL E6 C8 SEND DATA TO

THEOUTPUT PORT

100C HLT F4 HALT

SERIAL COMMUNICATION BETWEEN TWO MP KITS USING 8251TRANSMITTER PROGRAM

ADDRESS MNEMONICS OP-CODE COMMANDS1000 MOV AL,36 BO 36 MOVE THE VALUE

TOACCUMULATOR

1002 OUT CE,AL E6 CE SEND DATA TO OUTPUT PORT

1004 MOV AL,10 B0 10 MOVE THE VALUE TOACCUMULATOR

1006 OUT C8,AL E6 C8 SEND DATA TO OUTPUT PORT

1008 MOV AL,00 B0 00 MOVE THE VALUE TOACCUMULATOR

100A OUT C8,AL E6 C8 SEND DATA TO

83

Page 84: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OUTPUT PORT100C MOV AL,4E B0 4E MOVE THE VALUE

TOACCUMULATOR

100E OUT C2,AL E6 C2 SEND DATA TO OUTPUT PORT

1010 MOV AL,37 B0 37 MOVE THE VALUE TOACCUMULATOR

1012 OUT C2,AL E6 C2 SEND DATA TO OUTPUT PORT

1014 MOV AL,AA BO AA MOVE THE VALUE TOACCUMULATOR

1016 OUT CO,AL E6 CO SEND DATA TO OUTPUT PORT

1018 INT 02 CD 02 INTERUPT

RECEIVER PROGRAM

ADDRESS MNEMONICS OP-CODE COMMANDS1200 IN AL,C0 E4 C0 INTERUPT

1202 MOV BX[1250] BB 50 12 MOVE THE VALUE TO ADDRESS

1205 MOV BX,AL 88 07 MOVE ACCUMULATORDATA TO BX

1207 INT 02 CD 02 INTERUPT

84

Page 85: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING OF STEPPER MOTORSTEPPER MOTOR INTERFACING

AIMTo write an assembly language program to interface stepper motor

with 8086.

APPARATUS REQUIRED

8086 Microcontroller kit, Power chord, stepper motor, stepper motor interface board

THEORYA motor in which the rotor is able to assume only discrete stationary

angular position is a stepper motor. The rotary motion occurs in a step-wise

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

85

Page 86: CS 2259-MICROPROCESSOR LABORATORY

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 SCHEMEIn this scheme, any two adjacent stator windings are energized. The

switching scheme is shown in the table given below. This scheme produces

more torque.

ANTICLOCKWISE CLOCKWISE

STEP

A1

A2 B1

B2 DATA STEP

A1

A2

B1

B2 DATA

1 1 0 0 1 9h 1 1 0 1 0 Ah2 0 1 0 1 5h 2 0 1 1 0 6h3 0 1 1 0 6h 3 0 1 0 1 5h4 1 0 1 0 Ah 4 1 0 0 1 9h

ADDRESS DECODING LOGICThe 74138 chip is used for generating the address decoding logic to

generate the device select pulses, CS1 & CS2 for selecting the IC 74175.The

74175 latches the data bus to the stepper motor driving circuitry.

Stepper Motor requires logic signals of relatively high power.

Therefore, the interface circuitry that generates the driving pulses uses

86

Page 87: CS 2259-MICROPROCESSOR LABORATORY

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.

A-TO RUN STEPPER MOTOR AT DIFFERENT SPEED

MEMORY ADDRESS

LABEL MNEMONICS OPCODE

1000 START MOV D1 offset table (1014)

BF,14,10

1003 MOV CL, 04 B1,04

1005 LOOP1 MOV AL,[D1] 8A,05

1007 OUT PORT1,AL

E6,C0

1009 MOV DX,1010 BA,10,10

100C DELAY DEC DX 4A

100D JNZ DELAY 75,FD

87

Page 88: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100F INC D1 47

1010 LOOP LOOP1 E2,F3

1012 JMP START EB,EC

1014 TABLE DB 09,05,06,0A

B-TO RUN STEPPER MOTOR AT FORWARD AND REVERSE DIRECTIONMEMORY ADDRESS

LABEL MNEMONICS OPCODE

1000 START MOV BL 20H B3,20

1002 FORWD MOV D1,OFFSET FORW (1037)

BF,37,10

1005 CALL ROTATE E8,18 00

1008 DEC BL FE CB

100A JNZ FORWARD 75 F6

100C CALL DELAY E8 21 00

100F MOV BL 20 B3 20

88

Page 89: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

1011 REVER MOV D1 ,OFFSET REV (103B)

BF 3B 10

1014 CALL ROTATE E8 09 00

1017 DEC BL FE CB

1019 JNZ REVER 75 F8

101B CALL DELAY E8 12 00

101E JMP START EB E0

1020 ROTATE MOV CL,04 B1 04

1022 REPT MOV AL,[D1] 8A 05

1024 OUT PORT1,AL E6 C0

1026 MOV DX,1010 BA 10,10

MEMORY ADDRESS

LABEL MNEMONICS OPCODE

1029 DEC BX 4A

102A LOOP L1 JNZ LOOP 1 75 FD

102C INC D1 47

102D LOOP REPT E2 F3

102D RET C3

102F MOV DX FFFF BA FF, FF

1030 DEC DX 4A

1033 DELAY JNZ DELAY 75 FD

89

Page 90: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

1036 RET C3

1037 FORW DB 09 05 06 0A103B REV DB 0A 06 05 09

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:

90

Page 91: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

MODE 0 – SIMPLE I/O MODE:

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 LABEL MNEMONICS OPCODES1000 MOV SI , 1500 BE 00 151003 MOV AL,90 B0 901005 OUT C6,AL E6 C61007 IN AL,C0 E4 C01009 MOV [SI], AL 88 04100B HLT F4

MODE 0 STROBED I/O MODE:

Let us initialize port A as input port and port B as output port

91

Page 92: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM:

ADDRESS LABEL MNEMONICS OPCODES1000 MOV AL,90 B0 901002 OUT C6,AL E6 C61004 IN AL,C0 E4 C01006 OUT C2 AL E6 C21008 HLT F4

92

Page 93: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT:

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

93

Page 94: CS 2259-MICROPROCESSOR LABORATORY

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

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

DATA ENDS

CODE SEGMENT

START: MOV AX, DATA

MOV DS, AX

MOV AH, 09H

MOV DX, OFFSET MSG

94

Page 95: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INT 21H

MOV AH, 4CH

INT 21H

CODE ENDS

END START

RESULT:

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 ENDSCODE SEGMENTSTART: MOV AX, DATA

MOV DS, AX

MOV DX, OFFSET FILENAME

MOV AH, 3CH

INT 21H

MOV AH, 4CH

INT 21H

CODE ENDS

END START

95

Page 96: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT:

96

Page 97: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

BIOS/DOS CALLS – KEYBOARD CONTROL

AIM:

To interface a keyboard using DOS calls.

ALGORITHM:

1. Initialize the data segment, file name and the message to be displayed.2. Set the file attribute to create a file using a DOS call.3. If the file is unable t o create a file display the message

PROGRAM:

.Datamesg db 'Ten seconds have passed!',0Dh, 0Ah,'$'.Code;; pmesg - Prints the message pointed to by the DX register on the screen.;pmesg PROCmov ah, 09h ;DOS Print to screen function.int 21h ;Call DOS.ret ;Return after printing.pmesg ENDP;Test our procedure for printing a message.start: mov ax, @Data ;We're using the data segment now so wemov ds, ax ; need to initialize it!mov dx, offset mesg;Point DX at the message.call pmesg ;Print the message on the screen.call pmesg ; a few times.call pmesg ;mov ax, 4C00h ;DOS Exit function call, return code 0.int 21h ;Call DOS to exit.end start

RESULT:

97

Page 98: CS 2259-MICROPROCESSOR LABORATORY

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

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

DATA ENDS

CODE SEGMENT

START: MOV AX, DATA

MOV DS, AX

MOV AH, 36H

MOV DX, OFFSET MSG

INT 21H

MOV AH, 4CH

INT 21H

CODE ENDS

END START

RESULT:

98

Page 99: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

99

Page 100: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

100

Page 101: CS 2259-MICROPROCESSOR LABORATORY

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

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

101

Page 102: CS 2259-MICROPROCESSOR LABORATORY

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:

102

Page 103: CS 2259-MICROPROCESSOR LABORATORY

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

103

Page 104: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

DEC CL

JNZ AGAIN

MOV SI,OFFSET LARGEST

MOV [SI],AL

MOV AH,4CH

INT 21H

CODE ENDS

END START

104

Page 105: CS 2259-MICROPROCESSOR LABORATORY

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

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

105

Page 106: CS 2259-MICROPROCESSOR LABORATORY

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

106

Page 107: CS 2259-MICROPROCESSOR LABORATORY

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

107

Page 108: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

108

Page 109: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER

EX NO: aDATE:

ADDITION OF TWO 8-BIT NUMBERS USING 8051

AIMTo write an assembly language program to add the two 8-bit numbers

using microcontroller instruction set.

APPARATUS REQUIRED1. 8051 Microcontroller kit2. Power chord.

ALGORITHM

1. Clear C-register for carry.

2. Move the first data to Accumulator.

3. Add the second data with Accumulator.

4. Store the sum in memory pointed by DPTR.

PROGRAM

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODECOMMENTS

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

109

Page 110: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6109 LOOP SJMP LOOP 80, FE

OBSERVATION

INPUT OUTPUT

Address Data Address Data

61026500

6103

RESULT

110

Page 111: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

using 8051 instruction set was written and executed successfully.

1. PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER

EX NO: bDATE:

SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051

AIMTo write an assembly language program to subtract the two 8-bit

numbers using microcontroller instruction set.

APPARATUS REQUIRED

1. 8051 microcontroller kit

2. Power chord.

ALGORITHM

1. Clear C-register for carry.

2. Move the first data to Accumulator.

3. Subtract the second data with Accumulator.

4. Store the sum in memory pointed by DPTR.

PROGRAM

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODE COMMENTS

6100 CLR C C3

6101 MOV A,#data1 74, 04

6103 SUBB A, #data2 94, 02

6105 MOV DPTR, #6500H 90, 65, 00

111

Page 112: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6108 MOVX @DPTR, A F0

6109 LOOP SJMP LOOP 80, FE

OBSERVATION

INPUT OUTPUT

Address Data Address Data

61026500

6103

RESULT

112

Page 113: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

Thus, the assembly language program to subtract the two 8-bit

numbers was written and executed successfully.

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER

EX NO: cDATE:

MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8051

AIMTo write an assembly language program to multiply the two 8-bit

numbers using microcontroller instruction set.

APPARATUS REQUIRED

1. 8051 Microcontroller kit

2. Power chord.

ALGORITHM

1. Clear C-register for carry.

2. Move the first data to Accumulator.

3. Move the second data to B-register.

4. Multiply the second data with Accumulator.

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

6. The lower order of the result is in Accumulator.

7. Store the sum in memory pointed by DPTR.

113

Page 114: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODE COMMENTS

6100 CLR C C3

6101 MOV A,#data1 74, 04

6103 MOV B,#data2 75, F0, 02

6106 MUL AB A4

6107 MOV DPTR, #6500H 90, 65, 00

610A MOVX @DPTR, A F0

610B INC DPTR A3

610C MOV A, B E5, F0

610E MOVX @DPTR, A F0

610F LOOP SJMP LOOP 80, FE

114

Page 115: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6102 6500

6103 6501

115

Page 116: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

RESULT

Thus, the assembly language program to multiply the two 8-bit

numbers using 8051 instruction set was written and executed

PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051 MICROCONTROLLER

EX NO: dDATE:

DIVISION OF TWO 8-BIT NUMBERS USING 8051AIM

To write an assembly language program to divide the two 8-bit

numbers using microcontroller instruction set.

APPARATUS REQUIRED

1. 8051 Microcontroller kit

2. Power chord.

ALGORITHM

1. Clear C-register for carry.

2. Move the first data to Accumulator.

3. Move the second data to B-register.

4. Multiply the second data with Accumulator.

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

6. The quotient of the result is in Accumulator.

7. Store the sum in memory pointed by DPTR.

116

Page 117: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODE COMMENTS

6100 CLR C C3

6101 MOV A,#data1 74, 08

6103 MOV B,#data2 75, F0, 02

6106 DIV AB 84

6107 MOV DPTR, #6500H 90, 65, 00

610A MOVX @DPTR, A F0

610B INC DPTR A3

610C MOV A, B E5, F0

610E MOVX @DPTR, A F0

610F LOOP SJMP LOOP 80, FE

OBSERVATION

INPUT OUTPUT

117

Page 118: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

ONE’S AND TWO’S COMPLEMENT USING 8051AIM

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

complement of an 8-bit number using microcontroller instruction set.

APPARATUS REQUIRED

1. 8051 Microcontroller kit

2. Power chord.

ALGORITHM

1. Move the data to Accumulator.

2. Complement the accumulator.

3. Move the one’s complement output to the memory 6500H.

4. Add 01H with accumulator.

5. Move the two’s complement output to the memory 6501H. PROGRAM

118

Page 119: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODE COMMENTS

6100 MOV A, #data 74, CC

6101 CPL A F4

6103 MOV DPTR, #6500H 90, 65, 00

6106 MOVX @DPTR, A F0

6107 INC A 04

610A INC DPTR A3

610B MOVX @DPTR, A F0

610C LOOP SJMP LOOP 80, FE

OBSERVATION

INPUT OUTPUT

Address Data Address Data

61016500

6501

119

Page 120: CS 2259-MICROPROCESSOR LABORATORY

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

SETTING BITS IN AN 8 BIT NUMBERS USING 8051AIM

To write an assembly language program to find the Setting bits an

8-bit number using microcontroller instruction set.

APPARATUS REQUIRED

1. 8051 Microcontroller kit

2. Power chord.

ALGORITHM

1. Move the data to Accumulator.

2. Perform OR operation with accumulator.

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

PROGRAM

120

Page 121: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODE COMMENTS

6100 MOV A, #data1 74, 2F

6102 ORL A, #data2 44, 7E

6104 MOV DPTR, #6500H 90, 65, 00

6107 MOVX @DPTR, A F0

6108 LOOP SJMP LOOP 80, FE

OBSERVATION

INPUT OUTPUT

Address Data Address Data

61016500

6103

121

Page 122: CS 2259-MICROPROCESSOR LABORATORY

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

MASKING BITS IN AN 8 BIT NUMBERS USING 8051AIM

To write an assembly language program to find the Masking bits an

8-bit number using microcontroller instruction set.

APPARATUS REQUIRED

1. 8051 Microcontroller kit

2. Power chord.

ALGORITHM

1. Move the data to Accumulator.

2. Perform AND operation with accumulator.

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

122

Page 123: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

PROGRAM

MEMOR

Y

ADDRESS

LABEL MNEMONICS OP CODE COMMENTS

6100 MOV A, #data1 74, 2F

6102 ANL A, #data2 54, 7E

6104 MOV DPTR, #6500H 90, 65, 00

6107 MOVX @DPTR, A F0

6108 LOOP SJMP LOOP 80, FE

OBSERVATION

INPUT OUTPUT

Address Data Address Data

61016500

6103

123

Page 124: CS 2259-MICROPROCESSOR LABORATORY

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.

PROGRAMS FOR SORTING AND SEARCHING (USING 8051)

EX NO: aDATE:

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 KitALGORITHM

1. Load the count value from memory to A-register and store it in B-

register.

2. Decrement B-register (B is a count for (N-1) repetitions).

3. Set HL pair as data address pointer.

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

124

Page 125: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

ADDRESSLABEL MNEMONICS OP CODE

6100 MOV R3, #04H 7B, 04

6102 MOV R4, #04H 7C, 04

6104 MOV DPTR, #6500H 90, 65, 00

6107 LOOP1 MOV R5, DPL AD, 82,

6109 MOV R6, DPH AE, 83

610B MOVX A, @DPTR E0

610C MOV B,A F5, F0

610E LOOP INC DPTR A3

125

Page 126: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

610F MOVX A, @DPTR E0

6110 MOV R0, A F8

6111 CLR C C3

6112 SUBB A, B 95, F0

6114 JNC LOOP2 50,13

6116 EXCH PUSH DPL C0, 82

6118 PUSH DPH C0, 83

611A MOV DPL, R5 8D, 82

611C MOV DPH, R6 8E, 83

611E MOV A, R0 E8

611F MOVX A, @DPTR E0

6120 POP DPH D0, 83

6122 POP DPL D0, 82

6124 MOV A, B E5, F0

6126 MOVX @DPTR, A F0

6127 MOV B, R0 88, FO

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

126

Page 127: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OBSERVATION

INPUT

(Before sorting)

OUTPUT

(After sorting)

Address Data Address Data

6500 05H 6500 05H

6501 0AH 6501 03H

6502 0CH 6502 06H

6503 06H 6503 08H

6504 03H 6504 0AH

6505 08H 6505 0CH

RESULT

Thus, the assembly language program to sort an array of data in ascending order

using 8051 simulator tools was written and executed successfully.

PROGRAMS FOR SORTING AND SEARCHING (USING 8051)

EX NO: bDATE: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 KitALGORITHM

1. Load the count value from memory to A-register and store it in B-

register.

2. Decrement B-register (B is a count for (N-1) repetitions).

3. Set HL pair as data address pointer.

127

Page 128: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

ADDRESSLABEL MNEMONICS OP CODE

6100 MOV R3, #04H 7B, 04

6102 MOV R4, #04H 7C, 04

6104 MOV DPTR, #6500H 90, 65, 00

6107 LOOP1 MOV R5, DPL AD, 82,

6109 MOV R6, DPH AE, 83

610B MOVX A, @DPTR E0

610C MOV B,A F5, F0

610E LOOP INC DPTR A3

610F MOVX A, @DPTR E0

128

Page 129: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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

129

Page 130: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

OBSERVATION

INPUT

(Before sorting)

OUTPUT

(After sorting)

Address Data Address Data

6500 05H 6500 05H

6501 0AH 6501 0CH

6502 0CH 6502 0AH

6503 06H 6503 08H

6504 03H 6504 06H

6505 08H 6505 03H

RESULT

Thus the assembly language program to sort an array of data in descending

order using 8051 simulator tools was written and executed successfully.

PROGRAMS FOR SORTING AND SEARCHING (USING 8051)

EX NO: c

DATE:LARGEST ELEMENT IN AN ARRAY

AIM

To write an assembly language program to find the largest number in

an array using 8051 simulator tools.

APPARATUS REQUIRED

8051 Microcontroller kit,

Power chord

ALGORITHM

1. Clear C-register for carry.

130

Page 131: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

2. Move the first data from memory to accumulator and move it to B-

register.

3. Move the second data from memory to accumulator.

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

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

6. Increment the C-register

7. Store the sum in memory.

8. Move the carry to accumulator and store in memory.

PROGRAM

MEMORY

ADDRESSLABEL MNEMONICS OP CODE

6100 MOV DPTR,#6500 90, 65, 00

6103 MOV 40,#00 75, 40, 00

6106 MOV R5,#05 7D, 05

6108 LOOP2 MOVX A,@DPTR E0

6109 CJNE A,40H,LOOP1 B5, 40, 08

610C LOOP3 INC DPTR A3

610D DJNZ R5, LOOP2 DD, F9

131

Page 132: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

610F MOV A, 40H E5, 40

6111 MOVX @DPTR,A F0

6112 HLT SJMP HLT 80, FE

6114 LOOP1 JC LOOP3 40, F6

6116 MOV 40H,A F5, 40

6118 SJMP LOOP3 80, F2

OBSERVATION

INPUT OUTPUT

Address Data Address Data

6500 04H

6500 0AH

6501 08H

6502 02H

6503 0AH

6504 06H

132

Page 133: CS 2259-MICROPROCESSOR LABORATORY

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

4000 MOV DPTR,#FFC2 90 FF C2

4003 MOV R0,#00 78 004005 MOV R1,#44 79 444007 MOV A,#10 74 104009 MOVX@DPTR,A F0400A MOV A,#CC 74 CC400C MOVX@DPTR,A F0400D MOV A,#90 74 90401F MOVX@DPTR,A F04010 LOOP MOV DPH,R1 89 834012 MOV DPL,R0 88 82

133

Page 134: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4014 MOVX@DPTR E04015 MOV DPTR,FFC0 90 FF C0

4018 MOVX@DPTR,A F04019 LCALL DELAY 12 45 00401C INC R0 08401D CJNE R0,#0F,LOOP B8 0F F0

401A LJMP START 02 81 00

ORG 4500

ADDRESS LABEL MNEMONICS OP-CODE

4500 MOV R4,#A0 7C A04502 LOOP2 MOV R5,#FF 7D FF4504 LOOP1 NOP 004505 DJNZ R5,LOOP1 DD FD

4507 DJNZ R4,LOOP2 DC F9

4509 RET 22

LOOK-UP TABLE

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

134

Page 135: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING OF DC MOTOR SPEED CONTROL

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

135

Page 136: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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 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 MOD0MOD2: MOV A,#94H ;MOD0: MOVX @DPTR,A ;COUNTER2 IN MODE 2 MOV DPTR,#TABLE ;INI: MOVX A,@DPTR ;

136

Page 137: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

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 MOVX @DPTR,A ; CLR A ; MOV DPTR,#280CH ;SMALLEST COUNT TO TURN MOVX @DPTR,A ;MOTOR ON LJMP LOOP ;

MSG1: DFB "DIR F/R",03HMSG2: DFB "SPEED ",03H DFB 00H,50H END

137

Page 138: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

INTERFACING AND PROGRAMMING OF STEPPER MOTOR USING 8051

STEPPER MOTOR INTERFACING

AIMTo write an assembly language program to interface stepper motor

with 8051.

APPARATUS REQUIRED

8081 Microcontroller kit, Power chord, stepper motor, stepper motor interface board

THEORYA motor in which the rotor is able to assume only discrete stationary

angular position is a stepper motor. The rotary motion occurs in a step-wise

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

138

Page 139: CS 2259-MICROPROCESSOR LABORATORY

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 SCHEMEIn this scheme, any two adjacent stator windings are energized. The

switching scheme is shown in the table given below. This scheme produces

more torque.

ANTICLOCKWISE CLOCKWISE

STEP

A1

A2 B1

B2 DATA STEP

A1

A2

B1

B2 DATA

1 1 0 0 1 9h 1 1 0 1 0 Ah2 0 1 0 1 5h 2 0 1 1 0 6h3 0 1 1 0 6h 3 0 1 0 1 5h4 1 0 1 0 Ah 4 1 0 0 1 9h

ADDRESS DECODING LOGICThe 74138 chip is used for generating the address decoding logic to

generate the device select pulses; CS1 & CS2 for selecting the IC 74175.The

74175 latches the data bus to the stepper motor driving circuitry.

Stepper Motor requires logic signals of relatively high power.

Therefore, the interface circuitry that generates the driving pulses uses

139

Page 140: CS 2259-MICROPROCESSOR LABORATORY

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.

ALGORITHM

1. Store the lookup table address in DPTR.

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

3. Load the control word for motor rotation in accumulator.

4. PUSH the address in DPTR into stack.

5. Load FFC0 in to DPTR.

6. Call the delay program.

7. Send the control word for motor rotation to the external device.

8. POP up the values in stack and increment it.

9. Decrement the count in R0. If zero, go to next step, else proceed to

step 3.

10.Perform steps 1 to 9 repeatedly.

ADDRESS LABEL MNEMONICS OPCODE4100 START MOV DPTR,#4500 90 45 00

4103 MOV R0 #04 78 044105 MOVX A@DPTR E04106 PUSH DPH C0 834108 PUSH DPL C0 82410A MOV DPTR,#FFC0 90 FF C0

410D MOV R2 #04 7A 04410F MOV R1 #0F 7B 0F4111 DLY1 MOV R3 #0F 7B 0F4113 DLY DJNZ R3 DLY DB FE4115 DJNZ R1 DLY1 D9 FA4117 DJNZ R2 DLY1 DA F8

140

Page 141: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4119 MOVX@DPTR,A F0411A POP DPL D0 82411C POP DPH D0 83411E INC DPTR A3411F DJNZ R0 J0 D8 E44121 SJMP START 80 DD

SAWTOOTH WAVE GENERATION USING 8051AIM

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

microcontroller instruction set.

APPARATUS REQUIRED

8051 Microcontroller kit, Power chord, DAC Interface Card, CROALGORITHM

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.

PROGRAMORG 4100HDAC I EQU FFC0HADDRESS LABEL MNEMONICS OPCODE COMMENT

141

Page 142: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4100 START MOV A,#00H 74 00 MOVE DATA TO ACC

4102 L1 MOV DPTR,#DAC I

90 FF C0 MOVE DATA 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.

TRIANGULAR WAVE GENERATION USING 8051AIM

To write an assembly language program to generate the triangular

wave using microcontroller instruction set.

APPARATUS REQUIRED

8051 Microcontroller kit, Power chord, DAC Interface Card, CRO

ALGORITHM1. Move the port address of DAC to DPTR.

2. Load the initial value (00H) to accumulator.

3. Move the accumulator content to DAC.

4. Increment the accumulator content by 1.

5. If accumulator content is zero proceed to next step. Else go to step

3.

142

Page 143: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

6. Load value (FF) to accumulator.

7. Move the accumulator content to DAC.

8. Decrement the accumulator content by 1.

9. If accumulator content is zero go to step2. Else go to step 7.

PROGRAMORG 4100HDAC I EQU FFC0HADDRESS LABEL MNEMONICS OPCODE COMMENT4100 START MOV A,#00H 74 00 MOVE DATA

TO ACC4102 L1 MOV

DPTR,#DAC I90 FF C0 MOVE DATA

TO DPTR4105 MOVX@DPTR,A F0 MOVE DPTR

TO ACC4106 INC A 04 INCREMENT

ON ACC4107 JNZ L1 70 F9 IF JUMP NO

ZERO GO 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

143

Page 144: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

ON ACC410D JNZ L2 70 FC IF JUMP NO

ZERO TO L2410F SJMP START 80 EF SHORT JUMP

TO STARTOBSERVATION

S.No TIME PERIOD (msec) AMPLITUDE (volts)

1 1.6 * 2 = 3.2mse 2.5 * 2 = 5 V

RESULT

Thus the assembly language program to generate the triangular wave

using 8051 instruction set was written and executed successfully.

PROGRAMMING AND VERIFYING TIMER, INTERRUPTS AND UART OPERATIONS IN 8051 MICROCONTROLLER

1-INTERFACING PROGRAM OF TIMER [8053] USING MICROCONTROLLERA) SQUARE WAVE GENERATION MODEADDRESS LABEL MNEMONICS OPCODE COMMENT4100 MOV

DPTR,#FFCE90 FF CE MOVE DATA TO

DATA POINTER4103 MOV A,#36 74 36 MOVE DATA TO

ACCUMULATOR4105 MOVX@DPTR,A F0 MOVE DPTR TO

ACC4106 MOV A,#0A 74 0A MOVE DATA TO

ACC4108 MOV

DPTR,#FFC890 FF C8 MOVE DATATO

DPTR410B MOVX@DPTR,A F0 MOVE DPTR TO

ACC410C MOV A,#00 74 00 MOVE DATA TO

ACC410E MOVX

@DPTR,AF0 MOVE DPTR TO

ACC

144

Page 145: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

410F HERE: SJMP HERE 80 FE SHORT JUMP TO HERE

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

1-INTERFACING PROGRAM OF TIMER [8053] USING MICROCONTROLLERB) SQUARE WAVE GENERATION OF FREQUENCY 150 KHz AT CHANNEL 0ADDRESS LABEL MNEMONICS OPCODE COMMENT4100 MOV A,#36 74 36 MOVE DATA

TO ACC4102 MOV

DPTR,#FFCE90 FF CE MOVE DATA

TO DPTR4105 MOVX@DPTR,A F0 MOVE DPTR

TO ACC4106 MOV A,#12 74 12 MOVE DATA

TO ACC4108 MOV

DPTR,#FFC890 FF C8 MOVE

DATATO DPTR

410B MOVX@DPTR,A F0 MOVE DPTR TO ACC

410C MOV A,#00 74 00 MOVE DATA TO ACC

410E MOVX @DPTR,A

F0 MOVE DPTR TO ACC

145

Page 146: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

410F HERE: SJMP HERE 80 FE SHORT JUMP TO HERE

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

2-INTERFACING PROGRAM OF INTERRUPTS [8059] USING MICROCONTROLLERTO PROGRAM 8259 IN POLLING MODE

ADDRESS LABEL MNEMONICS OPCODE4100 MOV 1E,#00 75 A8 004103 MOV A,#16 74 164105 MOV DPTR,#FFCO 90 FF C0

4108 MOV @DPTR,A F04109 MOV DPTR,#FFC2 90 FF C2

410C MOV A,#00 74 00410F MOV @DPTR,A F04110 MOV @DPTR,A F04111 MOV DPTR,#FFCO 90 FF C0

4114 MOV A,#40 74 404116 MOV @DPTR,A F04117 WAIT MOV A,#0C 74 0C

146

Page 147: CS 2259-MICROPROCESSOR LABORATORY

CS2259 Microprocessors Laboratory

4119 MOV @DPTR,A F0411A MOV A, @DPTR E0411B MOV R0,A F8411C JNB E0 WAIT 30 E0 F8411F MOV A,R0 F84120 ANL A,#07 54 074122 CJNE A,#00 HERE B4 00 03

4124 LCALL ISR 12 41 504127 HERE: SJMP HERE 80 FE

ISR ORG 4150ADDRESS LABEL MNEMONICS OPCODE4150 MOV A,#00 74 004152 LCALL 0020 12 00 204155 STOP SJMP STOP 80 FE

RESULT

147