Question: How to run both programs together, 1 is C++ the other is assembly? ASM: .586P .MODEL FLAT, stdcall ; Flat Memory Model PUBLIC PROCEDURE1 _TEXT

How to run both programs together, 1 is C++ the other is assembly?

ASM:

.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++:

#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 Databases Questions!