8085 Practicals Journal
8085 Practicals Journal
8085 Practicals Journal
INDEX
Sr. Description Page Date Teacher's
No. No. Signature
1 Familiarization with 8085 microprocessor kit
2 Program to add two 8-bit numbers
3 Program to add two 16-bit numbers
4 Program to add subtract 8-bit numbers
5 Program that multiplies two 1 byte hex numbers
6 Program to find absolute difference between two nos.
7 Program to divide a 1 byte dividend by 1 byte divisor
8 Program to add the contents of block of memory
9 Program to transfer a block of data in reverse order
10 Program to exchange the contents of two blocks
11 Program to find the smallest as well as greatest
number from given block using linear search
12 Program to sort the data in ascending order
13 Program to sort the data in descending order
14 Program to search for the first occurrence of a number
in a given block of data
15 Program to count the occurrence of number in given
block of data
16 Program to find number of odd as well as even
numbers in given block
17 Program to convert a 2 digit BCD number into its
equivalent binary number
18 Program to convert binary number into its BCD
equivalent
19 To identify the working of given program in 8085
20 Program to multiply two 1 byte numbers by rotation
21 Study of transmission media
22 Study of modem, hub, repeaters and routers
Practical No. 2
Aim : To perform addition of two 8-bit numbers
Flow Chart:
Start
Is No
carry=1?
YES
Stop
Algorithm :
Program:
Result :
Input Output
2100 FF 2200 04
2101 05 2201 01
Practical No. 3
Is carry = No
1?
YES
Stop
Algorithm :
Program:
Input Output
2100 A2 2200 A4
2101 02 2201 D3
2102 D2
2103 01
Practical No. 4
Aim : To perform subtraction of two 8-bit numbers
Flow Chart:
Start
Is carry = No
1?
YES
Stop
Algorithm :
Program:
Result :
Input Output
2100 02 2200 04
2101 06 2201 00
Practical No. 5
Aim : To perform multiplication of two 8-bit numbers
Flow Chart:
Start
Is carry
No
= 1?
YES
Increment reg. D
Contents
of C=0?
NO
YES
Stop
Algorithm :
Program:
Input Output
2100 02 2200 06
2101 03 2201 00
Practical No. 6
Aim : To find absolute difference between two numbers.
Flow Chart:
Start
Is carry
No
= 1?
YES
Stop
Algorithm :
Program:
Result :
Input Output
2100 06 3100 04
2101 02 3102 00
Practical No. 7
Aim : To divide a 1 byte dividend by 1 byte divisor.
Flow Chart:
Start
reg. C of reg. B
Subtract contents
Increment reg. C
Is carry No
= 1?
YES
Store the result in accumulator
Stop
Algorithm :
Program:
Result :
Output
2200 01
2201 03
Practical No. 8
Aim : A block of data is stored in memory locations from 2200h. Another block
of data having the same length is stored in memory locations starting from
2300h. Write a program to add the contents of block of memory.
Flow Chart:
Start
Is Z = 1? NO
YES
Stop
Algorithm :
Step 1: Initialize H-L pair to source memory location 2200H for first block.
Step 2: Initialize B-C pair to source memory location 2300H for second block.
Step 3: Initialize D-E pair to destination memory location 2400H.
Step 4: Load second block contents to accumulator.
Step 5; Add H-L pair contents with accumulator.
Step 6: Store the byte from accumulator to destination D-E pair location.
Step 7: Increment the source pointer H-L pair.
Step 8: Increment the source pointer B-C pair.
Step 9: Increment the destination pointer D-E pair
Step 10: Move the lower byte of H-L pair to accumulator.
Step 11: Compare the accumulator contents with 0Ah.
Step 12: Jump to Step 6 if zero flag is not set.
Step 13: Halt
Program:
Flow Chart:
Start
Decrement counter C.
Is Counter No
= 0?
Yes
Stop
Algorithm :
Program:
Result :
Input Output
2100 01 3100 09
2101 02 3102 08
2102 03 3103 07
2103 04 3104 06
2104 05 3105 05
2105 06 3106 04
2106 07 3107 03
2107 08 3108 02
2108 09 3109 01
Practical No. 10
Aim : A block of data is stored in memory locations from 2501h. Another block
of data having the same length is stored in memory locations starting from
3501h. Size of the block is stored in memory location 2500h.Write a
program to exchange the contents of these two blocks.
Flow chart :
Start
Initialize D-E pair with address one byte less than actual
destination
Decrement counter C.
NO
Is Counter =
0?
YES
Stop
Algorithm :
Step 1: Initialize HL register pair as a pointer to memory location for counter
Step 2: Initialize the counter Reg C
Step 3: Initialize DE register pair as a pointer to memory location 3500H
Step 4: Increment HL pair and DE pair
Step 5: Get the contents of memory location 2501H into B register
Step 6: Get the contents of memory location 3501H into A register
Step 7: Store the contents of A register into memory location 2501H
Step 8: Copy the contents of B register into accumulator
Step 9: Store the contents of A register into memory location 3501H
Step 10: Decrement contents of C
Step 11: If counter is not zero, jump to Step 4
Step 12: Halt
Program:
Address Label Mnemonics Opcode Comment
2000 LXI H, 2500 21 ; Initialize HL reg pair as a pointer to memory location 2500H.
2001 00
2002 25
2003 MOV C, M 4E ; Initialize the counter
2004 LXI D, 3500 11 ; Initialize DE reg pair as a pointer to memory location 3501H
2005 00
2006 35
2007 LOOP: INX H 23 ; Increment HL pair
2008 INX D 13 ; Increment DE pair
2009 MOV B, M 46 ; Get the contents of memory location 2501H into B register
200A LDAX D 1A ; Get the contents of memory location 3501H into A register
200B MOV M, A 77 ; Store the contents of A register into memory location 2501H
200C MOV A, B 78 ; Copy the contents of B register into accumulator
200D STAX D 12 ; Store the contents of A register into memory location
3501H.
200E DCR C 0D ; Decrement contents of C
200F JNZ LOOP C2 ; If counter is not zero, jump to LOOP
07
20
2010 HLT 76 ; Halt
Result :
Input Output
2500 0A (Count) 2500 0A (Count)
2501 01 3501 11 2501 11 3501 01
2502 02 3502 12 2502 12 3502 02
2503 03 3503 13 2503 13 3503 03
2504 04 3504 14 2504 14 3504 04
2505 05 3505 15 2505 15 3505 05
2506 06 3506 16 2506 16 3506 06
2507 07 3507 17 2507 17 3507 07
2508 08 3508 18 2508 18 3508 08
2509 09 3509 19 2509 19 3509 09
250A 0A 350A 1A 250A 1A 350A 0A
Practical No. 11
Aim : A block of data is stored in memory locations from 2100h to 2109h.
Write a program to find the smallest as well as greatest number from given
block using Linear Search. Store the results immediately after the end of the block.
Flow Chart:
Start
Contents of Reg
YES
A > Memory ?
NO
Move the accumulator contents to Reg D
Is Counter = YES
0?
NO
A
A
Stop
Algorithm:
Step 1: Load the address of the first element (Count) of the array in HL pair.
Step 2: Move the count to Reg. B.
Step 3: Increment the pointer.
Step 4: Get the first data in Reg. C and D.
Step 5: Decrement the count.
Step 6: Increment the memory pointer.
Step 7: Move this number in accumulator.
Step 8: Compare the content of Reg C with accumulator.
Step 9: If Carry = 1, go to step 11 else goto step 10.
Step 10: Move the contents of accumulator to Reg C.
Step 11: If Carry = 0, go to step 13 else goto step 12.
Step 12: Move the contents of accumulator to Reg D.
Step 13: Decrement the counter.
Step 14: If counter = 0, go to step 6. If counter is not Zero, goto next step
Step 15: Move the reg. C contents to accumulator.
Step 16: Store the largest data in memory location 2200h.
Step 17: Move the reg. D contents to accumulator.
Step 18: Store the largest data in memory location 2201h.
Step 19: Halt
Program :
Result :
Input Output
2100 09 2200 09
2101 01 2201 01
2102 07
2103 09
2104 05
2105 06
2106 03
2107 08
2108 04
2109 02
Practical No. 12
Aim : A block of data is stored in memory locations from 2201h. The length of
the block is stored at 2200. Write a program that sorts the given data in
Ascending Order.
Start
Flow Chart:
Initialize Counter 1
NO Is contents of (memory
pointer – 1) > contents
of (Pointer)?
YES
NO Is Counter2
= 0?
YES
Decrement Counter 1
NO Is Counter1
= 0?
YES
Stop
Algorithm :
Step 1: Initialize the HL pair with memory location 2100H to get count of numbers
Step 2: Move the contents of memory to Reg. C i.e. counter
Step 3: Decrement Reg. C
Step 4: Load HL pair with address 2101H
Step 5: Move contents of memory to Reg. A
Step 6: Increment HL Pair
Step 7: Compare memory with Reg. A
Step 8: If contents of A are less or equal, don’t interchange
Step 9: Interchange the numbers
Step 10: Increment HL pair
Step 11: Decrement counter 2
Step 12: If counter is not zero, jump to Step 4
Step 13: Decrement counter 1
Step 14: If counter 1 is not zero, jump to Step 2
Step 15: Halt
Program:
Address Label Mnemonics Opcode Comment
2000 LXI H, 2100H 21 ;Initialize HL pair with memory location 2100H
2001 00
2002 21
2003 MOV C, M 4E ;Move the contents of memory to Reg. C
2004 DCR C 0D ;Decrement Reg. C
2005 REPEAT: MOV D, C 51 ; Move the contents of C to D (Counter 2)
2006 LXI H, 2101H 21 ; Load HL pair with address 2101H
2007 01
2008 21
2009 LOOP: MOV A, M 7E ; Move contents of memory to Reg. A
200A INX H 23 ; Increment HL Pair
200B CMP M BE ; Compare memory with Reg. A
200C JC SKIP DA
200D 14
200E 20
200F MOV B, M 46 ; Move contents of M to B
2010 MOV M, A 77 ; Move contents of A to M
2011 DCX H 2B ; Decrement HL Pair
2012 MOV M, B 70 ; Move contents of B to M
2013 INX H 23 ; Increment HL pair
2014 SKIP: DCR D 15 ; Decrement D
2015 JNZ LOOP C2 ; Jump if Contents of D are not zero
2016 09
2017 20
2018 DCR C 0D ; Decrement contents of C
2019 JNZ REPEAT C2 ; Jump if contents of C are not zero
201A 05
201B 20
201C HLT 76 ; Halt
Result :
Input Output
2100 09 2100 09
2101 01 2101 01
2102 07 2102 02
2103 09 2103 03
2104 05 2104 04
2105 06 2105 05
2106 03 2106 06
2107 08 2107 07
2108 04 2108 08
2109 02 2109 09
Practical No. 13
Aim : A block of data is stored in memory locations from 2201h. The length of
the block is stored at 2200. Write a program that sorts the given data in
Descending Order.
Start
Flow Chart:
Initialize Counter 1
NO
NO Is Counter2
= 0?
YES
Decrement Counter 1
NO
Is Counter1
= 0?
YES
Stop
Algorithm :
Step 1: Initialize the HL pair with memory location 2100H to get count of numbers
Step 2: Move the contents of memory to Reg. C i.e. counter
Step 3: Decrement Reg. C
Step 4: Load HL pair with address 2101H
Step 5: Move contents of memory to Reg. A
Step 6: Increment HL Pair
Step 7: Compare memory with Reg. A
Step 8: If contents of A are greater, don’t interchange
Step 9: Interchange the numbers
Step 10: Increment HL pair
Step 11: Decrement counter 2
Step 12: If counter is not zero, jump to Step 4
Step 13: Decrement counter 1
Step 14: If counter 1 is not zero, jump to Step 2
Step 15: Halt
Program:
Address Label Mnemonics Opcode Comment
2000 LXI H, 2100H 21 ;Initialize the HL pair with memory location
2100H
2001 00
2002 21
2003 MOV C, M 4E ;Move the contents of memory to Reg. C
2004 DCR C 0D ;Decrement Reg. C
2005 REPEAT: MOV D, C 51 ; Move the contents of C to D (Counter 2)
2006 LXI H, 2101H 21 ; Load HL pair with address 2101H
2007 01
2008 21
2009 LOOP: MOV A, M 7E ; Move contents of memory to Reg. A
200A INX H 23 ; Increment HL Pair
200B CMP M BE ; Compare memory with Reg. A
200C JNC SKIP D2
200D 14
200E 20
200F MOV B, M 46 ; Move contents of M to B
2010 MOV M, A 77 ; Move contents of A to M
2011 DCX H 2B ; Decrement HL Pair
2012 MOV M, B 70 ; Move contents of B to M
2013 INX H 23 ; Increment HL pair
2014 SKIP: DCR D 15 ; Decrement D
2015 JNZ LOOP C2 ; Jump if Contents of D are not zero
2016 09
2017 20
2018 DCR C 0D ; Decrement contents of C
2019 JNZ REPEAT C2 ; Jump if contents of C are not zero
201A 05
201B 20
201C HLT 76 ; Halt
Result :
Input Output
2100 09 2100 09
2101 01 2101 09
2102 07 2102 08
2103 09 2103 07
2104 05 2104 06
2105 06 2105 05
2106 03 2106 04
2107 08 2107 03
2108 04 2108 02
2109 02 2109 01
Practical No. 14
Aim: A block of data is stored in memory locations from 2101h. Length of the
block is stored at 2100h. Write program that searches for first occurrence
of the data byte 05h in the given block. Store the address of this occurrence
in the HL pair. If number not found, then HL pair must contain 0000h.
Flow Chart:
Start
YES
Is Zero Flag
= 1?
NO
NO
Is Reg B =
0?
YES
Stop
Algorithm :
Step 1: Initialize H-L pair to get the count of numbers and store it in Reg B
Step 2: Store the number to be searched in Reg C
Step 3: Initialize H-L pair for number to search and store it in Reg A
Step 4: Compare contents of Reg C
Step 5: If Reg A = Reg C, goto Step 8 else goto Step 6
Step 6: Increment HL pair and Decrement the counter i.e. Reg B
Step 7: If Reg B contents are zero, store 0000h in HL pair else goto Step 3
Step 8: Store the contents of HL pair at 2200h
Step 9: Halt
Program:
Address Label Mnemonics Opcode Comment
2000 LXI H, 2100 21 ; Initialize memory pointer to get the count
2001 00
2002 21
2003 MOV B, M 46 ; Store the count into Reg B
2004 LXI H, 2101 21 ; Initialize memory pointer for data
2005 01
2006 21
2007 MVI C, 05h 0E ; Store the number to be searched in Reg C
2008 05
2009 REPEAT: MOV A, M 7E ; Move contents of Memory to Reg A
200A CMP C B9 ; Compare contents of Reg A with Reg C
200B JZ LAST CA ; Jump if Reg A = Reg C
200C 1C
200D 20
200E INX H 23 ; Increment HL pair contents
200F DCR B 05 ; Decrement Reg B
2010 JNZ REPEAT C2 ; Jump if contents of Reg B is not zero
2011 09
2012 20
2013 LXI H, 0000h 21 ; Load HL pair with address 0000h
2014 00
2015 00
2016 SHLD 2200h 22 ; Store contents of HL pair to address 2200h
2017 00
2018 22
2019 JMP END C3 ; Jump to END
201A 1F
201B 20
201C LAST: SHLD 2200h 22 ; Store memory address to memory 2200h
201D 00
201E 22
201F END: HLT 76 ; Halt
Result :
Flow Chart:
Start
Initialize H-L pair to memory location of 1st data to compare & Reg E for count
YES
Is Zero Flag
= 1?
NO
NO
Is Reg B =
0?
YES
Move contents of Reg E to Reg A
Stop
Algorithm :
Step 1: Initialize H-L pair to get the count of numbers and store it in Reg B
Step 2: Store the number to be searched in Reg C
Step 3: Load HL pair for number to compare and store it in Reg A
Step 4: Compare contents of Reg C
Step 5: If Reg A ! = Reg C, goto Step 8 else goto Step 6
Step 6: Increment HL pair and Decrement the counter i.e. Reg B
Step 7: If Reg B contents are not zero, goto step 3 else goto step 8
Step 8: Increment contents of Reg E
Step 9: Move contents of Reg E into Reg A and store it to memory 2200h
Step 9: Halt
Program:
Address Label Mnemonics Opcode Comment
2000 LXI H, 2100 21 ; Initialize memory pointer to get the count
2001 00
2002 21
2003 MOV B, M 46 ; Store the count into Reg B
2004 LXI H, 2101 21 ; Initialize memory pointer for data
2005 01
2006 21
2007 MVI C, 05h 0E ; Store the number to be searched in Reg C
2008 05
2009 REPEAT: MOV A, M 7E ; Move contents of Memory to Reg A
200A CMP C B9 ; Compare contents of Reg A with Reg C
200B JNZ NEXT C2 ; Jump if Reg A != Reg C
200C 0F
200D 20
200E INR E 1C ; Increment Reg E
200F NEXT: INX H 23 ; Increment HL pair contents
2010 DCR B 05 ; Decrement Reg B
2011 JNZ REPEAT C2 ; Jump if contents of Reg B is not zero
2012 09
2013 20
2014 MOV A, E 7B ; Move the contents of Reg E to Reg A
2015 STA 2200h 32 ; Store contents of accumulator into 2200h
2016 00
2017 22
2018 HLT 76 ; Halt
Result :
Flow Chart:
Start
Decrement Counter B
YES
Is Counter = 0?
NO
Initialize destination Memory Pointer with 2600
Stop
Algorithm :
Program:
Result :
Input Output
2500 11 2600 01
2501 12 2601 04
2502 14
2503 16
2504 18
Practical No. 17
Aim : Write a program to convert a 2 digit BCD number into its equivalent binary
number.
Flow Chart:
Start
Decrement counter C
No
Is C contents
= 0?
YES
Increment contents of HL pair
Stop
Algorithm :
Program:
Result :
Input Output
2100 02 2200 1D
2101 09
Practical No. 18
Aim : Write a program to convert binary number into its BCD equivalent.
Flow Chart:
Start
NO Is carry = 0?
YES
Is C contents = 0? NO
YES
Store the byte from accumulator to destination
Stop
Algorithm :
Program:
Result :
Input Output
2100 1D 3100 29
Practical No. 19
Aim : A program is stored at given memory location copy the contents of this
memory locations on paper and disassemble the program using opcode sheet. Draw the
flowchart and write the working of given program in 8085.
Address Opcode
2000 16
2001 08
2002 06
2003 00
2004 0E
2005 01
2006 21
2007 00
2008 30
2009 46
200A 23
200B 71
200C 78
200D 81
200E 41
200F 4F
2010 23
2011 77
2012 15
2013 C2
2014 0C
2015 20
2016 76
Program:
Flow Chart:
Start
B
A
B
A
NO
Is Counter = 0?
YES
Stop
Algorithm:
Output
3001 01
3002 01
3003 02
3004 03
3005 05
3006 08
3007 0D
3008 15
3009 22
Practical No. 20
Aim : Write a program to multiply two 1 byte numbers by rotation.
Flow Chart:
Start
Stop
Algorithm :
Result :
Output
3050 14