Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

first 3. There are many ways to determine prime numbers. Here is a design for on

ID: 3706416 • Letter: F

Question

first 3. There are many ways to determine prime numbers. Here is a design for one way to find the primes. Implement this design in 80x86 assembly language. Using the console32 or console64 frame- work, write a program that stores the primes in an array of doublewords primeArray, and examine the contents of primeArray using the debugger. primel1]: 2; { first prime number ) prime[2] :# 3:1 second prime number } primeCount: 2; candidate: 5;{first candidate for a new prime) while primeCount primeCount then (no existing prime evenly divides the candidate, so it is a new prime) add 1 to primeCount; prime[primeCount]:-candidate; end if add 2 to candidate; end while;

Explanation / Answer

;# 8086 Program to check the given no for Prime # ;# Author: kingspp # ;################################################## ;NUM is assigned to the Number to be checked ;AL is used as the default no ;BL is used as Dividing Variable. It is Incremented in each loop ;BH is used to know the number of variables which can divide the Number. BH>02, The number is not prime ;BL is made to run x number of times, where x is the given number. ; Declaration Part .MODEL SMALL .DATA MSG DB "The Give No is a Prime No$" NMSG DB "The Given No is not a Prime No$" NUM DB 71H ;Enter the required no here .CODE START: MOV AX,@DATA MOV DS,AX MOV AL,NUM MOV BL,02H ; The Dividing starts from 2, Hence BH is compare to 02H MOV DX,0000H ; To avoid Divide overflow error MOV AH,00H ; To avoid Divide overflow error ;Loop to check for Prime No L1:DIV BL CMP AH,00H ; Remainder is compared with 00H (AH) JNE NEXT INC BH ; BH is incremented if the Number is divisible by current value of BL NEXT:CMP BH,02H ; If BH > 02H, There is no need to proceed, It is not a Prime JE FALSE ; The no is not a Prime No INC BL ; Increment BL MOV AX,0000H ; To avoid Divide overflow error MOV DX,0000H ; To avoid Divide overflow error MOV AL,NUM ; Move the Default no to AL CMP BL,NUM ; Run the loop until BL matches Number. I.e, Run loop x no of times, where x is the Number given JNE L1 ; Jump to check again with incremented value of BL ;To display The given no is a Prime No TRUE: LEA DX,MSG MOV AH,09H ; Used to print a string INT 21H JMP EXIT ;To display The given no is not a Prime No FALSE: LEA DX,NMSG MOV AH,09H ; Used to print a string INT 21H EXIT: MOV AH,4CH INT 21H END START