D
D
dominy2021-08-26 03:45:01
assembler
dominy, 2021-08-26 03:45:01

Why is function definition not found?

Hello, I'm writing my first masm calculator function that squares
a number.

//cpp-file
#include <iostream>

extern "C"
{
  int square(int num);
}

int main()
{
  int num;
  std::cin >> num;
  std::cout << square(num);
}

;masm32-file

.386
.model tiny, C

.code
    square PROC
         push    ebp
         mov     ebp, esp
         mov     eax, DWORD PTR [ebp+8]
         imul    eax, DWORD PTR [ebp+8]
         pop     ebp
         ret
    square ENDP
end

there are no errors, but the compiler says that the function has no definition, although it is in the asm file, how can I fix this
6126e436b7004447323990.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2021-08-26
@jcmvbkbc

the function does not have a definition, although it is in the asm file, how can I fix this

change in the assembler source square PROCto square PROC PUBLIC.
Make sure that the assembler source is compiled and linked with the project.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question