_
_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. 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.
Logic
What is a prime number? A prime number is a natural number it has no positive divisor other than 1 and itself. 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.
Logic
- 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.
- 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),....2
- When the reminder=0, the number is 'Not Prime', else 'Prime'
- XOR CX,CX /*Clearing the registers*/
- XOR DX,DX /*Clearing the registers*/
- MOV AX,[1500] /*Assume the number is store in memory 1500*/
- MOV BX,AX /*Copy the value in AX to BX */
- DEC BX
- DIV BX /*Dividing*/
- CMP DX,0000 /*Check for Reminder, Reminder is stored in DX*/
- JZ step 13
- XOR DX,DX /*Clearing DX*/
- CMP BX,0002
- JNZ step 5
- MOV CX,0001
- MOV [2000],CX /*Storing the result*/
- HLT
_How to program stepper motor in microprocessor 8086 assembly language
_
How to Control stepper motor using Microprocessor 8086 by assembly language program?.
As we all know that stepper motor driver plays an important role in automatic control system. We can create a stepper motor controller using 8086 microprocessor and 8255 Programmable Periferal Interface IC. Here is the assembly language program for 8086 microprocessor.
Notations used(xxxx...)B=Binary Number(xx......)H=Hexa Decimal NumberCW=Control Word register
You must know!
Program
2000 MOV BX,1000 /*Move a value to BX*/
2002 DEC BX /*Decrementing the value*/
CMP BX,0000 /*Check whether the value reach 0000*/
JNZ 2002 /*If not 0000, Decrement again*/
RET /*Return to the Motor program*/
How to Control stepper motor using Microprocessor 8086 by assembly language program?.
As we all know that stepper motor driver plays an important role in automatic control system. We can create a stepper motor controller using 8086 microprocessor and 8255 Programmable Periferal Interface IC. Here is the assembly language program for 8086 microprocessor.
Notations used(xxxx...)B=Binary Number(xx......)H=Hexa Decimal NumberCW=Control Word register
You must know!
- Stepper motor is interface with the help of 8255 IC (Programmable Periferal Interface).
- 8255 has two modes of operation BSR mode & IO mode. The mode is determined by the Control Word (CW) register, whose address is 26.
- Initialize the CW with (0000 0000)B=(00)H for BSR mode & (1000 0000)B=(80)H for IO mode
- Stepper motor is IO device so CW=(80)H
- There are 4 poles in a typical stepper motor A1, A2, B1, B2
- Energize the poles for Anticlockwise rotation
- So we, out these set of values to the IO port of 8255
Program
- MOV AL,80 /*Move 80(hex) to AL*/
- OUT 26,AL /*Move 80(Hex) to PPI, 26 is the CW of PPI*/
- MOV AL,0A /*Energizing the poles*/
- OUT 20,AL
- CALL 2000 /*Give some delay to rotate Motor*/
- MOV AL,06
- OUT 20,AL
- CALL 2000
- MOV AL,05
- OUT 20,AL
- CALL 2000
- MOV AL,09
- OUT 20,AL
- CALL 2000
- JMP line 3 /*Repeat the steps*/
- HLT
2000 MOV BX,1000 /*Move a value to BX*/
2002 DEC BX /*Decrementing the value*/
CMP BX,0000 /*Check whether the value reach 0000*/
JNZ 2002 /*If not 0000, Decrement again*/
RET /*Return to the Motor program*/