Sorry for my language mistakes . My OS is Windows.My computer has 64 bit processor.I should call an Intel x86/x64 assembly function in c code.I should write two asm functions (intel x64 and x86) and call these functions in c code.I compile and run this either on visual studio 2017 or cmd.I should take input from console, send the input to asm function.I write asm function name above the main function in c code for declaration.
For x64:
Firstly, I want to compile and run x64.asm with main.c in visual studio.I create an empty console application project.Add main.c and add asm.For asm file, Properties -> Excluded from Build -> No, Item Type ->Microsoft Macro Assembler.I set debugger options to x64. When I build and compile project I had some errors so I tried compiling from console.
I installed mingw-w64, nasm-2.12.01rc2-installer-x64 on my computer .mingw-w64 supports both x86 and x64.
So I enter below codes and compile, I am successful while compiling x64 codes.
nasm -f elf64 x64.asm -o x64.o
gcc -m64 -c mainx64.c -o mainx64.o
gcc -m64 mainx64.o x64.o -o x64
x86:
Although I use it with x64 correctly from console, I am not able to compile it with x86.Because I dont know how can I set enable-multilib property to true.
Firstly, to compile it, I installed mingw-get-setup ans select gcc and other related features which are all 32 bit, on my computer.I set path for these 32 bit mingw on environment variables in this case. This time, I enter the following codes in cmd:
nasm -f elf32 x86.asm -o x86.o
gcc -m32 -c mainx86.c -o mainx86.o
gcc -m32 mainx86.o x86.o -o x86
x86.o:mainx86.c:(.text+0x14b): undefined reference to `x86FunctionName' collected2.exe: error: ld returned 1 exit status
I also tried with VS, set debugger options to x86, but it gives me so many errors again.At the end of the errors, there is also an error like :
MSB3721 The command "ml.exe /c /nologo /Zi /Fo"Debug\x86.obj" /W3 /errorReport:prompt /T x86FunctionName.asm" exited with code 1. MyProject C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\BuildCustomizations\masm.targets 69
RESULTS: I am not able to both x64 and x86 in VS.I compile x64 with console but I am not able to compile x86 on console.
EDIT:
int Find(unsigned char* input);
int main(int argc, char** argv)
{
.........
int output = Find(buffer + 54);
}
x86.asm
global Find
%define row_in_bytes[ebp-4]
Find:
push ebp