[source]
#include<stdio.h>
int main(int a)
{
a=3;
for(a;a<10;a++){
printf("Hello\n");}
return 0;
}
[debugging]
0x80483d0 <main>: push %ebp
0x80483d1 <main+1>: mov %esp,%ebp//SFP|ret
0x80483d3 <main+3>: movl $0x3,0x8(%ebp) //SFP| RET | int a=3
0x80483da <main+10>: lea 0x0(%esi),%esi //NOP(cf: http://stackoverflow.com/questions/10505690/what-is-the-meaning-of-lea-0x0esi-esi)
//많이 반복되는 부분앞에서는 전형적으로 NOP를 깔아줘야한다함.이러한 NOP들은 빠르게 fetch engine을 통해서 소비가된다(이러한 fetch engine들은 실행했을때가아닌 prefetch때에 완성되어있다)
0x80483e0 <main+16>: cmpl $0x9,0x8(%ebp) //ebp + 8 (ret 바로 뒷부분) 의값과 0x9를 비교
0x80483e4 <main+20>: jle 0x80483e8 <main+24>// 낮으면 main +24로 점프
0x80483e6 <main+22>: jmp 0x8048400 <main+48> // 크면 main + 48 로 점프
0x80483e8 <main+24>: push $0x8048460 // HELLO
0x80483ed <main+29>: call 0x8048308 <printf> //printf()
0x80483f2 <main+34>: add $0x4,%esp // esp+4 (intger 크기, a가 또사용되니까 esp
0x80483f5 <main+37>: incl 0x8(%ebp)// a값 증가 (incl =long increase )
0x80483f8 <main+40>: jmp 0x80483e0 <main+16>//for문으로 다시 점프
0x80483fa <main+42>: lea 0x0(%esi),%esi// 이부분에 왜 NOP가 존재하는지는 아직 모르겟다 ;
0x8048400 <main+48>: xor %eax,%eax // eax 비우기
0x8048402 <main+50>: jmp 0x8048404 <main+52> //완료됫을시 retn으로
0x8048404 <main+52>: leave
0x8048405 <main+53>: ret
'과거의 컴퓨터 공부 > C 디버깅' 카테고리의 다른 글
fflush() (0) | 2014.09.20 |
---|---|
gets() v.s scanf() (0) | 2014.09.20 |
if else (0) | 2014.09.19 |
main함수 옆에 파라메터 넣어보기 (0) | 2014.09.18 |
변수, printf 디버깅 (0) | 2014.09.17 |