어셈340줄 점점 늘어나네요..
(gdb) disass main
Dump of assembler code for function main:
0x0804844d <+0>: push ebp
0x0804844e <+1>: mov ebp,esp
0x08048450 <+3>: and esp,0xfffffff0
0x08048453 <+6>: sub esp,0x30
0x08048456 <+9>: mov DWORD PTR [esp+0x18],0x3
0x0804845e <+17>: mov DWORD PTR [esp+0x1c],0x4
0x08048466 <+25>: mov DWORD PTR [esp+0x20],0x2
0x0804846e <+33>: mov DWORD PTR [esp+0x24],0x1
0x08048476 <+41>: mov DWORD PTR [esp+0x28],0x7
0x0804847e <+49>: mov DWORD PTR [esp+0x2c],0x5
0x08048486 <+57>: mov DWORD PTR [esp+0x10],0x0
0x0804848e <+65>: jmp 0x80484ad <main+96>
0x08048490 <+67>: mov eax,DWORD PTR [esp+0x10]
0x08048494 <+71>: mov eax,DWORD PTR [esp+eax*4+0x18]
0x08048498 <+75>: mov DWORD PTR [esp+0x4],eax
0x0804849c <+79>: mov DWORD PTR [esp],0x8048640 ;"%d\n"
0x080484a3 <+86>: call 0x8048310 <printf@plt>
0x080484a8 <+91>: add DWORD PTR [esp+0x10],0x1
0x080484ad <+96>: cmp DWORD PTR [esp+0x10],0x5
0x080484b2 <+101>: jle 0x8048490 <main+67>
0x080484b4 <+103>: mov DWORD PTR [esp],0xa
0x080484bb <+110>: call 0x8048340 <putchar@plt>
0x080484c0 <+115>: mov DWORD PTR [esp+0x10],0x1
0x080484c8 <+123>: jmp 0x8048565 <main+280>
0x080484cd <+128>: mov DWORD PTR [esp+0x14],0x0
0x080484d5 <+136>: jmp 0x804854d <main+256>
0x080484d7 <+138>: mov eax,DWORD PTR [esp+0x14]
0x080484db <+142>: mov edx,DWORD PTR [esp+eax*4+0x18]
0x080484df <+146>: mov eax,DWORD PTR [esp+0x14]
0x080484e3 <+150>: add eax,0x1
0x080484e6 <+153>: mov eax,DWORD PTR [esp+eax*4+0x18]
0x080484ea <+157>: cmp edx,eax
0x080484ec <+159>: jle 0x8048548 <main+251>
0x080484ee <+161>: mov eax,DWORD PTR [esp+0x14]
0x080484f2 <+165>: mov edx,DWORD PTR [esp+eax*4+0x18]
0x080484f6 <+169>: mov eax,DWORD PTR [esp+0x14]
0x080484fa <+173>: add eax,0x1
0x080484fd <+176>: mov eax,DWORD PTR [esp+eax*4+0x18]
0x08048501 <+180>: xor edx,eax
0x08048503 <+182>: mov eax,DWORD PTR [esp+0x14]
0x08048507 <+186>: mov DWORD PTR [esp+eax*4+0x18],edx
0x0804850b <+190>: mov eax,DWORD PTR [esp+0x14]
0x0804850f <+194>: lea edx,[eax+0x1]
0x08048512 <+197>: mov eax,DWORD PTR [esp+0x14]
---Type <return> to continue, or q <return> to quit---
0x08048516 <+201>: add eax,0x1
0x08048519 <+204>: mov ecx,DWORD PTR [esp+eax*4+0x18]
0x0804851d <+208>: mov eax,DWORD PTR [esp+0x14]
0x08048521 <+212>: mov eax,DWORD PTR [esp+eax*4+0x18]
0x08048525 <+216>: xor eax,ecx
0x08048527 <+218>: mov DWORD PTR [esp+edx*4+0x18],eax
0x0804852b <+222>: mov eax,DWORD PTR [esp+0x14]
0x0804852f <+226>: mov edx,DWORD PTR [esp+eax*4+0x18]
0x08048533 <+230>: mov eax,DWORD PTR [esp+0x14]
0x08048537 <+234>: add eax,0x1
0x0804853a <+237>: mov eax,DWORD PTR [esp+eax*4+0x18]
0x0804853e <+241>: xor edx,eax
0x08048540 <+243>: mov eax,DWORD PTR [esp+0x14]
0x08048544 <+247>: mov DWORD PTR [esp+eax*4+0x18],edx
0x08048548 <+251>: add DWORD PTR [esp+0x14],0x1
0x0804854d <+256>: mov eax,0x6
0x08048552 <+261>: sub eax,DWORD PTR [esp+0x10]
0x08048556 <+265>: cmp eax,DWORD PTR [esp+0x14]
0x0804855a <+269>: jg 0x80484d7 <main+138>
0x08048560 <+275>: add DWORD PTR [esp+0x10],0x1
0x08048565 <+280>: cmp DWORD PTR [esp+0x10],0x5
0x0804856a <+285>: jle 0x80484cd <main+128>
0x08048570 <+291>: mov DWORD PTR [esp+0x10],0x0
0x08048578 <+299>: jmp 0x8048597 <main+330>
0x0804857a <+301>: mov eax,DWORD PTR [esp+0x10]
0x0804857e <+305>: mov eax,DWORD PTR [esp+eax*4+0x18]
0x08048582 <+309>: mov DWORD PTR [esp+0x4],eax
0x08048586 <+313>: mov DWORD PTR [esp],0x8048640 ;"%d\n"
0x0804858d <+320>: call 0x8048310 <printf@plt>
0x08048592 <+325>: add DWORD PTR [esp+0x10],0x1
0x08048597 <+330>: cmp DWORD PTR [esp+0x10],0x5
0x0804859c <+335>: jle 0x804857a <main+301>
0x0804859e <+337>: mov eax,0x0
0x080485a3 <+342>: leave
0x080485a4 <+343>: ret
#include <stdio.h>
int main(int argc,char *argv[])
{
int v[6] = {3,4,2,1,7,5};
int i=0;
int j=0;
while(i<=5)
{
printf("%d ",v[i]);
i++;
}
putchar(10);
i = 1;
while(i<=5)
{
j=0;
while(6-i>j)
{
// main+138 start
if(v[j] <= v[j+1])
{
v[j] = v[j]^v[j+1];
v[j+1] = v[j]^v[j+1];
v[j] = v[j]^v[j+1];
}
j++;
}
i++;
}
i = 0;
while(i<=5)
{
printf("%d ",v[i]);
i++;
}
return 0;
}