#include
void printing_function(int i)
{
printf("f(%d)\n", i);
}
int main()
{
int i;
for (i = 2; i < 10; i++)
printing_function(i);
return 0;
}
#if 0
x86有一条专门的LOOP。检测ECX的值是否是0。不是0则将其递减,并将操作权交给操作符所指定的标签处(即跳转)。
#endif
#if 0
/*
* intel
*/
0000000000001149 :
1149: f3 0f 1e fa endbr64
114d: 55 push %rbp
114e: 48 89 e5 mov %rsp,%rbp
1151: 48 83 ec 10 sub $0x10,%rsp
1155: 89 7d fc mov %edi,-0x4(%rbp)
1158: 8b 45 fc mov -0x4(%rbp),%eax
115b: 89 c6 mov %eax,%esi
115d: 48 8d 3d a0 0e 00 00 lea 0xea0(%rip),%rdi # 2004 <_IO_stdin_used+0x4>
1164: b8 00 00 00 00 mov $0x0,%eax
1169: e8 e2 fe ff ff callq 1050
116e: 90 nop
116f: c9 leaveq
1170: c3 retq
0000000000001171 :
1171: f3 0f 1e fa endbr64
1175: 55 push %rbp
1176: 48 89 e5 mov %rsp,%rbp
1179: 48 83 ec 10 sub $0x10,%rsp
117d: c7 45 fc 02 00 00 00 movl $0x2,-0x4(%rbp)
1184: eb 0e jmp 1194
1186: 8b 45 fc mov -0x4(%rbp),%eax
1189: 89 c7 mov %eax,%edi
118b: e8 b9 ff ff ff callq 1149
1190: 83 45 fc 01 addl $0x1,-0x4(%rbp)
1194: 83 7d fc 09 cmpl $0x9,-0x4(%rbp)
1198: 7e ec jle 1186
119a: b8 00 00 00 00 mov $0x0,%eax
119f: c9 leaveq
11a0: c3 retq
11a1: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
11a8: 00 00 00
11ab: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
/*
* arm
*/
000000000040055c :
40055c: a9be7bfd stp x29, x30, [sp, #-32]!
400560: 910003fd mov x29, sp
400564: b9001fa0 str w0, [x29, #28]
400568: 90000000 adrp x0, 400000 <_init-0x3e8>
40056c: 9119e000 add x0, x0, #0x678
400570: b9401fa1 ldr w1, [x29, #28]
400574: 97ffffb7 bl 400450
400578: d503201f nop
40057c: a8c27bfd ldp x29, x30, [sp], #32
400580: d65f03c0 ret
0000000000400584 :
400584: a9be7bfd stp x29, x30, [sp, #-32]!
400588: 910003fd mov x29, sp
40058c: 52800040 mov w0, #0x2 // #2
400590: b9001fa0 str w0, [x29, #28]
400594: 14000006 b 4005ac
400598: b9401fa0 ldr w0, [x29, #28]
40059c: 97fffff0 bl 40055c
4005a0: b9401fa0 ldr w0, [x29, #28]
4005a4: 11000400 add w0, w0, #0x1
4005a8: b9001fa0 str w0, [x29, #28]
4005ac: b9401fa0 ldr w0, [x29, #28]
4005b0: 7100241f cmp w0, #0x9
4005b4: 54ffff2d b.le 400598
4005b8: 52800000 mov w0, #0x0 // #0
4005bc: a8c27bfd ldp x29, x30, [sp], #32
4005c0: d65f03c0 ret
4005c4: 00000000 .inst 0x00000000 ; undefined
#endif