Skip to content

Instantly share code, notes, and snippets.

@kinoshita-lab
Last active December 14, 2015 05:49
Show Gist options
  • Save kinoshita-lab/5038141 to your computer and use it in GitHub Desktop.
Save kinoshita-lab/5038141 to your computer and use it in GitHub Desktop.
Comparison between call by reference and call by value part 2
The Code:
int add_ref(const int& a, const int& b)
{
return a + b;
}
int add_value(const int a, const int b)
{
return a + b;
}
----------------------------------------------------------------------------
Compile with: gcc 4.7.1
arm-none-eabi-g++ -O3 -S hoge.cpp -o hoge.generic_arm.s
----------------------------------------------------------------------------
The Result (simpilified):
_Z7add_refRKiS0_:
ldr r3, [r0, #0]
ldr r0, [r1, #0]
adds r0, r3, r0
bx lr
_Z9add_valueii:
adds r0, r0, r1
bx lr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment