0% found this document useful (0 votes)
6K views44 pages

Ex. No: 1 8 Bit Addition Date: Aim

The document describes assembly language programs to perform various numeric operations on 8-bit and 16-bit numbers using an 8085 microprocessor, including addition, subtraction, multiplication, and BCD arithmetic. It provides the aim, algorithm, program, inputs, outputs, and result for each example. The examples cover 8-bit and 16-bit addition and subtraction, 8-bit multiplication, BCD subtraction and multiplication. The programs demonstrate how to load data, perform the arithmetic operations, store results, and verify outputs.

Uploaded by

Anbumani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6K views44 pages

Ex. No: 1 8 Bit Addition Date: Aim

The document describes assembly language programs to perform various numeric operations on 8-bit and 16-bit numbers using an 8085 microprocessor, including addition, subtraction, multiplication, and BCD arithmetic. It provides the aim, algorithm, program, inputs, outputs, and result for each example. The examples cover 8-bit and 16-bit addition and subtraction, 8-bit multiplication, BCD subtraction and multiplication. The programs demonstrate how to load data, perform the arithmetic operations, store results, and verify outputs.

Uploaded by

Anbumani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Ex.

No: 1 8 BIT ADDITION


Date :
AIM:
To add two 8 bit numbers using 8085 microprocessor kit or simulator.
ALGORITHM:
Step 1: Register A and B are loaded with the data to be added.
Step 2: Register C is cleared to store sum.
Step 3: Move the contents of any one register to accumulator.
Step 4: Add the contents of other registers with accumulator.
Step 5: Store the results present in accumulator in register C.
Step 6: Halt.
PROGRAM:
ADDRESS OPCODE MNEMONICS
8000 06
MVI B, A2
8001 A2
8002 16
MVI D, 39
8003 39
8004 0E
MVI C, 00
8005 00
8006 78 MOV A,B
8007 82 ADD D
8008 4F MOV C, A
8009 CF RST

INPUT:
B A2
D 39
OUTPUT:
C DB

RESULT:
Thus the assembly language program for 8 bit addition was executed successfully and
the output was verified.

1
Ex. No: 2 16 BIT ADDITION
Date :
AIM:
To add two 16 bit binary number using 8085 microprocessor kit or simulator.
ALGORITHM:
Step1: Load HL register pair with the data from the memory location 8085 and
8051H.
Step2: Move the contents of the HL register pair to DE register pair.
Step3: Load the HL register pair with the data from the memory location 8086 and
8061H.
Step4: Add the register pair DE and HL.
Step5: Store the result present in HL register pair to the memory location.
Step6: Verify the result present in memory.
Step7: Halt.
PROGRAM:
ADDRESS OPCODE MNEMONICS
8000 2A
8001 50 LHLD,8050 H
8002 80
8003 EB XCHG
8004 2A
8005 60 LHLD,8060 H
8006 80
8007 19 DAD D
8008 22 SHLD 8070 H
8009 70
800A 80
800B 76 HLT

INPUT:
8050 1E 8051 30
8060 FF 8061 2C
OUTPUT:
8070 1D 8071 50
RESULT:
Thus an assembly language program for 16 bit addition was executed successfully and
the output was verified.

2
Ex. No: 3 8 BIT SUBTRACTION
Date :
AIM:
To subtract 8 bit number using 8085 microprocessor kit or simulator.
ALGORITHM:
Step1: Store two 8 bit number which to be subtracted in successive memory location.
Step2: Load accumulator with the first data in memory.
Step3: Increment the memory location to point to the second 8 bit numbers.
Step4: Subtract the contents of the memory location with the content of the
accumulator.
Step5: Increment the memory location to store the result.
Step6: Move the content of the accumulator to the memory location.
Step7: Verify the result in the memory.
Step8: Halt.
PROGRAM:
ADDRESS OPCODE MNEMONICS
8000 21
8001 50 LXI H,8050 H
8002 80
8003 7E MOV A,M
8004 23 INX H
8005 96 SUB M
8006 23 INX H
8007 77 MOV M,A
8008 76 HLT

INPUT:
8050 4C
8051 32
OUTPUT:
8052 1A
RESULT:
Thus an assembly language program for 8 bit subtraction was executed successfully
and the output was verified.

3
Ex. No: 4 BCD SUBTRACTION
Date :
AIM:
To subtract two 8 bit BCD numbers using 8085 microprocessor kit or simulator.
ALGORITHM:
Step1: Store the minu end in register B and subtracted in a accumulator.
Step2: Transfer content of accumulator subtracted to register C.
Step3: Load 99 in accumulator to find the 9’s complement.
Step4: Subtract the subtracted from accumulator.
Step5: Increment the accumulator to get the 10’s complement of the subtracted.
Step6: Add the contents of B with the contents of accumulator.
Step7: Using DAA instructions convert the intermediate result in the accumulator to
BCD.
Step8: Store the result in memory.
Step9: Halt.
PROGRAM:
ADDRESS OPCODE MNEMONICS
8000 3A
8001 51 LDA 8051 H
8002 80
8003 4F MOV C, A
8004 3E
MVI A, 99
8005 99
8006 91 SUB C
8007 3C INR A
8008 47 MOV B, A
8009 3A
800A 50 LDA 8050
800B 80
800C 80 ADD B
800D 27 DAA
800E 32
800F 50 STA 9050
8010 90
8011 76 HLT

4
INPUT:
8050 72
8051 35
OUTPUT:
9050 37

RESULT:
Thus an assembly language program for BCD subtraction was executed successfully.

5
Ex. No: 5 8 BIT MULTIPLICATION
Date :
AIM:
To write an assembly language program to multiply 8 bit numbers in 8085
microprocessor kit or simulator.
ALGORITHM:
STEP1: Load the multiplier from the memory to the accumulator.
STEP2: Transfer the multiplier to B register.
STEP3: Load the multiplicand from the memory to the accumulator.
STEP4: Transfer the multiplier to register.
STEP5: Initialize accumulator to zero.
STEP6: Clear the D register for storing the carry.
STEP7: Add multiplicand in C register to accumulator.
STEP8: If the value in accumulator exceeds FFH increment D register by one.
STEP9: Decrement the multiplier in B by one.
STEP10: If the value in B register becomes zero store the result present in the
accumulator to memory.
STEP 11: Store the high byte of the result present in D register in memory.
STEP 12: HLT.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 3A
8001 50 LDA 8050
8002 80
8003 47 MOV B, A
8004 3A
8005 51 LDA 8051
8006 80
8007 4F MOV C, A
8008 AF XRA A
8009 57 MOV A
HERE 800A 81 ADD C
800B D2
800C 0F JNC 800E (GOTO)
800D 80
GOTO 800E 14 INC D
800F 05 DCR B
8010 C2 JNZ 800A (HERE)
8011 0A

6
8012 80
8013 32 STA 8053
8014 52
END LOOP 8015 80
8016 7A MOV A, D
8017 32
8018 53 STA 8053
8019 80
801A 76 HLT
INPUT/OUTPUT:
8050 04
8051 24

8052 90
8053 00

RESULT:
Thus an assembly language program for 8 bit multiplication has been executed
successfully.

7
Ex. No: 6 BCD MULTIPLICATION
Date :
AIM:
To write an assembly language program to multiply BCD numbers in 8085
microprocessor kit or simulator.
ALGORITHM:
STEP1: Load the multiplier from the memory to the accumulator.
STEP2: Transfer the multiplier to B register.
STEP3: Load the multiplicand from the memory to the accumulator.
STEP4: Transfer the multiplier to register C.
STEP5: Initialize accumulator to zero.
STEP6: Add the contents of register B with that of the accumulator.
STEP7: Convert the content of accumulator to BCD using DAA instruction.
STEP8: Decrement the register C by one.
STEP9: If content of register C is not zero goto Step 4.
STEP10: Store the content of the accumulator to memory.
STEP 11: HLT.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 3A
8001 50 LDA 8050
8002 80
8003 47 MOV B, A
8004 3A
8005 51 LDA 8051
8006 80
8007 4F MOV C, A
8008 AF XRA A
AGAIN 8009 80 ADD B
800A 27 DAA
800B 0D DCR C
800C C2
800D 09 JNC 8009 (AGAIN)
800E 80
800F 32
8010 53 STA 8053
8011 80
8012 76 HLT

8
INPUT/OUTPUT:
8050 27
8051 03

8053 81

RESULT:
Thus an assembly language program for BCD multiplication has been executed
successfully.

9
Ex. No: 7 8 BIT DIVISION
Date :
AIM:
To write an assembly language program to divide 8 bit numbers in 8085
microprocessor kit or simulator.
ALGORITHM:
STEP1: Store the division and dividend in register B and accumulator respectively.
STEP2: Clear register to store the quotient.
STEP3: Subtract the division from the dividend until the dividend is less than the
dividend
STEP4: Number of times subtraction in performed gives the quotient.
STEP5: The content of accumulator gives the remainder.
STEP6: The results are stored in memory.
STEP7: HLT.

PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 3A
8001 50 LDA 8050
8002 80
8003 47 MOV B, A
8004 3A
8005 51 LDA 8051
8006 80
8007 0E MVI C, 00
8008 00
8009 B8 CMP B
800A DA
800B 13 JC 8013 (END)
800C 80
RPT 800D 90 SUB B
800E 0C INR C
800F B8 CMP B
8010 D2
8011 0D JNC 800D (RPT)
8012 80
END 8013 32
8014 52 STA 8052
8015 80

10
8016 79 MOV A, C
8017 32
8018 53 STA 8053
8019 80
801A CF RST

INPUT/OUTPUT:
8050 02
8051 0B

8052 01
8053 05

RESULT:
Thus an assembly language program for 8 bit division has been executed
successfully.

11
Ex. No: 8 SEARCHING FOR AN ELEMENT IN AN ARRAY
Date :
AIM:
To write an assembly language program to search the data in an array using 8085
microprocessor kit.
ALGORITHM:
STEP1: Store the search data in register D.
STEP2: Store the number of elements in an array in register C.
STEP3: Move the first data present in the array to accumulator.
STEP4: Compare the search data with the contents of accumulator.
STEP5: If equal move FF to accumulator and go step 9.
STEP6: If not equal increment the memory location to point to the next data in the
array and store it in the accumulator.
STEP7: Decrement the count present in register CIF not zero.
STEP8: Clear the contents of accumulator.
STEP9: Store the contents of accumulator memory.
STEP10: Stop the execution.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 16
MVI O,A2H
8001 A2
8002 0E
MVI L,05H
8003 05
8004 21
8005 50 LXI H,8050H
8006 80
LOOP 8007 7E MOV A,M
8008 BA
8009 C2 CMP D
800A 15
800B 80 JZ END
800C 7E INX H
800D BA PCR C
800E C2
800F 07
8010 80 JNC LOOP
8011 AF XRA A
8012 C3 JMP LAST
8013 17
8014 80

12
END LOOP 8015 3E MV A,FF,H
8016 FF
8017 21
8018 00 LXI M,8500
8019 85
801A 77 MOV M,A
801B CF RST 1

INPUT 1:
D A2
C 05
8050 C3
8051 89
8052 A2
8053 74
8054 E7
OUTPUT 1:
8500 FF

INPUT 2:
D A2
C 05
8050 C3
8051 89
8052 A2
8053 74
8054 E7
OUTPUT 1:
8500 00
RESULT:
Thus an assembly language program for searching an element in an array has been
executed successfully and the output was verified.

13
Ex No: 9 SORTING IN ASCENDING ORDER

Date :

Aim:
To write a program to arrange the array of data in ascending order in microprocessor
kit or simulator.

Algorithm:

Step 1: Initialize HL pair as memory pointer.


Step 2: Get the count at 4200 into C register.
Step 3: Copy it in D register (for bubble sort (N-1) times required).
Step 4: Get the first value in A register.
Step 5: Compare it with the value at next location.
Step 6: If they are out of order, exchange the contents of A register and Memory.
Step 7: Decrement D register content by 1.
Step 8: Repeat steps 5 and 7 till the value in D register become zero.
Step 9: Decrement C register content by 1.
Step 10: Repeat steps 3 to 9 till the value in C register becomes zero.

PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 00 LXI H, 8200
8002 82
8003 4E MOV C, M
8004 0D DCR C
REPEAT 8005 51 MOV D,C
8006 21
8007 01 LXI H, 8201
8008 82
LOOP 8009 7E MOV A,M
800A 23 INX H
800B BE CMP M
800C DA
800E 15 JC 8015 (SKIP)
800F 80
8010 46 MOV B,M
8011 77 MOV M, A
8012 2B DCX H
8013 70 MOV M, B
8014 23 INX H

14
SKIP 8015 15 DCR D
8016 C2
8017 09 JNZ 8009 (LOOP)
8018 80
8019 0D DCR C
8020 C2
8021 05 JNZ 8005 (REPEAT)
8022 80
8023 76 HLT

INPUT:
8200 05 (Size of the array)
8201 05
8202 04
8203 03
8204 02
8205 01
OUTPUT:
8200 05 (Size of the array)
8201 01
8202 02
8203 03
8204 04
8205 01

RESULT:
Thus an assembly language program to arrange the elements in an array is ascending
order to written executed successfully.

15
Ex. No: 10 (a) LARGEST ELEMENT IN AN ARRAY
Date :
AIM:

To find the largest number in an array of data using 8085 instruction set.

ALGORITHM:

Step 1: Load the address of the first element of the array in HL pair.
Step 2: Move the count to B register.
Step 3: Increment the pointer.
Step 4: Get the first data in A register.
Step 5: Decrement the count.
Step 6: Increment the pointer.
Step 7: Compare the content of memory addressed by HL pair with that of A
register.
Step 8: If Carry = 0, go to step 10 or if Carry = 1 go to step 9
Step 9: Move the content of memory addressed by HL to A register.
Step 10: Decrement the count.
Step 11: Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to
next step.
Step 12: Store the largest data in memory.
Step 13: Halt.

PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 00 LXI H, 8200
8002 82
8003 46 MOV B, M
8004 23 INX H
8005 7E MOV A, M
8006 05 DCR B
LOOP 8007 23 INX H
8008 BE CMP M
8009 D2
800A 0D JNC 800D (AHEAD)
800B 80

16
800C 7E MOV A, M
AHEAD 800D 05 DCR B
800E C2
800F 07 JNZ 8007 (LOOP)
8010 80
8011 32
8012 00 STA 8300
8013 83
8014 76 HLT

INPUT/OUTPUT:

8200 05

8201 01

8202 02

8203 03

8204 04

8205 05

8300 05

RESULT:
Thus an assembly language program to find the largest element in an array is executed
successfully.

Ex. No: 10 (b) SMALLEST ELEMENT IN AN ARRAY

17
Date :
AIM:

To find the smallest number in an array of data using 8085 instruction set.

ALGORITHM:

Step 1: Load the address of the first element of the array in HL pair
Step 2: Move the count to B register.
Step 3: Increment the pointer
Step 4: Get the first data in A register.
Step 5: Decrement the count.
Step 6: Increment the pointer
Step 7: Compare the content of memory addressed by HL pair with that of A
register.
Step 8: If Carry = 0, go to step 10 or if Carry = 1 go to step 9
Step 9: Move the content of memory addressed by HL to A register.
Step 10: Decrement the count
Step 11: Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to
next step.
Step 12: Store the largest data in memory.
Step 13: Halt.

PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 00 LXI H, 8200
8002 82
8003 46 MOV B, M
8004 23 INX H
8005 7E MOV A, M
8006 05 DCR B
LOOP 8007 23 INX H
8008 BE CMP M
8009 DA
800A 0D JC 800D (AHEAD)
800B 80
800C 7E MOV A, M

18
AHEAD 800D 05 DCR B
800E C2
800F 07 JNZ 8007 (LOOP)
8010 80
8011 32
8012 00 STA 8300
8013 83
8014 76 HLT

INPUT/OUTPUT:

8200 05

8201 01

8202 02

8203 03

8204 04

8205 05

8300 01

RESULT:
Thus an assembly language program to find the smallest element in an array is
executed successfully.

Ex. No: 11 REVERSING ARRAY ELEMENTS


Date :

19
AIM:

To reverse the array elements using 8085 microprocessor kit or simulator.

ALGORITHM:

Step 1: Load the address where the count and the element of the given array are
stored.
Step 2: Store the count in register C.
Step 3: Point to the address of reverse array.
Step 4: Move the data from the given array to accumulator and store it in the
reverse array.
Step 5: Update the pointers of the given array and reverse array.
Step 6: Decrement register C if not zero go to step 4.
Step 7: Halt.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 00 LXI H, 8500
8002 85
8003 4E MOV C, M
8004 11
8005 00 LXI D, 8600
8006 86
8007 23 INX H
LOOP 8008 7E MOV A, M
8009 12 STAX D
800A 1B DCX D
800B 23 INX H
800C 0D DCR C
800D C2
800E 08 JNC 8008 (LOOP)
800F 80
8010 76 HLT

INPUT/OUTPUT:

8500 05

20
8501 7E

8502 F4

8503 47

8504 83

8505 76

85FC 76

85FD 83

85FE 47

85FF F4

8600 7E

RESULT:
Thus an assembly language program to reverse the element in an array is executed
successfully.

Ex. No: 12 BLOCK MOVE

Date :
AIM:

21
To implement the block move concept in array using 8085 microprocessor kit or
simulator.

ALGORITHM:
Step 1: Load register pair HL with the address 8500.
Step 2: Load register pair DE with the address 8600
Step 3: Move the content at memory location into accumulator.
Step 4: Store the content of accumulator into memory pointed by DE.
Step 5: Increment value of register pair HL and DE by 1.
Step 6: Decrements value of register C by 1.
Step 7: If zero flag not equal to 1, go to step 3.
Step 8: Halt.

PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 0E
MVI C, 05
8001 05
8002 21
8003 00 LXI H,
8004 85
8005 11
8006 00 LXI D, 8600
8007 86
LOOP 8008 7E MOV A, M
8009 12 STAX D
800A 23 INX H
800B 13 INX D
800C 0D DCR C
800D C2
800E 08 JNZ 8008 (LOOP)
800F 80
8010 76 HLT

INPUT/OUTPUT:

8500 05

8501 7E

22
8502 F4

8503 47

8504 83

8505 76

8600 7E

8601 F4

8602 47

8603 83

8604 76

RESULT:
Thus an assembly language program to move the array element using block move
concept is executed successfully.

Ex No: 13 SORTING IN DESCENDING ORDER

Date :

AIM:
To write a program to arrange the array elements in descending order.

23
ALGORITHM:

Step 1: Initialize HL pair as memory pointer.


Step 2: Get the count at 4200 into C register.
Step 3: Copy it in D register (for bubble sort (N-1) times required).
Step 4: Get the first value in A register.
Step 5: Compare it with the value at next location.
Step 6: If they are out of order, exchange the contents of A register and Memory.
Step 7: Decrement D register content by 1.
Step 8: Repeat steps 5 and 7 till the value in D register become zero.
Step 9: Decrement C register content by 1.
Step 10: Repeat steps 3 to 9 till the value in C register becomes zero.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 00 LXI H, 8200
8002 82
8003 4E MOV C, M
8004 0D DCR C
REPEAT 8005 51 MOV D,C
8006 21
8007 01 LXI H, 8201
8008 82
LOOP 8009 7E MOV A,M
800A 23 INX H
800B BE CMP M
800C D2
800E 15 JNC 8015 (SKIP)
800F 80
8010 46 MOV B,M
8011 77 MOV M, A
8012 2B DCX H
8013 70 MOV M, B
8014 23 INX H
SKIP 8015 15 DCR D
8016 C2
8017 09 JNZ 8009 (LOOP)
8018 80
8019 0D DCR C
8020 C2
8021 05 JNZ 8005 (REPEAT)
8022 80

24
8023 76 HLT

INPUT:
8200 05 (Size of the array)
8201 01
8202 02
8203 03
8204 04
8205 01

OUTPUT:
8200 05 (Size of the array)
8201 05
8202 04
8203 03
8204 02
8205 01

RESULT:
Thus an assembly language program to arrange the elements in an array is descending
order to written executed successfully.

Ex. No: 14 (a) BCD TO HEX CONVERSION

Date :
AIM:

To convert the BCD numbers in memory to equivalent HEX using 8085


microprocessor kit or simulator.

25
ALGORITHM:
Step 1: Initialize memory pointer to 8050.
Step 2: Get the most significant digit.
Step 3: Multiply the MSD by ten using repeated addition.
Step 4: Add the least significant digit to the result obtained in previous step.
Step 5: Store the HEX data in memory.
Step 6: Halt.

PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 21 LXI H, 8050
8001 50
8002 80
8003 7E MOV A, M
8004 87 ADD A
8005 47 MOV B, A
8006 87 ADD A
8007 87 ADD A
8008 80 ADD B
8009 23 INX H
800A 86 ADD M
800B 23 INX H
800C 77 MOV M, A
800D 76 HLT

INPUT:
8050 02
8051 09

26
OUTPUT:
8052 1D

RESULT:
Thus an assembly language program to convert BCD to HEX is executed
successfully.

Ex. No: 14 (b) HEX TO BCD CONVERSION

Date :
AIM:
To convert HEX number to BCD number using 8085 microprocessor kit or

27
simulator.

ALGORITHM:
Step 1: Initialize memory pointer to 8050.
Step 2: Get the hexa decimal number in C register.
Step 3: Perform repeated addition for C number of times.
Step 4: Adjust for BCD in each step.
Step 5: Store the BCD in each step.
Step 6: Halt.

PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 50 LXI 8050
8002 80
8003 16
MVI D, 00
8004 00
8005 AF XRA
8006 4E MOV C, M
LOOP 2 8007 C6
ADI 01
8008 01
8009 27 DAA
800A D2
800B 0E JNC
800C 80
800D 14 INR D
LOOP 1 800E 0D DCR C
800F C2
8010 07 JNZ 8007
8011 80
80012 32
80013 51 STA 8051
8014 80
8015 7A MOV A, D
8016 32
8017 52 STA 8052
8018 80
8019 76 HLT

INPUT:
8050 FF

OUTPUT:

28
8051 55

8052 02

RESULT:
Thus an assembly language program to convert HEX to BCD is executed
successfully.

Ex. No: 15 (a) BINARY TO ASCII CONVERSION

Date :
AIM:

29
To convert binary number to ASCII number using 8085 microprocessor kit or
simulator.

ALGORITHM:
Step 1: Load Accumulator with the data from memory.
Step 2: Copy the number into B.
Step 3: Set Carry Flag.
Step 4: Complement Carry Flag.
Step 5: Subtract 0A from A.
Step 6: When carry is present, A is numeric.
Step 7: Add 41H for Alphabet.
Step 8: Jump to store the value.
Step 9: Get back B to A.
Step 10: Add 30H with A to get ASCII.
Step 11: Point to next location to store address.
Step 12: Store A to memory location pointed by HL pair.
Step 13: Halt.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 50 LXI H, 8050
8002 80
8003 7E MOV A, M
8004 47 MOV B, A
8005 37 STC
8006 3F CMC
8007 D6
SUI 0A
8008 0A
8009 DA
800A 11 JC 8011 (NUM)
800B 80
800C C6
ADI 41
800D 41
800E C3
800F 14 JMP 8014 (STORE)
8010 80
NUM 8011 78 MOV A, B
8012 C6
ADI 30
8013 30
STORE 8014 23 INX H

30
8015 77 MOV M, A
8016 76 HLT

INPUT:
8050 0A

OUTPUT:
8051 41

RESULT:
Thus an assembly language program to convert binary to ASCII is executed
successfully.

Ex. No: 15 (b) ASCII TO BINARY CONVERSION

Date :
AIM:

31
To convert ASCII number to binary number using 8085 microprocessor kit or
simulator.

ALGORITHM:
Step 1: Load address of the number
Step 2: Load ASCII data to accumulator from memory
Step 3: Compare with ASCII (9) + 1
Step 4: The input is numeric
Step 5: Subtract offset to get Alphabetic character
Step 6: Store the result
Step 7: Subtract 30to get numeric value
Step 8: Point to next location
Step 9: Store Acc content to memory
Step 10: Halt.
PROGRAM:

LABEL ADDRESS OPCODE MNEMONICS


8000 21
8001 50 LXI H, 8050
8002 80
8003 7E MOV A, M
8004 FE
CPI 58
8005 58
8006 D2
8007 0E JNC 800E (NUM)
8008 80
8009 D6
SUI 37
800A 37
800B C3
800C 10 JMP 8010 (STORE)
800D 80
NUM 800E D6
SUI 30
800F 30
STORE 8010 23 INX H
8011 77 MOV M, A
8012 76 HLT

INPUT:
8050 41

OUTPUT:

32
8051 0A

RESULT:
Thus an assembly language program to convert ASCII to Binary is executed
successfully.

Ex. No: 16 (a) ASCII TO BCD CONVERSION

Date :
AIM:

33
To convert ASCII number to BCD number using 8085 microprocessor kit or
simulator.

ALGORITHM:

Step 1: Load ASCII data to Acc from memory in hexadecimal


Step 2: Subtract the Acc with (30)16 = (48)10
Step 3: Store the Acc content at 4101
Step 4: Halt.

PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 3A
8001 00 LDA 8100
8002 81
8003 D6
SUI 30
8004 30
8005 32
8006 01 STA 8101
8007 81
8008 76 HLT

INPUT:
8100 36

OUTPUT:
8101 06

RESULT:
Thus an assembly language program to convert ASCII to BCD is executed
successfully.

Ex. No: 16 (b) BCD TO ASCII CONVERSION

Date :
AIM:

34
To convert BCD number to ASCII number using 8085 microprocessor kit or
simulator.

ALGORITHM:
Step 1: Input the content of 2050 in accumulator.
Step 2: Move content of Accumulator to register B.

Step 3: Separate the least significant digit using AND with 0F and ADD 30 to
accumulator

Step 4: Store content of accumulator to memory location 3050

Step 5: Move content of register B to Accumulator

Step 6: Separate the most significant digit using AND with F0

Step 7: Rotate Content of Accumulator 4 times

Step 8: ADD 30 to accumulator

Step 9: Store content of accumulator to memory location 3051


Step 10: Halt.

PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 3A
8001 50 LDA 8050
8002 80
8003 47 MOV B, A
8004 E6
ANI 0F
8005 0F
8006 C6
ADI 30
8007 30
8008 32
8009 50 STA 9050
800A 90
800B 78 MOV A, B
800C E6
ANI F0
800D F0
800E 07 RLC
800F 07 RLC
8010 07 RLC
8011 07 RLC
8012 C6
ADI 30
8013 30
8014 32
8015 51 STA 9051
8016 90

35
8017 76 HLT

INPUT:
8050 98

OUTPUT:
9050 38
9051 39

RESULT:
Thus an assembly language program to convert BCD to ASCII is executed
successfully.

Ex. No: 17 SQUARE OF A NUMBER

Date :
AIM:

36
To find the square of a number in microprocessor 8085 kit or simulator.

ALGORITHM:
Step 1: Assign 20 to register H, 50 to register L and 00 to accumulator A.
Step 2: Load the content of memory location which is specified by M in register
B.
Step 3: Load the content of memory location which is specified by M is register
B.
Step 4: Add content of M in accumulator A and decrement value of B by 01.
Step 5: Check if B holds 00, if true then store the value of A at memory location
9050 otherwise goto step 3.
Step 6: Halt.
PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 26
MVI H, 80
8001 80
8002 2E
MVI L, 50
8003 50
8004 3E
MVI A, 00
8005 00
8006 46 MOV B, M
8007 86 ADD M
8008 05 DCR B
8009 C2
800A 07 JNZ 8007
800B 80
800C 32
800D 50 STA 9050
800E 90
800F 76 HLT

INPUT:
8050 03

37
OUTPUT:
8051 09

RESULT:
Thus an assembly language program to find the square of a number is executed
successfully.

Ex. No: 18 SQUARE OF BCD NUMBER

Date :

38
AIM:

To find the square of a BCD number in microprocessor 8085 kit or simulator.

ALGORITHM:
Step 1: Assign address location.
Step 2: Move the content of accumulator to D register.
Step 3: Load the address location to give input.
Step 4: Move the content of accumulator to B register.
Step 5: Move the content of accumulator to C register.
Step 6: Immediately move 00 to E register.
Step 7: Assign address location.
Step 8: Move the content of E register to accumulator.
Step 9: Add the content of B register with accumulator.
Step 10: Jump to step 13.
Step 11: Move the content of D to accumulator.
Step 12: Decrement the value of D.
Step 13: Call subroutine.
Step 14: Move the content of A to D.
Step 15: Jump to step 7.
Step 16: Call display address.
Step 17: Halt.
PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 AF
XRA A
8001 57
8002 3A
8003 50 LDA 8050
8004 80
8005 47 MOV B, A
8006 4F MOV C, A
8007 1E
MVI E, 00
8008 00
8009 AF XRA A
800A 7B MOV A, E
800B 80 ADD B
800C 27 DAA
800D 5F MOV E, A
800E D2 JNC 8016

39
800F 16
8010 80
8011 7A MOV A, D
8012 C6
ADI 01
8013 01
8014 27 DAA
8015 57 MOV D, A
8016 C2
8017 00 CALL 8100
8018 81
8019 C2
801A 0A JNZ 800A
801B 80
801C 0D
801D C0 CALL 13CO
801E 13
801F 76 HLT
SUB ROUTINE
8100 3E
MVI A, 99
8101 99
8102 D6
SUI 01
8103 01
8104 3C INR A
8105 81 ADD C
8106 27 DAA
8107 4F MOV C, A
8108 C9 RET

INPUT:
8050 03

OUTPUT:
8051 09

RESULT:
Thus an assembly language program to find the square of BCD number is executed
successfully.
Ex. No: 19 SQUARE ROOT OF A NUMBER

Date :
AIM:

40
To find the square root of a number in microprocessor 8085 kit or simulator.

ALGORITHM:
Step 1: Assign 01 to register D and E.
Step 2: Load the value, stored at memory location 8050 in accumulator A.
Step 3: Subtract value stored at accumulator A from register D.
Step 4: Check if accumulator holds 0, if true then jump to step 8.
Step 5: Increment value of register D by 2.
Step 6: Increment value of register E by 1.
Step 7: Jump to step 3.
Step 8: Move value stored at register E in A.
Step 10: Halt.
PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 10
MVI D, 01
8001 01
8002 1E
MVI E, 01
8003 01
8004 3A
8005 50 LDA 8050
8006 80
8007 92 SUB D
8008 CA
8009 11 JZ 8011
800A 80
800B 14 INR D
800C 14 INR D
800D 1C INR E
800E C3
800F 07 JMP 8007
8010 80
8011 7B MOV A, E
8012 32
8013 50 STA 9050
8014 90
8015 76 HLT

INPUT:
8050 09

41
OUTPUT:
8051 03

RESULT:
Thus an assembly language program to find the square root of a number is executed
successfully.

Ex. No: 20 SQUARE ROOT OF BCD NUMBER

Date :
AIM:

42
To find the square root of a number in microprocessor 8085 kit or simulator.

ALGORITHM:
Step 1: Assign address location.
Step 2: Move the content of accumulator to D register.
Step 3: Load the address location to give input.
Step 4: Move the content of accumulator to B register.
Step 5: Move the content of accumulator to C register.
Step 6: Immediately move 00 to E register.
Step 7: Assign address location.
Step 8: Move the content of E register to accumulator.
Step 9: Add the content of B register with accumulator.
Step 10: Jump to step 13.
Step 11: Move the content of D to accumulator.
Step 12: Decrement the value of D.
Step 13: Call subroutine.
Step 14: Move the content of A to D.
Step 15: Jump to step 7.
Step 16: Call display address.
Step 17: Halt.
PROGRAM:

ADDRESS OPCODE MNEMONICS


8000 AF XRA A
8001 4F MOV C, A
8002 3A
8003 50 LDA 8050
8004 80
8005 06
MVI B, 01
8006 01
8007 90 SUB B
8008 0C INR C
8009 CA
800A 20 JZ 8020
800B 80
800C 57 MOV D, A
800D 04 INR B
800E 04 INR B
800F CD
8010 00 CALL 8100
8011 81

43
8012 3E
MVI A, 99
8013 99
8014 90 SUB B
8015 3C INR A
8016 32 ADD D
8017 27 DAA
8018 0C INR C
8019 CA
801A 20 JZ 8020
801B 80
801C DA
801D 0C JC 800C
801E 80
801F CD
8020 C0 CALL C013
8021 13
8022 76 HLT
SUBROTINE
8100 F5 PUSH PSW
8101 78 MOV A, B
8102 C6
ADI 00
8103 00
8104 27 DAA
8105 47 MOV B, A
8106 F1 POP PSW
8107 C9 RET

INPUT:
8050 09

OUTPUT:
8051 03

RESULT:
Thus an assembly language program to find the square root of BCD number is
executed successfully.

44

You might also like