// code based on https://www.cs.uaf.edu/courses/cs301/2014-fall/notes/inline-assembly/ // this is the 32-bit version // // fastcall convention: first (word) arg in ecx, second in edx, remainder on stack // caller pops from stack, result in %eax // - see https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html // extern "C" long add100(long in); /* Prototype */ __asm__( /* Assembly function body */ "_add100:\n" " mov %rdi, %rax\n" " add $100, %rax\n" " ret\n" ); #include using namespace std; int main() { cout << "Enter a number: "; long num; cin >> num; long num_plus_100 = add100(num); cout << "Number plus 100: " << num_plus_100 << endl; return 0; }