I'm trying to embedd my x64 assembler code into c++, as i know x64 __asm
is not allowed in x64, so what i tried, is i made an asm defintion like this in func.asm
:
.code
proc_testing PROC
push rcx
pop rcx
proc_testing ENDP
END
And in my C code, main.c
:
#include "stdafx.h"
extern"C" void inline proc_testing();
int main()
{
proc_testing();
return 0;
}
I tought that inline
keyword would make the compiler not to call proc_testing()
but to place its code inside the main. Unfortunately it still make a call proc_testing
. In masm you have a keyword MACRO
also, but here i cannot use this, i get compilation error if use MACRO
instead of PROC
, i tried to do it like this:
.code
proc_testing MACRO
push rcx
pop rcx
proc_testing ENDM
END
This way i get an error: unmatched macro nesting
.
So i have a two question actually:
1) Can the masm assembly in x64 in visual studio be inline? So when i use proc_testing();
it will not do the call proc_testing
but actually place the code of proc_testing
inside the main
.
2) Can you make masm MACRO
to work outside the .asm
file? If So how can i achieve that?
So basically i need to get rid of the call
and place the assembly code directly at link/compile time. The assembler code is generated dynamically using some engine, so i cannot use compiler intrinsics, i would need to rewrite the asm generator for that.
And finally, if all the variants are not possible, can i do an analogy of _asm _emit
, to just place the machine code in hex, in the .text
inside the specific places?