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 Irvine32 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 3 to n/2, 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
.586P
.MODEL FLAT, stdcall ; Flat Memory Model
PUBLIC PROCEDURE1
_TEXT SEGMENT ; Tells the assembler what type of the following is
.data
primeArray DWORD 3,5,7,11,13,17,19,23,29,31,37,41,43,47
.code
PROCEDURE1 PROC Prime: DWORD
MOV ECX, 0
L1:
MOV eax, [primeArray+ecx*4]
CMP Prime, eax
JE L2
inc ECX
CMP ecx, 14
jl L1
mov eax, 0
RET
L2:
mov eax, 1
RET
PROCEDURE1 ENDP
_TEXT ENDS
END
C++ code provided:
#include
//prototype for COPYSTR extern function (in this case in asm file)
extern "C" int _stdcall PROCEDURE1( int);
int main()
{
char dest[100]={0};
char* source = "Enter a number";
char* source1= "The number is prime";
char* source2= "Tne number is not prime";
int test1=7;
int prime = PROCEDURE1(test1);
if(prime ==1)
{
printf("%s
",source1);
}
else
{
printf("%s
",source2);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!