Skip to content

Instantly share code, notes, and snippets.

@justinvh
Created February 8, 2019 05:34
Show Gist options
  • Save justinvh/b55ebd5111d4e8fe66da8a565b437ea8 to your computer and use it in GitHub Desktop.
Save justinvh/b55ebd5111d4e8fe66da8a565b437ea8 to your computer and use it in GitHub Desktop.
int main() {
short x = 42;
short y = 25;
switch (x) {
short x = 42;
short y = 25;
case 42: return y;
case 84: return y;
default: return y;
}
}
//
0000000000000000 <main>:
int main() {
0: 55 push rbp
1: 48 89 e5 mov rbp,rsp
short x = 42;
4: 66 c7 45 fa 2a 00 mov WORD PTR [rbp-0x6],0x2a
short y = 25;
a: 66 c7 45 fc 19 00 mov WORD PTR [rbp-0x4],0x19
switch (x) {
10: 0f bf 45 fa movsx eax,WORD PTR [rbp-0x6]
14: 83 f8 2a cmp eax,0x2a
17: 74 07 je 20 <main+0x20>
19: 83 f8 54 cmp eax,0x54
1c: 74 08 je 26 <main+0x26>
1e: eb 0c jmp 2c <main+0x2c>
short x = 42;
short y = 25;
case 42: return y;
20: 0f bf 45 fe movsx eax,WORD PTR [rbp-0x2]
24: eb 0a jmp 30 <main+0x30>
case 84: return y;
26: 0f bf 45 fe movsx eax,WORD PTR [rbp-0x2]
2a: eb 04 jmp 30 <main+0x30>
default: return y;
2c: 0f bf 45 fe movsx eax,WORD PTR [rbp-0x2]
}
}
30: 5d pop rbp
31: c3 ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment