Just like the title suggests. Say, I want to do this with a Godbolt project:
main.cpp
#include <iostream>
extern "C" int test_111();
int main()
{
int r = test_111();
std::cout << "result=" << r << std::endl;
return 0;
}
and then in asm1.asm
:
.code
test_111 PROC
; 64-bit assembly
xor eax, eax
inc rax
ret
test_111 ENDP
END
Trying it under "x86-64 clang" (any version).
But I can't seem to figure out how to do this. Any suggestions?
PS. The goal is to inject my own assembly instructions into the output.
EDIT:
After a suggestion in the comments, I tried the asm volatile
key words, but it simply adds whatever gibberish I put in there into the assembly output:
Using the Tree mode, you can set up a CMake project with multiple files, including asm:
Godbolt Link
To make it work, I had to enable
nasm
support in theCMakeLists.txt
file and manually set the path to the assembler