- Related Questions & Answers
- Program to check for two out of five code in 8085 Microprocessor
- 8085 Program to check for palindrome
- Program to check for palindrome in 8085 Microprocessor
- Check for Valid hex code - JavaScript
- 8085 code to convert binary number to ASCII code
- 8085 program to subtract two BCD numbers
- 8085 Program to Multiply two numbers of size 8 bits
- 8085 Program to find the HCF of two given bytes
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to add two consecutive bytes of an array
- 8085 program to subtract two consecutive bytes of an array
- 8085 Program to Check the fourth bit of a byte
- Check for Power of two in JavaScript
- 8085 Program to convert two-digit hex to two ASCII values

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Now let us see a program of Intel 8085 Microprocessor. This program will help us to check a given value is a valid 2 out of 5 code or not.

**Problem Statement**:

Write 8085 Assembly language program to check whether a given number is 2 out of five code or not. The number is stored at location 8000H.

**Discussion**:

The checking of two out of five code is simple. At first we have to check the higher order three bits are 0 or not. If they are 0, then we will check next five bits. If there are exactly two 1s in these 5-bits, then it is a valid 2 out of 5 code.

Here at first we are ANDing the number by (1110 0000), if the first three bits are 0, then the result will be 0, after that we are checking the number of 1s by using rotating operation. Using rotation operation if the carry flag is enabled, then the count will be increased. Thus the total count of 1s will be reflected.

This program will store FFH into location 8050H if the number is valid 2 out of 5 code, otherwise it will store 00H into 8050H.

**Input**:

First Input

Address | Data |
---|---|

... | . . . |

8000 | 12 |

... | . . . |

Second Input

Address | Data |
---|---|

... | . . . |

8000 | 13 |

... | . . . |

Third Input

Address | Data |
---|---|

... | . . . |

8000 | 03 |

... | . . . |

**Flow Diagram**:

**Program**:

Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|

F000 | 3A, 00, 80 | LDA 8000H | Load the number from memory | |

F003 | 67 | MOV H,A | Load A to H | |

F004 | 2E, 00 | MVI L,00H | Clear register L | |

F006 | E6, E0 | ANI E0H | AND Acc and 11100000b | |

F008 | C2, 21, F0 | JNZ DONE | If Z = 0, go to Done | |

F00B | 7C | MOV A,H | Load H to A | |

F00C | 0E, 05 | MVI C,05H | Load C with 05H for counting | |

F00E | 16, 00 | MVI D,00H | Clear register D | |

F010 | 0F | LOOP | RRC | Rotate acc content to the right |

F011 | D2, 15, F0 | JNC SKIP | If CY = 0, jump to skip | |

F014 | 14 | INR D | Increase D by 1 | |

F015 | 0D | SKIP | DCR C | Decrease C by 1 |

F016 | 10, F0 | JNZ LOOP | Jump to LOOP | |

F019 | 3E, 02 | MVI A,02H | Initialize A with 02H | |

F01B | BA | CMP D | Compare D with A | |

F01C | C2, 21, F0 | JNZ DONE | if Z = 0, go to DONE | |

F01F | 2E, FF | MVI L,FFH | Load L with FFH | |

F021 | 7D | DONE | MOV A,L | Take result from L to A |

F022 | 32, 50, 80 | STA 8050H | Sore result at 8050H | |

F025 | 76 | HLT | Terminate the program |

**Output**:

First Output

Address | Data |
---|---|

... | . . . |

8050 | FF |

... | . . . |

Second Output

Address | Data |
---|---|

... | . . . |

8050 | 00 |

... | . . . |

Third Output

Address | Data |
---|---|

... | . . . |

8050 | FF |

... | . . . |

Advertisements