Question: Use the Irvine 3 2 library. Dynamically Generate Prime Numbers Modify the procedure.asm so that prime numbers are dynamically calculated instead of looking up in
Use the Irvine library. Dynamically Generate Prime Numbers
Modify the procedure.asm so that prime numbers are dynamically calculated instead of looking up in an array. To find out if an input, n is a prime number, make a loop that ranges from to n then divide n by i the loop number then check the remainder of the division, if there is no remainder for the division the number n is not prime.
ASM provided code
P
MODEL FLAT, stdcall ; Flat Memory Model
PUBLIC PROCEDURE
TEXT SEGMENT ; Tells the assembler what type of the following is
data
primeArray DWORD
code
PROCEDURE PROC Prime: DWORD
MOV ECX,
L:
MOV eax, primeArrayecx
CMP Prime, eax
JE L
inc ECX
CMP ecx,
jl L
mov eax,
RET
L:
mov eax,
RET
PROCEDURE ENDP
TEXT ENDS
END
C code provided:
#include
prototype for COPYSTR extern function in this case in asm file
extern C int stdcall PROCEDURE int;
int main
char dest;
char source "Enter a number";
char source "The number is prime";
char source "Tne number is not prime";
int test;
int prime PROCEDUREtest;
ifprime
printfs
source;
else
printfs
source;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
