어셈블리어-스택
(gdb) list 1,25
1#include <stdio.h>
2int Temp(int a)
3{
4int b=1;
5
6if(a==1)
7{
8a++;
9}
10else
11{
12b++;
13}
14
15return b;
16}
17
18int main(int argc, char* argv[])
19{int c=20;
20Temp(1);
21}
(gdb) set disassembly-flavor intel
(gdb) disassemble main
Dump of assembler code for function main:
0x0804840f <+0>:push ebp
0x08048410 <+1>:mov ebp,esp
0x08048412 <+3>:sub esp,0x14
0x08048415 <+6>:mov DWORD PTR [ebp-0x4],0x14 함수의 지역변수 b
0x0804841c <+13>:mov DWORD PTR [esp],0x1 main함수의 지역변수 c
0x08048423 <+20>:call 0x80483ed <Temp>
0x08048428 <+25>:leave
0x08048429 <+26>:ret
End of assembler dump.
(gdb) disassemble Temp
Dump of assembler code for function Temp:
0x080483ed <+0>:push ebp
0x080483ee <+1>:mov ebp,esp
0x080483f0 <+3>:sub esp,0x10
0x080483f3 <+6>:mov DWORD PTR [ebp-0x4],0x1
0x080483fa <+13>:cmp DWORD PTR [ebp+0x8],0x1 첫 번째 파라미터
0x080483fe <+17>:jne 0x8048406 <Temp+25>
0x08048400 <+19>:add DWORD PTR [ebp+0x8],0x1
0x08048404 <+23>:jmp 0x804840a <Temp+29>
0x08048406 <+25>:add DWORD PTR [ebp-0x4],0x1
0x0804840a <+29>:mov eax,DWORD PTR [ebp-0x4]
0x0804840d <+32>:leave
0x0804840e <+33>:ret
ebp+0x4: 리턴 어드레스
0 개의 댓글