microprocessor labmanual

38
SATHYABAMA UNIVERSITY DR.JEPPIAAR NAGAR, RAJIV GANDHI SALAI, CHENNAI - 600119 DEPARTMENT OF ELECTRONICS AND TELECOMMUNICATION ENGINEERING LABORATORY MANUAL SECX4031 MICROPROCESSOR INTERFACING & APPLICATIONS LAB (AS PER SYLLABUS 2010-2014) V SEMESTER, ETCE

Upload: nahariprsad

Post on 28-Oct-2015

261 views

Category:

Documents


8 download

DESCRIPTION

8085 AND 8086 LAB EXPERIMENTS

TRANSCRIPT

Page 1: Microprocessor Labmanual

SATHYABAMA UNIVERSITY DR.JEPPIAAR NAGAR, RAJIV GANDHI SALAI,

CHENNAI - 600119

DEPARTMENT OF

ELECTRONICS AND TELECOMMUNICATION ENGINEERING

LABORATORY MANUAL

SECX4031

MICROPROCESSOR INTERFACING & APPLICATIONS LAB

(AS PER SYLLABUS 2010-2014)

V SEMESTER, ETCE

Page 2: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 2

CONTENTS

SSLL.. NNOO HHAANNDDOOUUTTSS PPAAGGEE

NNUUMMBBEERR

MMPP..11 LAB EXPERIMENT HANDOUT 33

MMPP..22 ANNEXURE 3333

SECX4031 MICROPROCESSORS INTERFACING & APPLICATIONS LAB (SYLLABUS)

I. 8085 Programming 1. Study of 8085 Microprocessor 2. 8 bit Addition, Subtraction, Multiplication and Division. 3. 16 bit Addition, Subtraction. 4. BCD to Hex and Hex to BCD code conversion. 5. Largest and smallest of a given set of numbers. 6. Block Movement of Data. 7. Square Root of 8-bit number.

II. 8086 Programming 1. Study of 8086 Microprocessor 2. 16 bit Addition, Subtraction, Multiplication and Division. 3. 32 bit Addition and Addition of 3x3 Matrices. 4. Ascending Order and Descending Order. 5. Reversal of a String.

III. Interfacing Experiments 1. Keyboard and Display Interface 2. ADC Interface 3. DAC Interface 4. Stepper Motor Interface 5. Traffic Signal Modeling

RECORD NOTEBOOK / OBSERVATION WRITING FORMAT

LEFT HAND SIDE (UNRULED)

RIGHT HAND SIDE (RULED)

FLOW CHART AIM MANUAL CALCULATION APPARATUS NEEDED ALGORITHM PROCEDURE THEORY (ONLY IN RECORD) PROGRAM INPUT/ OUTPUT RESULT

Page 3: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 3

MP.1 LAB EXPERIMENT HANDOUT

LIST OF EXPERIMENTS

(AS PER UNIVERSITY SYLLABUS)

(100 Marks)

INDEX

SSll.. NNoo CCyyccllee EExxeerrcciissee

NNuummbbeerr EExxppeerriimmeennttss

PPaaggee

NNuummbbeerr

11 SS11..11 Study of 8085 Microprocessor 33

22 11 11..11 8 bit Addition, Subtraction, Multiplication and Division

11--1100

33 11 11..22 16 bit Addition, Subtraction 1111

44 11 11..33 BCD to Hex and Hex to BCD code conversion

1144--1166

55 11 11..44 Largest and smallest of a given set of numbers.

1177--1199

66 11 11..55 Block Movement of Data. 2200--2211

77 11 AASSSSIIGGNNMMEENNTT Square Root of 8-bit number --

88 SS22..11 Study of 8086 Microprocessor 2222

99 22 22..11 16 bit Addition, Subtraction, Multiplication and Division

2222--2277

1100 22 22..22 32 bit Addition 2288--2299

1111 22 22..33 Ascending Order and Descending Order.

3300--3322

1122 22 AASSSSIIGGNNMMEENNTT Reversal of a String --

1133 33 33..11 Keyboard and Display Interface --

1144 33 33..22 ADC Interface --

1155 33 33..33 DAC Interface --

1166 33 33..44 Stepper Motor Interface --

1177 33 33..55 Traffic Signal Modeling --

For Interfacing experiments (Exercise 3.1 to 3.5)- Respective Manuals shall be provided by Lab In-charges in the Laboratory.

Page 4: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 4

8085 PROGRAMMING

S1.1. STUDY OF 8085 PROCESSOR

8085 architecture diagram shall be drawn in the record and its functional units shall

be described in detail.

Page 5: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 5

1.1. 8-BIT ADDITION, SUBTRACTION, MULTIPLICATION AND DIVISION

1.1 (a) ADDITION OF TWO EIGHT BIT NUMBERS (8085) AIM: To write and execute an assembly language program to perform the addition of two eight bit numbers using 8085 kit.

ALGORITHM: Step 1 : Start. Step 2 : Clear C register for carry Step 3 : Load the first data from memory to accumulator and move it to B register. Step 4 : Load the second data from memory to accumulator. Step 5 : Add the content of B register to the accumulator. Step 6 : Check for carry. If carry = 1, go to step 7 else if carry =0, go to step 8. Step 7 : Increment the C register. Step 8 : Store the sum in memory Step 9 : Move the carry to accumulator and store in memory Step 10 : End Program

Note: && - Sample Comment written and Comment to be written for all other programs

In this program Registers A, B C are used for Data Manipulation PROGRAM:

Instruction Memory Address

Label Hex code Mnemonic Operand

&& Comment

8000 0E,00 MVI C,00 Clear C register for carry

8002 3A, 00, 90 LDA 9000 Load the first data from memory to accumulator

8005 47 MOV B,A Move the data to B register.

8006 3A, 01, 90 LDA 9001 Load the second data from memory to accumulator.

8009 80 ADD B Add the content of B register to the accumulator.

800A D2, 0E, 80 JNC 800E (NO_CY)

Check for carry. If carry = 1, increment carry register else if carry =0 store the result

800D 0C INR C Increment the C register for carry

800E NO_CY: 32, 00, 95 STA 9500 Store the sum in memory

8011 79 MOV A,C Move the carry to accumulator

8012 32, 01, 95 STA 9501 Store Carry in memory

8015 CF RST 1 End the program

Note: RST 1 can be replaced by HLT also to terminate the program. Hex code for HLT

is 76. Do not type the labels for example :( NO_CY) in the assembler kit. NOT to write the operands given within brackets

Page 6: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 6

MANUAL CALCULATION: (FOR THE INPUT USED AS DATA)

BIT POSITION 8 7 6 5 4 3 2 1 0

1 1 1 1 1 1

DATA 1 AE 1 0 1 0 1 1 1 0 INPUT

DATA 2 + FD 1 1 1 1 1 1 0 1

SUM = AB 1 0 1 0 1 0 1 1 OUTPUT

CARRY = 01 *** NOTE: This shall be considered as an example manual calculation and to be done done for all arithmetic or logical programs like exercise numbers 1.1, 1.2, 1.3, 2.1 & 2.2 by students. SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 AE Augend

9001 FD Addend

After Execution

Memory Address

Data

9500 AB Sum

9501 01 Carry

Addition: FD+AE=01AB RESULT: An assembly language program to perform addition of two eight bit numbers using 8085 is written and executed.

Page 7: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 7

1.1(b) SUBTRACTION OF TWO EIGHT BIT NUMBERS (8085) AIM: To write and execute an assembly language program to perform subtraction of two eight bit numbers using 8085 kit. ALGORITHM:

Step 1 : Start. Step 2 : Clear C register to account for sign of the result. Step 3 : Load the subtrahend (the data to be subtracted) from memory to accumulator

and move it to B register. Step 4 : Load the minuend from memory to accumulator. Step 5 : Subtract the content of B register from the content of the accumulator. Step 6 : Check for carry. If carry = 1, go to step 7 else if carry =0, go to step 8. Step 7 : Increment the C register. Complement the accumulator and add 01H. Step 8 : Store the difference in memory. Step 9 : Move the content of C register (sign bit) to accumulator and store in memory. Step 10 : End program

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 0E, 00 MVI C,00

8002 3A, 00, 90 LDA 9001

8005 47 MOV B,A

8006 3A, 01, 90 LDA 9000

8009 90 SUB B

800A D2, 0E, 80 JNC 8010 (L1)

800D 0C INR C

800E 2F CMA

800F 3C INR A

8010 L1 32, 01, 95 STA 9501

8013 79 MOV A,C

8014 32, 02, 95 STA 9502

8017 CF RST 1

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 AF Subtrahend

9001 EF Minuend

After Execution

Memory Address

Data

9501 40 Difference

9502 00 Borrow

Subtraction: EF-AF=40

Page 8: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 8

RESULT: An assembly language program to perform subtraction of two eight bit numbers using 8085 is written and executed.

1.1 (c) MULTIPLICATION OF TWO EIGHT BIT NUMBERS (8085) AIM: To write and execute an assembly language program to perform multiplication of two eight bit numbers using 8085 kit. ALGORITHM:

Step 1 : Start. Step 2 : Clear Reg D for Carry Step 3 : Load 1st Number ( Multiplicand in Reg B through reg A Step 4 : Load 2nd Number ( Multiplier in Reg C through reg A Step 5 : Clear Reg A ( Accumulator) Step 6 : Now add content of Reg B with Reg A Step 7 : Check for Carry if carry NOT exists then skip next step Step 8 : Decrement 2nd number ( multiplier) in Reg C Step 9 : Check for Reg C for zero, If NOT zero go to step 6 Else continue Step 10 : Store the result ( product) in reg A into output memory address Step 11 : Store the Carry in Reg D into next output memory address Step 12 : End Program

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 16,00 MVI D, 00

8002 3A,00,90 LDA 9000

8005 47 MOV B, A

8006 3A,01,90 LDA 9001

8009 4F MOV C, A

800A 3E,00 MVI A, 00

800C L2 80 ADD B

800D D2,11,80 JNC L1 (8011)

8010 14 INR D

8011 L1 0D DCR C

8012 C2,0C,80 JNZ L2 (800C)

8015 32,00,95 STA 9500

8018 7A MOV A, D

8019 32,01,95 STA 9501

801C CF RST 1

Page 9: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 9

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 EF Multiplicand

9001 AF Multiplier

After Execution

Memory Address

Data

9500 61 LSB of Product

9501 A3 MSB of the Product

Multiplication: EFxAF= A361 RESULT: An assembly language program to perform multiplication of two eight bit numbers using 8085 is written and executed. 1.1 (d) DIVISION OF TWO EIGHT BIT NUMBERS (8085) AIM: To write and execute an assembly language program to perform the division of two eight bit numbers using 8085 kit. ALGORITHM:

Step 1 : Start. Step 2 : Clear C register to account for quotient. Step 3 : Load the divisor in accumulator and move it to B register. Step 4 : Load the dividend in the accumulator. Step 5 : Check whether divisor is less than dividend. If divisor is less than

dividend, go to step 9, else go to next step. Step 6 : Subtract the content of B register from accumulator. Step 7 : Increment the content of C register (quotient). Step 8 : Go to step 5. Step 9 : Store the content of accumulator (remainder) in memory. Step 10: Move the content of C register (quotient) to accumulator and store in

memory. Step 11 : End program.

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 0E, 00 MVI C,00

8002 3A, 00, 90 LDA 9001

8005 47 MOV B,A

8006 3A, 01, 90 LDA 9000

8009 L2 B8 CMP B

800A DA, 12 ,80 JC 8012 (L1)

Page 10: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 10

Instruction Memory Address

Label Hex Code Mnemonic Operand

800D 90 SUB B

800E 0C INR C

800F C3, 09, 80 JMP 8009 (L2)

8012 L1 32, 00, 95 STA 9500

8015 79 MOV A,C

8016 32, 01, 95 STA 9501

8019 CF RST 1

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 EF Divisor

9001 AF Dividend

After Execution

Memory Address

Data

9500 40 Remainder

9501 01 Quotient

Division: EF/AF= Remainder (40) Quotient (01)

RESULT: An assembly language program to perform division of two eight bit numbers using 8085 is written and executed.

Page 11: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 11

1.2. 16 BIT ADDITION and SUBTRACTION 1.2 (a) ADDITION OF TWO SIXTEEN BIT NUMBERS (8085) AIM: To write an assembly language program to perform addition of two sixteen bit numbers.

ALGORITHM:

Step 1 : Start. Step 2 : Clear C register for carry. Step 3 : Load the first data in HL register pair. Step 4 : Move the first data to DE register pair. Step 5 : Load the second data in HL register pair. Step 6 : Add the content of DE register pair to HL register pair. Step 7 : Check for carry. If carry = 1, go to step 8 else if carry =0, go to step

9. Step 8 : Increment the C register to account for carry. Step 9 : Store the sum in memory. Step 10: Move the carry to accumulator and store in memory. Step 11: End program.

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 0E, 00 MVI C,00

8002 2A, 00, 90 LHLD 9000

8005 EB XCHG

8006 2A, 02, 90 LHLD 9002

8009 19 DAD D

800A D2, 0E, 80 JNC 800E (L1)

800D 0C INR C

800E L1 22, 00, 95 SHLD 9500

8011 79 MOV A,C

8012 32, 02, 95 STA 9502

8015 CF RST 1

Page 12: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 12

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 CD Upper Byte (Augend)

9001 AB Lower Byte (Augend)

9002 AA Upper Byte (Addend)

9003 AA Lower Byte (Addend)

After Execution

Memory Address

Data

9500 77 Lower Byte Sum

9501 56 Upper Byte Sum

9502 01 Carry

16-Bit Addition: ABCD+AAAA=015677 RESULT: An assembly language program to perform addition of two 16-bit numbers using 8085 is written

and executed

1.2 (b) SUBTRACTION OF TWO SIXTEEN BIT NUMBERS (8085) AIM: To write an assembly language program to perform subtraction, of two sixteen bit numbers.

ALGORITHM:

Step 1 : Start. Step 2 : Load the first data in HL register pair. Step 3 : Move the first data to DE register pair. Step 4 : Load the second data in HL register pair. Step 5 : Move the content of E to A. Step 6 : Subtract Content of L from A (Lower Bytes) Step 7 : Store the difference in the memory Step 8 : Move the content of D to A. Step 9 : Subtract Content of H from A with borrow (higher Bytes) Step 10: Store the difference in the memory Step 11: End program.

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 2A, 00, 90 LHLD 9000

8003 EB XCHG

8004 2A, 02, 90 LHLD 9002

Page 13: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 13

Instruction Memory Address

Label Hex Code Mnemonic Operand

8007 7B MOV A, E

8008 95 SUB L

8009 32, 00, 95 STA 9500

800C 7A MOV A, D

800D 9C SBB H

800E 32, 01, 95 STA 9501

8011 CF RST 1

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 CD Upper Byte (Minuend)

9001 AB Lower Byte (Minuend)

9002 AA Upper Byte (Subtrahend)

9003 AA Lower Byte (Subtrahend)

After Execution

Memory Address

Data

9500 23 Lower Byte Difference

9501 01 Upper Byte Difference

16-Bit Subtraction: ABCD-AAAA=0123

RESULT: An assembly language program to perform subtraction of two 16-bit numbers using 8085 is

written and executed.

Page 14: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 14

1.3. CONVERTING A BCD NUMBER TO HEX NUMBER and HEX TO BCD NUMBERS

1.3 (a) CONVERTING A BCD NUMBER TO HEX NUMBER (8085) AIM: To write an assembly language program to convert BCD number in memory to the equivalent HEX number using 8085. ALGORITHM:

Step 1 : Start Step 2 : Load the BCD number in accumulator (Reg A) Step 3 : Copy it to Reg E Step 4 : Mask the Lower Nibble of the BCD number Step 5 : Rotate it 4 times to move Upper nibble to lower nibble place Step 6 : Copy the number to Reg B Step 7 : Clear Reg A Step 8 : Copy number “0A” in Reg C (Decimal number 10) Step 9 : Multiply the number in B by 10d Step 10: Then move the product in Reg B Step 11: Copy the original number in Reg E to Reg A Step 12: Mask the Upper Nibble of the BCD Number Step 13: Add the Number in Reg B with the number in Reg A Step 15: The number is copied to a memory location Step 14: End program.

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 3A, 00, 90 LDA 9000

8003 5F MOV E, A

8004 E6, 0F ANI F0

8006 0F RRC

8007 0F RRC

8008 0F RRC

8009 0F RRC

800A 47 MOV B, A

800B 3E,00 MVI A,00

800D 0E, 0A MVI C,0A

800F L1 80 ADD B

8010 OD DCR C

8011 C2, 0F, 80 JNZ 800F(L1)

8014 47 MOV B, A

8015 MOV A, E

8016 E6, F0 ANI 0F

8018 80 ADD B

Page 15: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 15

Instruction Memory Address

Label Hex Code Mnemonic Operand

8019 32, 00, 95 STA 9500

801C CF RST 1

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 29 (BCD)

After Execution

Memory Address

Data

9500 1D (HEX)

BCD (29d) = Hexadecimal (1DH) RESULT: An assembly language program to convert the Binary coded decimal (BCD) into Hexadecimal number (HEX) has been written and executed using microprocessor 8085. 1.3 (b) CONVERTING HEXADECIMAL NUMBER TO BCD NUMBER (8085) AIM: To write an assembly language program to convert HEX numbers in memory to the equivalent BCD number using 8085. ALGORITHM:

Step 1 : Start Step 2 : Clear Reg D and E to store tens and hundreds respectively Step 3 : Load the HEX number in accumulator (Reg A) Step 4 : Compare Hex number with 64h (100d)(Check for Hundreds) Step 5 : If carry , HEX <64 so go to Check Tens ( Step 8 ) NO Carry Next step Step 6 : Subtract 64 h (100s) from the number. Step 7 : Increment Reg E for each hundred and repeat step 6 until HEX

becomes less than 100d (64H) Step 8 : Compare Remaining Hex number with 0Ah (10d) (Check for Tens) Step 9 : If carry , Remaining HEX <10 so go to Check ones ( Step ) NO Carry

Next step Step 10: Subtract 0A h (10s) from the number. Step 11: Increment Reg D for each hundred and repeat step 6 until HEX

becomes less than 10d (0AH) Step 12: Now the remaining is ones and is stored in Reg C Step 13: Now tens are copied from reg D to Reg A Step 15: The number is rotated 4 times to move it to tens position (upper

Nibble) Step 14: Then the number is added with ones in Reg c Step 15: Store the Combined tens and ones in reg A to memory location Step 16: Store the Hundreds in Reg E to next memory location Step 17: End program.

Page 16: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 16

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 16, 00 MVI D, 00

8002 1E, 00 MVI E, 00

8004 3A, 00, 90 LDA 9000

8007 L2 FE, 64 CPI 64

8009 DA, 0B, 80 JC 8012 (L1)

800C D6, 64 SUI 64

800E 1C INR E

800F C3, 06, 80 JMP 8007 (L2)

8012 L1 FE, 0A CPI 0A

8014 DA, 1C, 80 JC 8024(L3)

8017 D6, 0A SUI 0A

8019 14 INR D

801A C3, 0B, 80 JMP 8012 (L1)

801D L3 4F MOV C, A

801E 7A MOV A, D

801F 0F RRC

8020 0F RRC

8021 0F RRC

8022 0F RRC

8023 81 ADD C

8024 32, 00, 95 STA 9500

8027 7B MOV A, E

8028 32, 01, 95 STA 9501

802B CF RST 1

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 1D (Hex)

After Execution

Memory Address

Data

9500 29 (BCD) Tens and ones

9501 00 Hundreds

Hexadecimal (1DH) = BCD (0029d) RESULT: The program to convert the hexadecimal number (HEX) into Binary coded decimal (BCD) has been written and executed using microprocessor 8085.

Page 17: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 17

1.4. LARGEST AND SMALLEST OF A GIVEN SET OF NUMBERS 1.4 (a) LARGEST OF A GIVEN SET OF NUMBERS (8085) AIM: To write assembly language programs to search the largest of a given set of array of numbers

using 8085.

ALGORITHM:

Step 1 : Start. Step 2 : Load the address of the first element of the array in HL register pair (pointer). Step 3 : Move the count to B register. Step 4 : Increment the pointer. Step 5 : Get the first data in the accumulator. Step 6 : Decrement the count. Step 7 : Increment the pointer. Step 8 : Compare the content of memory addresses by HL pair with that of

accumulator. Step 9 : If CF=0, go to step 11 else go to step 10. Step 10: Move the content memory addressed HL to accumulator. Step 11: Decrement the count. Step 12: Check for zero for the count. If ZF=0, go to step 7 else go to next step. Step 13: Store the largest data in the memory. Step 14: End program.

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 21, 00, 90 LXI H,9000

8003 46 MOV B,M

8004 23 INX H

8005 7E MOV A,M

8006 05 DCR B

8007 L2 23 INX H

8008 BE CMP M

8009 D2, 0D, 80 JNC 800D (L1)

800C 7E MOV A,M

800D L1 05 DCR B

800E C2, 08, 80 JNZ 8007 (L2)

8011 32, 00, 95 STA 9500

8014 76 HLT

Page 18: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 18

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 05 Count

9001 EF Data 1

9002 DA Data 2 9003 FD Data 3 9004 12 Data 4 9005 05 Data 5

After Execution

Memory Address

Data

9500 FD Largest

1.4 (b) SMALLEST OF A GIVEN SET OF NUMBERS (8085) AIM: To write assembly language programs to search the smallest of a given set of array of numbers

using 8085.

ALGORITHM:

Step 1 : Start. Step 2 : Load the address of the first element of the array in HL register pair (pointer). Step 3 : Move the count to B register. Step 4 : Increment the pointer. Step 5 : Get the first data in the accumulator. Step 6 : Decrement the count. Step 7 : Increment the pointer. Step 8 : Compare the content of memory addresses by HL pair with that of

accumulator. Step 9 : If CF=1, go to step 11 else go to step 10. Step 10: Move the content memory addressed HL to accumulator. Step 11: Decrement the count. Step 12: Check for zero for the count. If ZF=0, go to step 7 else go to next step. Step 13: Store the smallest data in the memory. Step 14: End program.

Page 19: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 19

PROGRAM:

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

9000 05 Count

9001 EF Data 1

9002 DA Data 2 9003 FD Data 3 9004 12 Data 4 9005 05 Data 5

After Execution

Memory Address

Data

9500 05 Smallest

RESULT: The programs to find the Largest and smallest number has been written and executed using microprocessor 8085. NOTE: Largest and smallest programs are the same except the commands JC and JNC.

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 21, 00, 90 LXI H, 9000

8003 46 MOV B,M

8004 23 INX H

8005 7E MOV A,M

8006 05 DCR B

8007 L2 23 INX H

8008 BE CMP M

8009 DA, 0D, 80 JC 800D (L1)

800C 7E MOV A,M

800D L1 05 DCR B

800E C2 , 08, 80 JNZ 8007 (L2)

8011 32, 00, 95 STA 9500

8014 76 HLT

Page 20: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 20

1.5. BLOCK MOVEMENT OF DATA

AIM: To write an assembly language program to move a block of data from one set of memory location to other using 8085 microprocessor. ALGORITHM:

Step 1: Start Step 2: Load the starting address of the destination block in DE pair (9100) Step 3: Load the address of the Length of the block in HL pair (9000).

From the next address (9001) the source block starts Step 4: Move the length of the block to Reg B Step 5: Increment the HL pair to Starting address of the source block Step 6: Move the first source data to Accumulator ( Reg A) Step 7: Move the Data to Destination block by Pointing with DE pair. Step 8: Increment the destination address ( DE Pair) Step 9: Decrement the Block count in Reg B Step 10: Check whether the block count is 0, if NOT zero Go to step 4, else next step Step 11: Terminate the program. PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

8000 11,00,91 LXI D, 9100

8003 21,00,90 LXI H, 9000

8006 46 MOV B, M

8007 L1 23 INX H

8008 7E MOV A, M

8009 12 STAX D

800A 13 INX D

800B 05 DCR B

800C C2,07,80 JNZ 8007 (L1)

800F CF RST 1

Page 21: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 21

SAMPLE INPUT & OUTPUT:

The block arrays of five 8-bit data are moved from Addresses 9001 to 9100.

Before Execution

Memory Address

Data

9000 05 Number of Data (Count)

9001 0A Data 1

9002 05 Data 2 9003 32 Data 3 9004 5B Data 4 9005 CA Data 5

After Execution

Memory Address

Data

9100 0A Data 1

9101 05 Data 2 9102 32 Data 3 9103 5B Data 4 9104 CA Data 5

RESULT: The program to move a block of data from one set of memory location to another set of memory location has been written and executed using microprocessor 8085.

Page 22: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 22

8086 PROGRAMMING

S2.1. STUDY OF 8086 PROCESSOR Draw 8086 architecture diagram in the record

Write about the functional units in detail

2.1. 16-BIT ADDITION, SUBTRACTION, MULTIPLICATION AND DIVISION

2.1 (a) ADDITION OF TWO SIXTEEN BIT NUMBERS (8086) AIM: To write and execute an assembly language program to perform addition of two sixteen bit numbers using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Clear CX register for carry Step 3 : Initiate Source Index to a source address where input data is stored. Step 4 : Initiate Destination Index to a destination address where output data is

stored. Step 5 : Augends data shall be copied into Accumulator (AX) using source index. Step 6 : Addend data from next input address shall be copied into register BX

using source index. Step 7 Both addend and augends in are added Step 8 : Check for the Carry Flag. If Carry flag is NOT set skip next step 9 Step 9 : Register CX is incremented (Carry) Step 10 : The Sum in Register AX is copied into output memory address using

destination index register Step 11 : The Carry stored in Register CX is copied into the next output address Step 12 : The program is halted

Note: - Address, Hex Codes and Comment to be written for all other programs while in the lab In this program Registers AX, BX, CX are used for Data Manipulation PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

MOV CX,0000

MOV SI,1000

MOV DI,1500

MOV AX,[SI]

MOV BX,[SI+2]

ADD AX,BX

JNC (NO_CARY)

INC CL

NO_CARY MOV [DI],AX

MOV [DI+2],CX

INT 3

Page 23: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 23

Note: NO_CARY shall be replaced with relevant memory address inside the program else the assembler throws a syntax error. SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 Augend

(Lower Byte)

1001 Augend

(Upper Byte)

1002 Addend

(Lower Byte)

1003 Addend

(Upper Byte)

After Execution

Memory Address

Data

1500 Sum

(Lower Byte)

1501 Sum

(Upper Byte)

1502 Carry

RESULT: An assembly language program to perform the addition of two sixteen bit numbers using 8086 is written and executed. 2.1 (b) SUBTRACTION OF TWO SIXTEEN BIT NUMBERS (8086) AIM: To write and execute an assembly language program to perform subtraction of two sixteen bit numbers using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Clear CX register for Carry/Borrow Step 3 : Initiate Source Index to a source address where input data is stored. Step 4 : Initiate Destination Index to a destination address where output data is

stored. Step 5 : Minuend data shall be copied into Accumulator (AX) using source index. Step 6 : Subtrahend data from next input address shall be copied into register BX

using source index. Step 7 Subtrahend in register BX is subtracted from minuend in register AX Step 8 : Check for the Carry/Borrow Flag. If Carry/Borrow flag is NOT set skip next

step 9 Step 9 : Borrow is Copied into CL register. The difference in AX is two’s

complemented. Step 10 : The Difference in Register AX is copied into output memory address using

destination index register Step 11 : The Borrow stored in Register CX is copied into the next output address Step 12 : The program is halted

BORROW indicates that the Minuend is smaller than Subtrahend

PROGRAM:

Page 24: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 24

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

MOV CX,0000

MOV SI,1000

MOV DI,1500

MOV AX,[SI]

MOV BX,[SI+2]

SUB AX,BX

JNC (NO_BOROW)

INC CL

NEG AX

NO_BOROW MOV [DI],AX

MOV [DI+2],CX

INT 3

Note: NO_BOROW shall be replaced with relevant memory address inside the program else the assembler throws a syntax error. SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 Minuend

(Lower Byte)

1001 Minuend

(Upper Byte)

1002 Subtrahend

(Lower Byte)

1003 Subtrahend

(Upper Byte)

After Execution

Memory Address

Data

1500 Difference

(Lower Byte)

1501 Difference

(Upper Byte)

1502 Borrow

RESULT: An assembly language program to perform the subtraction of two sixteen bit numbers using 8086 is written and executed. 2.1 (c) MULTIPLICATION OF TWO SIXTEEN BIT NUMBERS (8086) AIM: To write and execute an assembly language program to perform multiplication of two sixteen bit numbers using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Initiate Source Index to a source address where input data is stored. Step 3 : Initiate Destination Index to a destination address where output data is

stored. Step 4 : Multiplicand data shall be copied into Accumulator (AX) using source

Page 25: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 25

index. Step 5 : Multiplier data from next input address shall be copied into register BX

using source index. Step 6 Both Multiplicand and Multiplier are multiplied Step 7 : The Product in Register AX is copied into output memory address using

destination index register Step 8 : The Carry stored in Register DX is copied into the next output address Step 9 : The program is halted

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

MOV DX,0000

MOV SI,1000

MOV DI,1500

MOV AX,[SI]

MOV BX,[SI+2]

MUL AX,BX

MOV [DI],AX

MOV [DI+2],DX

INT 3

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 Multiplicand

(Lower Byte)

1001 Multiplicand

(Upper Byte)

1002 Multiplier

(Lower Byte)

1003 Multiplier

(Upper Byte)

After Execution

Memory Address

Data

1500 Product

(Lower Byte)

1501 Product

(Upper Byte)

1502 Carry

(Lower Byte)

1503 Carry

(Upper Byte)

RESULT: An assembly language program to perform multiplication of two sixteen bit numbers using 8086 is written and executed.

Page 26: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 26

2.1 (d) DIVISION OF SIXTEEN BIT NUMBER BY EIGHT BIT NUMBER (8086) AIM: To write and execute an assembly language program to perform division of two sixteen bit numbers using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Initiate Source Index to a source address where input data is stored. Step 3 : Initiate Destination Index to a destination address where output data is

stored. Step 4 : Dividend data shall be copied into Accumulator (AX) using source index. Step 5 : Divisor data from next input address shall be copied into register BX using

source index. Step 6 Division is completed. Remainder is Generated in DX and Quotient in AX Step 7 : The Quotient in Register AX is copied into output memory address using

destination index register Step 8 : The Remainder stored in Register DX is copied into the next output

address Step 9 : The program is halted

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

MOV DX,0000

MOV SI,1000

MOV DI,1500

MOV AX,[SI]

INC SI

INC SI

MOV BX,[SI]

DIV AX,BX

MOV [DI],AX

INC DI

INC DI

MOV [DI],DX

INT 3

Page 27: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 27

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 Dividend

(Lower Byte)

1001 Dividend

(Upper Byte)

1002 Divisor

(Lower Byte)

1003 Divisor

(Upper Byte)

After Execution

Memory Address

Data

1500 Quotient

(Lower Byte)

1501 Quotient

(Upper Byte)

1502 Remainder

(Lower Byte)

1503 Remainder

(Upper Byte)

RESULT: An assembly language program to perform the addition, subtraction, multiplication and division of two sixteen bit numbers using 8086 is written and executed.

Page 28: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 28

2.2. 32-BIT ADDITION AIM: To write and execute an assembly language program to perform the addition of two thirty two bit numbers using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Initiate Register DX Step 3 : Point the source and destination register to source and destination

memory addresses respectively Step 4 : Copy the augend into register AX (Lower word) and register BX (Upper

Word) Step 5 : Copy the addend into register CX (Lower word) and register DX (Upper

Word) Step 6 : Add the Lower 16 bit words in AX and CX Step 7 : Copy the sum in AX to Destination memory location Step 8 : Initiate CX for storing Carry generated Step 9 : Add the Upper words in BX and DX with carry Step 10 : If Carry is generated then CX else store the result Step 11 : Copy the Sum (Upper Word) from BX and Carry from CX to destination

Memory locations Step 12 : Stop the program

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

MOV DX,0000

MOV SI,1000

MOV DI,1500

MOV AX,[SI]

MOV BX,[SI+2]

MOV CX,[SI+4]

MOV DX,[SI+6]

ADD AX,CX

MOV CX,0000

MOV [DI],AX

ADC BX,DX

JNC (NO_CARY)

INC CX

NO_CARY MOV [DI+2],BX

MOV [DI+4],CX

INT 3

Page 29: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 29

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 Augend

(Lower Word Lower Byte)

1001 Augend

(Lower Word Upper Byte)

1002 Augend

(Upper Word Lower Byte)

1003 Augend

(Upper Word Upper Byte)

1004 Addend

(Lower Word Lower Byte)

1005 Addend

(Lower Word Upper Byte)

1006 Addend

(Upper Word Lower Byte)

1007 Addend

(Upper Word Upper Byte)

After Execution

Memory Address

Data

1500 Sum

(Lower Word Lower Byte)

1501 Sum

(Lower Word Upper Byte)

1502 Sum

(Upper Word Lower Byte)

1503 Sum

(Upper Word Upper Byte)

1504 Carry

[BX][AX[ +[DX][CX]=[1504][1503][1502][1501][1500] RESULT: An assembly language program to perform the addition of two thirty two bit numbers using 8086 is executed and verified.

Page 30: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 30

2.3. ASCENDING ORDER AND DESCENDING ORDER 2.3 (a) ARRANGING AN ARRAY OF NUMBERS IN ASCENDING ORDER (8086) AIM: To write and execute an assembly language program to arrange an array of numbers in ascending order using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Point the Source index to source memory location Step 3 : Copy the Number of array elements stored in Source index to register CL Step 4 : Decrement the register CL Step 5 : Increment the Source index and copy the first Number in to Register AL Step 6 : Compare the next number in Memory location with Content in AL Step 7 : If carry is generated Content in AL is smaller than next location content.

Then it goes to step3, else to next step Step 8 : The contents in memory locations are swapped by using AL register. Thus

smaller number is copied in first location and the larger in next location Step 9 : Then the Steps are repeated until the numbers arranged in ascending

order Step 10 : Every time register is decremented and checked for zero content. When

CX=0 the sorting of number has been completed Step 11 : Stop the program

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

STEP1: MOV SI,1000

MOV CL,[SI]

DEC CL

INC SI

STEP2: MOV AL,[SI]

INC SI

CMP AL, [SI]

JC (STEP3)

XCHG AL,[SI]

XCHG AL,[SI-1]

LOOP (STEP1)

STEP3: DEC CL

JNZ (STEP2)

INT 3

Page 31: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 31

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 07 No of Array elements

1001 23

1002 34

1003 21

1004 AB

1005 FA 1006 3B

1007 11

After Execution

Memory Address

Data

1000 11

1001 21

1002 23

1003 34

1004 3B

1005 AB

1006 FA

RESULT: An assembly language program to Sort an array of numbers in ascending order using 8086 kit is executed and verified. 2.3 (b) SORTING AN ARRAY OF NUMBERS IN DESCENDING ORDER (8086) AIM: To write and execute an assembly language program to arrange an array of numbers in descending order using 8086 kit. ALGORITHM:

Step 1 : Start. Step 2 : Point the Source index to source memory location Step 3 : Copy the Number of array elements stored in Source index to register CL Step 4 : Decrement the register CL Step 5 : Increment the Source index and copy the first Number in to Register AL Step 6 : Compare the next number in Memory location with Content in AL Step 7 : If carry is generated Content in AL is smaller than next location content.

Then it goes to step3, else to next step Step 8 : The contents in memory locations are swapped by using AL register. Thus

smaller number is copied in first location and the larger in next location Step 9 : Then the Steps are repeated until the numbers arranged in descending

order Step 10 : Every time register is decremented and checked for zero content. When

CX=0 the sorting of number has been completed Step 11 : Stop the program

Page 32: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 32

PROGRAM:

Instruction Memory Address

Label Hex Code Mnemonic Operand

Comment

STEP1: MOV SI,1000

MOV CL,[SI]

DEC CL

INC SI

STEP2: MOV AL,[SI]

INC SI

CMP AL, [SI]

JNC (STEP3)

XCHG AL,[SI]

XCHG AL,[SI-1]

LOOP (STEP1)

STEP3: DEC CL

JNZ (STEP2)

INT 3

SAMPLE INPUT & OUTPUT:

Before Execution

Memory Address

Data

1000 07 No of Array elements

1001 23

1002 34

1003 21

1004 AB

1005 FA 1006 3B

1007 11

After Execution

Memory Address

Data

1000 FA

1001 AB

1002 3B

1003 34

1004 23

1005 21

1006 11

RESULT: An assembly language program to Sort an array of numbers in descending order using 8086 kit is executed and verified.

Page 33: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 33

MP.2 ANNEXURE

BASICS TO KNOW FOR PROGRAMMING USING 8085

• 8085 IS AN INTEL 40 PIN CHIP PROCESSOR THAT WORKS AT +5V DC

POWER SUPPLY.

• FOR PROGRAMMING 8085, WE NEED TO KNOW ABOUT MEMORY UNIT, REGISTERS, INSTRUCTION SET, TIMERS & COUNTERS, STACK,

INTERRUPTS.

• MEMORY UNIT

o Memory unit is an externally attached chip to a maximum of 64 Kb.

o The addresses start from 0000h and end at FFFFH.

o The addresses may be of ROM (Read-Only Memory) or RAM (Random

Access Memory).

o The addresses of ROM cannot be used by the user for programming

o Only RAM addresses can be used for programming. For example,

addresses 8000H to 9FFFH may be usable addresses. ( KIT manual

shall be referred for knowing usable and unusable addresses)

• REGISTERS

o The register unit consists of twelve 8-bit registers and two 16-bit

registers.

o They are

� 8-bit registers: A (Accumulator), B, C, D, E, H, L, Flag, W, Z,

Temp and Instruction registers.

� 16-bit registers: SP (Stack Pointer) and PC (Program Counter)

o Registers A becomes main operand for any arithmetic or logical

instructions. It is used to fetch data from memory or write data into

memory. Thus, it is called WORKING REGISTER.

Page 34: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 34

o The other registers BC can be used as 16-bit register as a pair and

individually B and C can be used as 8-bit registers. This setup is called

REGISTER PAIR. The other register pairs are DE, HL and WZ. (WZ

cannot be used by any programmer)

o HL Register pair is considered to be working register pair in 16-bit

operations as accumulator in 8-bit operations.

o Flag register shows the status of any arithmetic or logical operation

when

� carry/borrow is generated (CARRY FLAG),

� the registers pointed being data 00H (ZERO FLAG),

� the MSB of the Content in register A is binary 1 (SIGN FLAG),

� parity of the Content of Register A is odd or even (PARITY

FLAG)

o Temp register and Instruction registers cannot be used by

programmer. They are meant for internal operations.

• INSTRUCTIONS

o There are 7 sets of instructions in 8085.

o They are

� Data Transfer Instructions that copy data from memory to

Registers, Registers to Memory, Register to register,

Accumulator to Output interfaced peripherals, input interfaced

peripherals to accumulator.

� Arithmetic Instructions that perform operations of addition,

subtraction, incrementing a register, decrementing a register

etc. (NO instructions for Multiplication and division)

� Logical Instructions that performs compare operations,

rotational operations, and gate operations like OR, AND, NOT,

XOR.

Page 35: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 35

� Branch instructions for looping and branching of instruction like

jumping and calling subroutines.

� Machine Control Instructions that controls machine to stop

operation (HLT) or no operation (NOP).

� Stack control instructions that are used in programming the

stack memory. (A Chosen part of RAM for special purpose use)

and

� Interrupt instructions that control the interrupts and invokes the

interrupt programs

• PROGRAM

o A program consists of sequence of instructions.

o Instructions are written in sequence of addresses.

o The addresses used for writing instructions cannot be used for data

storage. For example, if addresses 8000h to 8FFFH are used for

writing instructions, the data required for those instructions should

not be written in the same addresses. It can be written in any other

usable segment of addresses like 9000H to 9FFFH.

• STEPS FOR WRITING PROGRAM

o The steps for writing program are algorithm design, instruction

choosing for relevant algorithm,

o For writing the program, Algorithm is designed first. With the help of

the algorithm, instructions are chosen from instruction set and are

written in sequence.

o After writing the instructions, logically the instructions are verified

with sample data. Then the program is written in the assembler.

Page 36: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 36

• ALGORITHM DESIGN

o Let us take an example, adding two 8-bit numbers

o ADDING TWO 8-BIT NUMBERS

� The two 8-bit DATA (to be added) shall be stored in data

memory addresses (External). Thus to copy them into the CPU

we need to use register A (Accumulator) only. Other registers

B, C, D, E, H and L cannot be used for this purpose. (While in

16 bit Copy from memory addresses H and L registers can be

used together as a pair)

� Since two 8-bit numbers are added, two 8-bit registers shall be

used for the purpose. For arithmetic and logical operations

register A (Accumulator) is one of the register

� As shown in the below figure, Two 8-bit DATA to be added are

fed in usable memory address. For example, memory address

9000H holds DATA1 and 9001H holds DATA2.

� DATA1 is fetched by Reg A (Instruction: LDA 9000) and Copied

into Reg B (Instruction: MOV B,A) and DATA2 is fetched by Reg

A (Instruction: LDA 9001). Now Reg A holds DATA2 and Reg B

hold DATA1.

LDA 9000

MOV B,A

LDA 9001

Note: Any USABLE address can be used in the above

instructions.

� Both data are added (Instruction: ADD B) by using ALU

(Arithmetic Logic Unit). It generates the SUM and stores it in

Reg A (8-BIT OPERATIONS).

ADD B

Page 37: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 37

� CARRY is generated in CARRY/BORROW flag usually called as

CARRY flag. If Carry is generated CARRY flag becomes Binary 1

else becomes Binary 0.

� CARRY cannot be copied into any register directly. Thus

Instruction JNC (Jump NO Carry) is used, where

• When carry flag is Binary 1, then next Instruction INR C

is executed. This instruction Increments Register C.

• When carry flag is Binary 0, then next Instruction INR C

is skipped and NOT executed.

JNC ADDRESS_1

INR C

ADDRESS_1

� Now SUM is in register A (Accumulator) and Carry is simulated

in Register C.

� The Added SUM and CARRY are stored in Memory as follows.

� The SUM in register A is stored directly to any memory address

(Instruction: STA 9500).

ADDRESS_1 STA 9500

� The Carry stored in register C is Copied in Register A

(Instruction: MOV A,C) and then it is stored in the next Higher

memory address 9501H (Instruction: STA 9501)

MOV A,C

STA 9501

� The program stops now using Instruction HLT or RST 1

RST 1

Page 38: Microprocessor Labmanual

Sathyabama University Department of Electronics and Telecommunication Engineering

Semester V Microprocessor, Interfacing and Applications Laboratory-Manual, 38

Now the program is consolidated as follows

MVI C,00

LDA 9000

MOV B,A

LDA 9001

ADD B

JNC ADDRESS_1

INR C

ADDRESS_1 STA 9500

MOV A,C

STA 9501

RST 1

Figure explaining adding process of two 8-bit data in 8085

The above program is used for adding two 8-bit numbers using 8085 assembler.

Address DATA

9000 33

9001 44

Address DATA

9500 77

9501 00

MEMORY UNIT

44

33 Reg

A

33

SUM

CARRY

SUM

Reg

B

Reg

A

ALU

Reg

A

+

Reg

C

Reg

A

CARRY FLAG, JNR (JUMP NO CARRY) INSTRUCTION, INR INSTRUCTION ARE

USED TO COPY CARRY FLAG DATA INTO REGISTER A AND THEN TO REG C.