- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

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

# 8085 program to determine if the number is prime or not

In this program we will see how to check a number is prime or not using 8085.

## Problem Statement

Write 8085 Assembly language program to check whether a given number is prime or not.

## Discussion

Here the approach is little bit different. We are actually counting the number of unique factors. For prime numbers the factors are only two. The 1 and the number itself. So if the result is 02H, then it is prime, otherwise not a prime number. As there is no division operation, we have to perform division by subtracting repeatedly.

## Input

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

F100 | 07 |

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

F100 | FF |

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

F100 | 2F |

**Flow Diagram**

## Program

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

F000 | 21, 00, F1 | | LXI H,F100 | Point to F100 to take the number |

F003 | FE | | MOV A,M | Take the number into Accumulator |

F004 | 0E | | MVI C,00 | Clear C register |

F006 | 57 | | MOV D,A | Copy A to D |

F007 | 5F | | MOV E,A | Copy A to E |

F008 | 42 | L2 | MOV B,D | Load B with D |

F009 | B8 | L1 | CMP B | Compare B with A |

F00A | DA, 11, F0 | | JC LABEL | if carry is generated, jump to Label |

F00D | 90 | | SUB B | Subtract B from A |

F00E | C2, 09, F0 | | JNZ L1 | Jump to L1 |

F011 | FE, 00 | LABEL | CPI 00 | Compare A with 00H |

F013 | C2, 17, F0 | | JNZ SKIP | If Z = 0, jump to SKIP |

F016 | 0C | | INR C | Increase C by 1 |

F017 | 7B | SKIP | MOV A,E | Load A with E again |

F018 | 15 | | DCR D | Decrease D by 1 |

F019 | C2, 08, F0 | | JNZ L2 | Jump to L2 label if Z = 0 |

F01C | 79 | | MOV A,C | Load C to A |

F01D | 32, 01, F1 | | STA F101 | Store result into F101 |

F020 | 76 | | HLT | Terminate the program |

## Output

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

F150 | 02 |

This is Prime

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

F150 | 08 |

This is not prime

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

F150 | 02 |

This is Prime

- Related Articles
- Bash program to check if the Number is a Prime or not
- C# Program to check if a number is prime or not
- Python program to check if a number is Prime or not
- PHP program to check if a number is prime or not
- Python Program to Find if a Number is Prime or Not Prime Using Recursion
- Write a C# program to check if a number is prime or not
- Find the largest prime number required to test as a divisor to determine if the following number is a prime number. Also determine if the number is a prime number: 117
- C++ Program to Check Whether a Number is Prime or Not
- C Program to Check Whether a Number is Prime or not?
- Java Program to Check Whether a Number is Prime or Not
- 8085 program to check whether the given 16 bit number is palindrome or not
- Check if a number is Quartan Prime or not in C++
- Check if a number is Primorial Prime or not in Python
- Check if a number is Primorial Prime or not in C++
- Write a Golang program to check whether a given number is prime number or not

Advertisements