How to check prime number using assembly language program

What is a Prime number?
A prime number is a natural number it has no positive divisor other than 1 and itself.

Prime number checking program is a beginner program for any programming language. In 8086 assembly language, checking prime number is an interesting logic.

Here is the microprocessor 8086 assembly language program to check whether the given number is prime or not.

It is a common program for beginners who wish to study basic programming steps in assembly language for 8086 microprocessor.

Read Also: Stepper Motor Interfacing with 8086
What is a Prime number

Logic of Prime Number Check in Assembly Code

  • Before going to the assembly code let me explain the programming logic first.
  • Suppose the given number is 'x'. Let us divide the number x with (x-1). I.e. x/(x-1).
  • Now check the reminder status. Reminder is store in DX register b default.
  • Now divide x with x-2, i.e. x/(x-2) then check the reminder.
  • Repeat this step up to the denominator become 2.
  • Denominator is like (x-1), (x-2),(x-3),....etc. 2
  • When the reminder=0, the number is 'Not Prime', else it is 'Prime'

Prime Number Program in 8086

Now let’s see the 8086 assembly language code for prime number checking.
If you have any doubts regarding to the above described assembly language program feel free to ask using the comment box below. Keep visiting CircuitsGallery for more about 8086.
You may also like: 

No comments:

Post a Comment