8051 code to find number of prime numbers in array stored in memory with starting address 0xA0
What is a prime number?
Code goes here:
MAIN: MOV R1,#0XA0 ;memory faddress rom where all numbers to be checked are stored
MOV R0,#10H ; memory address to store all the prime numbers from an array.
MOV R2,#10 ; length of array
DIV AB ;Dividing the number by 2
CJNE R3,#01H,LABEL2 ;Checking whether the number is 2
LABEL1:DEC R3 ; decrementing and checking whether the number is not divisible by all possible values of number/2
MOV @R0,B ; moving the prime number to the array
CJNE R4,#0H,LABEL1 ; checking whether the number is divisible any number
CJNE R2,#0H,LABEL5 ; verifying whether the counter has reacged to zero