//NOTE: This code is meant to be compiled on a 32bit x86 machine. I don't have a 64bit machine available to do this for that arch at the moment. #include extern "C" int asm_data; extern "C" int asm_func(int x); //_Z7cppfunci, _Z is a prefix to tell us how it's mangled, 7 is the length of the function name, i means 1 int param extern "C" int asm_caller(int x, int y); //_Z7cppfuncii, which translates to how you predict it to. int cppfunc(int x){ return x << 2; } //Same as asm_func(), so we won't use it. int cppfunc(int x, int y){ return x << y; } //We're not actually going to use this one. int main(int argc, char** argv){ int input1 = 6, input2 = 1; printf("asm_func(%i) returns %i\n", input1, asm_func(input1)); printf("asm_caller(%i, %i) return %i\n", input1, input2, asm_caller(input1, input2)); printf("asm_data = 0x%x\n", asm_data); //No mangling for global data, so it's just as easy the other direction. return 0; }