汇编指令学习

发布时间:2023年12月17日

1 过程调用分析

08049172 <f>:
 8049172:       55                      push   %ebp
 8049173:       89 e5                   mov    %esp,%ebp
 8049175:       53                      push   %ebx
 8049176:       83 ec 04                sub    $0x4,%esp
 8049179:       83 7d 08 00             cmpl   $0x0,0x8(%ebp)
 804917d:       75 07                   jne    8049186 <f+0x14>
 804917f:       b8 01 00 00 00          mov    $0x1,%eax
 8049184:       eb 35                   jmp    80491bb <f+0x49>
 8049186:       83 7d 08 01             cmpl   $0x1,0x8(%ebp)
 804918a:       75 07                   jne    8049193 <f+0x21>
 804918c:       b8 02 00 00 00          mov    $0x2,%eax
 8049191:       eb 28                   jmp    80491bb <f+0x49>
 8049193:       8b 45 08                mov    0x8(%ebp),%eax
 8049196:       83 e8 01                sub    $0x1,%eax
 8049199:       83 ec 0c                sub    $0xc,%esp
 804919c:       50                      push   %eax
 804919d:       e8 d0 ff ff ff          call   8049172 <f>
 80491a2:       83 c4 10                add    $0x10,%esp
 80491a5:       89 c3                   mov    %eax,%ebx
 80491a7:       8b 45 08                mov    0x8(%ebp),%eax
 80491aa:       83 e8 02                sub    $0x2,%eax
 80491ad:       83 ec 0c                sub    $0xc,%esp
 80491b0:       50                      push   %eax
 80491b1:       e8 bc ff ff ff          call   8049172 <f>
 80491b6:       83 c4 10                add    $0x10,%esp
 80491b9:       01 d8                   add    %ebx,%eax
 80491bb:       8b 5d fc                mov    -0x4(%ebp),%ebx
 80491be:       c9                      leave
 80491bf:       c3                      ret

? ? ? ? 详解 :只分析过程调用部分

  1. 8049179: 83 7d 08 00? ?cmpl $0x0,0x8(%ebp) //比较立即数和0x8(%ebp)地址
  2. 804917d: 75 07? ? ? ?jne 8049186 <f+0x14> //上一条指令结果不为0就跳转
  3. 804917f: b8 01 00 00 00?mov $0x1,%eax
  4. 8049184: eb 35? ? ? ? jmp 80491bb <f+0x49>
  5. 8049186: 83 7d 08 01? ? cmpl $0x1,0x8(%ebp) //比较1跟0x8(%ebp)地址大小
  6. 804918a: 75 07? ? ? ? jne 8049193 <f+0x21>//
  7. 804918c: b8 02 00 00 00 mov $0x2,%eax
  8. 8049191: eb 28 ? ? ? jmp 80491bb <f+0x49>
  9. 8049193: 8b 45 08? ? ?mov 0x8(%ebp),%eax
  10. 8049196: 83 e8 01? ? ?sub $0x1,%eax //eax的值减去1
  11. 8049199: 83 ec 0c? ? ?sub $0xc,%esp?//栈esp指针减去12
  12. 804919c: 50? ? ? ? ? push %eax?//把eax压住栈中
  13. 804919d: e8 d0 ff ff ff call 8049172 <f>?//调用f
  14. 80491a2: 83 c4 10? ? ?add $0x10,%esp?//esp增加16个字节
  15. 80491a5: 89 c3? ? ? ?mov %eax,%ebx?//把eax寄存去值传送到ebx
  16. 80491a7: 8b 45 08? ? ?mov 0x8(%ebp),%eax
  17. 80491aa: 83 e8 02? ? ?sub $0x2,%eax
  18. 80491ad: 83 ec 0c? ? ? sub $0xc,%esp
  19. 80491b0: 50? ? ? ? ? push %eax
  20. 80491b1: e8 bc ff ff ff call 8049172 <f>
  21. 80491b6: 83 c4 10 ? ? add $0x10,%esp
  22. 80491b9: 01 d8? ? ? ?add %ebx,%eax?//把ebx+eax的值传给eax
  23. 80491bb: 8b 5dfc? ? ? mov -0x4(%ebp),%ebx
  24. 80491be: c9 leave
  25. 80491bf: c3 ret

C语言代码?

int f(int n)
{
    //**********Begin**********
    if (n == 0)
        return 1;
    else if (n == 1)
        return 2;
    else
        return f(n-1) + f(n-2);
    //**********End**********
}

2 数组访问与指针操作分析

? ? ? ? 2.1?数组访问分析

08049172 <main>:
 8049172:       8d 4c 24 04             lea    0x4(%esp),%ecx
 8049176:       83 e4 f0                and    $0xfffffff0,%esp
 8049179:       ff 71 fc                pushl  -0x4(%ecx)
 804917c:       55                      push   %ebp
 804917d:       89 e5                   mov    %esp,%ebp
 804917f:       51                      push   %ecx
 8049180:       83 ec 14                sub    $0x14,%esp
 8049183:       c7 45 f0 00 00 00 00    movl   $0x0,-0x10(%ebp)
 804918a:       83 ec 04                sub    $0x4,%esp
 804918d:       8d 45 e8                lea    -0x18(%ebp),%eax
 8049190:       50                      push   %eax
 8049191:       8d 45 ec                lea    -0x14(%ebp),%eax
 8049194:       50                      push   %eax
 8049195:       68 08 a0 04 08          push   $0x804a008
 804919a:       e8 b1 fe ff ff          call   8049050 <__isoc99_scanf@plt>
 804919f:       83 c4 10                add    $0x10,%esp
 80491a2:       8b 45 ec                mov    -0x14(%ebp),%eax
 80491a5:       89 45 f4                mov    %eax,-0xc(%ebp)
 80491a8:       eb 11                   jmp    80491bb <main+0x49>
 80491aa:       8b 45 f4                mov    -0xc(%ebp),%eax
 80491ad:       8b 04 85 40 c0 04 08    mov    0x804c040(,%eax,4),%eax
 80491b4:       01 45 f0                add    %eax,-0x10(%ebp)
 80491b7:       83 45 f4 01             addl   $0x1,-0xc(%ebp)
 80491bb:       8b 45 e8                mov    -0x18(%ebp),%eax
 80491be:       39 45 f4                cmp    %eax,-0xc(%ebp)
 80491c1:       7c e7                   jl     80491aa <main+0x38>
 80491c3:       83 ec 08                sub    $0x8,%esp
 80491c6:       ff 75 f0                pushl  -0x10(%ebp)
 80491c9:       68 0d a0 04 08          push   $0x804a00d
 80491ce:       e8 5d fe ff ff          call   8049030 <printf@plt>
 80491d3:       83 c4 10                add    $0x10,%esp
 80491d6:       b8 00 00 00 00          mov    $0x0,%eax
 80491db:       8b 4d fc                mov    -0x4(%ebp),%ecx
 80491de:       c9                      leave
 80491df:       8d 61 fc                lea    -0x4(%ecx),%esp
 80491e2:       c3                      ret

? ? ? ? 详解 :只分析数组部分

  1. 80491a2: 8b 45 ec? ?mov -0x14(%ebp),%eax //n的值进行传递
  2. 80491a5: 89 45 f4? ?mov %eax,-0xc(%ebp)?//n的值进行传递
  3. 80491a8: eb 11? ? ?jmp 80491bb <main+0x49> //无条件跳转
  4. 80491aa: 8b 45 f4? ?mov -0xc(%ebp),%eax
  5. 80491ad: 8b 04 85 40 c0 04 08 mov 0x804c040(,%eax,4),%eax //数组读取方式
  6. 80491b4: 01 45 f0? ?add %eax,-0x10(%ebp) //sum+a[n]传给sum
  7. 80491b7: 83 45 f4 01 addl $0x1,-0xc(%ebp)//n++
  8. 80491bb: 8b 45 e8? ?mov -0x18(%ebp),%eax?// m的值传递
  9. 80491be: 39 45 f4 ? cmp %eax,-0xc(%ebp)?//比较m和n
  10. 80491c1: 7c e7? ? ?jl 80491aa <main+0x38> //小于跳转
  11. 80491c3: 83 ec 08? ?sub $0x8,%esp
  12. 80491c6: ff 75 f0? ?pushl -0x10(%ebp)
  13. 80491c9: 68 0d a0 04 08 push $0x804a00d
  14. 80491ce: e8 5d fe ff ff call 8049030 <printf@plt>
  15. 80491d3: 83 c4 10? ?add $0x10,%esp
  16. 80491d6: b8 00 00 00 00 mov $0x0,%eax
  17. 80491db: 8b 4d fc? ?mov -0x4(%ebp),%ecx
  18. 80491de: c9 leave
  19. 80491df: 8d 61 fc lea -0x4(%ecx),%esp
  20. 80491e2: c3 ret

?C语言代码?

 #include <stdio.h>

int a[10] = {0,1,2,3,4,5,6,7,8,9};
int main()
{
	int m, n, i, sum = 0;
	scanf("%d%d", &m, &n);
    printf("评测结果:成功\n评测脚本:C\n返回结果:");//此行不在汇编代码中
    //**********Begin********
    for(i=m;i<n;i++)
    sum+=a[i];

    //**********End**********
	printf("%d", sum);
    return 0;
}

? ? ? ? 2.2?指针操作分析

?

08049162 <main>:
 8049162:       8d 4c 24 04             lea    0x4(%esp),%ecx
 8049166:       83 e4 f0                and    $0xfffffff0,%esp
 8049169:       ff 71 fc                pushl  -0x4(%ecx)
 804916c:       55                      push   %ebp
 804916d:       89 e5                   mov    %esp,%ebp
 804916f:       51                      push   %ecx
 8049170:       83 ec 14                sub    $0x14,%esp
 8049173:       c7 45 eb 61 62 63 64    movl   $0x64636261,-0x15(%ebp)
 804917a:       c7 45 ef 65 66 67 00    movl   $0x676665,-0x11(%ebp)
 8049181:       c6 45 f3 00             movb   $0x0,-0xd(%ebp)
 8049185:       8d 45 eb                lea    -0x15(%ebp),%eax
 8049188:       89 45 f4                mov    %eax,-0xc(%ebp)
 804918b:       eb 1e                   jmp    80491ab <main+0x49>
 804918d:       8b 45 f4                mov    -0xc(%ebp),%eax
 8049190:       0f b6 00                movzbl (%eax),%eax
 8049193:       0f be c0                movsbl %al,%eax
 8049196:       83 ec 08                sub    $0x8,%esp
 8049199:       50                      push   %eax
 804919a:       68 08 a0 04 08          push   $0x804a008
 804919f:       e8 8c fe ff ff          call   8049030 <printf@plt>
 80491a4:       83 c4 10                add    $0x10,%esp
 80491a7:       83 45 f4 01             addl   $0x1,-0xc(%ebp)
 80491ab:       8b 45 f4                mov    -0xc(%ebp),%eax
 80491ae:       0f b6 00                movzbl (%eax),%eax
 80491b1:       84 c0                   test   %al,%al
 80491b3:       75 d8                   jne    804918d <main+0x2b>
 80491b5:       b8 00 00 00 00          mov    $0x0,%eax
 80491ba:       8b 4d fc                mov    -0x4(%ebp),%ecx
 80491bd:       c9                      leave
 80491be:       8d 61 fc                lea    -0x4(%ecx),%esp
 80491c1:       c3                      ret

?? ? ? ? 详解 :只分析指针部分

  1. 8049173: c7 45 eb 61 62 63 64 movl $0x64636261,-0x15(%ebp) //传送值
  2. 804917a: c7 45 ef 65 66 67 00 movl $0x676665,-0x11(%ebp)
  3. 8049181: c6 45 f3 00? ? ? ?movb $0x0,-0xd(%ebp)
  4. 8049185: 8d 45 eb? ? ? ? ?lea -0x15(%ebp),%eax //取-0x15(%ebp)的地址传
  5. 8049188: 89 45 f4? ? ? ? ?mov %eax,-0xc(%ebp)
  6. 804918b: eb 1e ? ?? ?? ?jmp 80491ab <main+0x49> // 无条件跳转
  7. 804918d: 8b 45 f4? ? ? ? ?mov -0xc(%ebp),%eax
  8. 8049190: 0f b6 00 ? ?? ?? movzbl (%eax),%eax
  9. 8049193: 0f be c0 ? ?? ?? movsbl %al,%eax
  10. 8049196: 83 ec 08 ? ?? ?? sub $0x8,%esp
  11. 8049199: 50 ? ?? ?? ?? ?push %eax
  12. 804919a: 68 08 a0 04 08? ? ?push $0x804a008
  13. 804919f: e8 8c fe ff ff call 8049030 <printf@plt>
  14. 80491a4: 83 c4 10 ? ?? ?? add $0x10,%esp
  15. 80491a7: 83 45 f4 01 ? ?? ?addl $0x1,-0xc(%ebp) //p++
  16. 80491ab: 8b 45 f4 ? ?? ?? mov -0xc(%ebp),%eax //p的地址传递
  17. 80491ae: 0f b6 00 ? ?? ?? movzbl (%eax),%eax?//p的地址传递
  18. 80491b1: 84 c0 ? ?? ?? ?test %al,%al //while判断语句
  19. 80491b3: 75 d8 ? ?? ?? ?jne 804918d <main+0x2b> //结果不相等.就跳转
  20. 80491b5: b8 00 00 00 00? ? ?mov $0x0,%eax
  21. 80491ba: 8b 4d fc mov -0x4(%ebp),%ecx
  22. 80491bd: c9 leave
  23. 80491be: 8d 61 fc lea -0x4(%ecx),%esp
  24. 80491c1: c3 ret

??C语言代码?

#include <stdio.h>
int main()
{
	char a[] = "abcdefg\0";
	char *p = a;
	printf("评测结果:成功\n评测脚本:C\n返回结果:");//此行不在汇编代码中
    //**********Begin**********
    while (*p != '\0') {
        printf("%c\n", *p);
        p++;
    }
    //**********End**********
    return 0;
}

3 结构/链表的访问分析

? ? ? ? 3.1?结构体的访问分析?

08049162 <main>:
 8049162:       8d 4c 24 04             lea    0x4(%esp),%ecx
 8049166:       83 e4 f0                and    $0xfffffff0,%esp
 8049169:       ff 71 fc                pushl  -0x4(%ecx)
 804916c:       55                      push   %ebp
 804916d:       89 e5                   mov    %esp,%ebp
 804916f:       51                      push   %ecx
 8049170:       83 ec 04                sub    $0x4,%esp
 8049173:       a1 d8 c0 04 08          mov    0x804c0d8,%eax
 8049178:       50                      push   %eax
 8049179:       68 72 c0 04 08          push   $0x804c072
 804917e:       68 40 c0 04 08          push   $0x804c040
 8049183:       68 08 a0 04 08          push   $0x804a008
 8049188:       e8 a3 fe ff ff          call   8049030 <printf@plt>
 804918d:       83 c4 10                add    $0x10,%esp
 8049190:       b8 00 00 00 00          mov    $0x0,%eax
 8049195:       8b 4d fc                mov    -0x4(%ebp),%ecx
 8049198:       c9                      leave
 8049199:       8d 61 fc                lea    -0x4(%ecx),%esp
 804919c:       c3                      ret

?? ? ? ? 详解 :只分析结构体部分?

  1. 08049162 <main>:
  2. 8049162: 8d 4c 24 04? ?lea 0x4(%esp),%ecx
  3. 8049166: 83 e4 f0? ? ?and $0xfffffff0,%esp
  4. 8049169: ff 71 fc? ? ?pushl -0x4(%ecx)
  5. 804916c: 55? ? ? ? ?push %ebp
  6. 804916d: 89 e5? ? ? ?mov %esp,%ebp
  7. 804916f: 51? ? ? ? ?push %ecx
  8. 8049170: 83 ec 04? ? ?sub $0x4,%esp
  9. 8049173: a1 d8 c0 04 08 mov 0x804c0d8,%eax
  10. 8049178: 50? ? ? ? ?push %eax
  11. 8049179: 68 72 c0 04 08 push $0x804c072 //压入栈
  12. 804917e: 68 40 c0 04 08 push $0x804c040?//压入栈
  13. 8049183: 68 08 a0 04 08 push $0x804a008?//压入栈
  14. 8049188: e8 a3 fe ff ff call 8049030 <printf@plt>
  15. 804918d: 83 c4 10? ? ?add $0x10,%esp
  16. 8049190: b8 00 00 00 00 mov $0x0,%eax
  17. 8049195: 8b 4d fc? ? ?mov -0x4(%ebp),%ecx
  18. 8049198: c9 leave
  19. 8049199: 8d 61 fc lea -0x4(%ecx),%esp
  20. 804919c: c3 ret

C语言代码??

#include <stdio.h>
struct Books {
	char  title[50];
	char  subject[100];
	int   id;
} book = {"math", "math", 123456};

int main()
{
	printf("评测结果:成功\n评测脚本:C\n返回结果:");//此代码不体现在汇编代码中
    //**********Begin********
    printf("title : %s\n", book.title);
    printf("科目: %s\n", book.subject);
    printf("id: %d\n", book.id);
	
    //**********End**********
    return 0;
}

? ? ? ? 3.2?链表的访问分析??

08049172 <main>:
 8049172:       8d 4c 24 04             lea    0x4(%esp),%ecx
 8049176:       83 e4 f0                and    $0xfffffff0,%esp
 8049179:       ff 71 fc                pushl  -0x4(%ecx)
 804917c:       55                      push   %ebp
 804917d:       89 e5                   mov    %esp,%ebp
 804917f:       51                      push   %ecx
 8049180:       83 ec 14                sub    $0x14,%esp
 8049183:       c7 45 ec 00 00 00 00    movl   $0x0,-0x14(%ebp)
 804918a:       83 ec 0c                sub    $0xc,%esp
 804918d:       6a 08                   push   $0x8
 804918f:       e8 ac fe ff ff          call   8049040 <malloc@plt>
 8049194:       83 c4 10                add    $0x10,%esp
 8049197:       89 45 f0                mov    %eax,-0x10(%ebp)
 804919a:       8b 45 f0                mov    -0x10(%ebp),%eax
 804919d:       c7 00 00 00 00 00       movl   $0x0,(%eax)
 80491a3:       8b 45 f0                mov    -0x10(%ebp),%eax
 80491a6:       c7 40 04 00 00 00 00    movl   $0x0,0x4(%eax)
 80491ad:       8b 45 f0                mov    -0x10(%ebp),%eax
 80491b0:       89 45 ec                mov    %eax,-0x14(%ebp)
 80491b3:       c7 45 f4 01 00 00 00    movl   $0x1,-0xc(%ebp)
 80491ba:       eb 53                   jmp    804920f <main+0x9d>
 80491bc:       83 ec 0c                sub    $0xc,%esp
 80491bf:       6a 08                   push   $0x8
 80491c1:       e8 7a fe ff ff          call   8049040 <malloc@plt>
 80491c6:       83 c4 10                add    $0x10,%esp
 80491c9:       89 45 e8                mov    %eax,-0x18(%ebp)
 80491cc:       8b 45 f4                mov    -0xc(%ebp),%eax
 80491cf:       0f af c0                imul   %eax,%eax
 80491d2:       89 c2                   mov    %eax,%edx
 80491d4:       8b 45 e8                mov    -0x18(%ebp),%eax
 80491d7:       89 10                   mov    %edx,(%eax)
 80491d9:       8b 45 e8                mov    -0x18(%ebp),%eax
 80491dc:       c7 40 04 00 00 00 00    movl   $0x0,0x4(%eax)
 80491e3:       8b 45 f0                mov    -0x10(%ebp),%eax
 80491e6:       8b 55 e8                mov    -0x18(%ebp),%edx
 80491e9:       89 50 04                mov    %edx,0x4(%eax)
 80491ec:       8b 45 f0                mov    -0x10(%ebp),%eax
 80491ef:       8b 40 04                mov    0x4(%eax),%eax
 80491f2:       89 45 f0                mov    %eax,-0x10(%ebp)
 80491f5:       8b 45 e8                mov    -0x18(%ebp),%eax
 80491f8:       8b 00                   mov    (%eax),%eax
 80491fa:       83 ec 08                sub    $0x8,%esp
 80491fd:       50                      push   %eax
 80491fe:       68 08 a0 04 08          push   $0x804a008
 8049203:       e8 28 fe ff ff          call   8049030 <printf@plt>
 8049208:       83 c4 10                add    $0x10,%esp
 804920b:       83 45 f4 01             addl   $0x1,-0xc(%ebp)
 804920f:       83 7d f4 04             cmpl   $0x4,-0xc(%ebp)
 8049213:       7e a7                   jle    80491bc <main+0x4a>
 8049215:       b8 00 00 00 00          mov    $0x0,%eax
 804921a:       8b 4d fc                mov    -0x4(%ebp),%ecx
 804921d:       c9                      leave
 804921e:       8d 61 fc                lea    -0x4(%ecx),%esp
 8049221:       c3                      ret

?

??? ? ? ? 详解 :只分析链表部分

  1. 8049183: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
  2. 804918a: 83 ec 0c? ? ?sub $0xc,%esp
  3. 804918d: 6a 08? ? ? ?push $0x8
  4. 804918f: e8 ac fe ff ff call 8049040 <malloc@plt>
  5. 8049194: 83 c4 10? ? ?add $0x10,%esp
  6. 8049197: 89 45 f0? ? ?mov %eax,-0x10(%ebp)
  7. 804919a: 8b 45 f0? ? ?mov -0x10(%ebp),%eax
  8. 804919d: c7 00 00 00 00 00 movl $0x0,(%eax)
  9. 80491a3: 8b 45 f0? ? ?mov -0x10(%ebp),%eax
  10. 80491a6: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
  11. 80491ad: 8b 45 f0? ? ?mov -0x10(%ebp),%eax
  12. 80491b0: 89 45 ec? ? ?mov %eax,-0x14(%ebp)
  13. 80491b3: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp) //i赋值1
  14. 80491ba: eb 53? ? ? ?jmp 804920f <main+0x9d>
  15. 80491bc: 83 ec 0c? ? ?sub $0xc,%esp
  16. 80491bf: 6a 08? ? ? ?push $0x8
  17. 80491c1: e8 7a fe ff ff call 8049040 <malloc@plt>
  18. 80491c6: 83 c4 10? ? ?add $0x10,%esp
  19. 80491c9: 89 45 e8? ? ?mov %eax,-0x18(%ebp)
  20. 80491cc: 8b 45 f4? ? ?mov -0xc(%ebp),%eax
  21. 80491cf: 0f af c0? ? ?imul %eax,%eax //i*i
  22. 80491d2: 89 c2? ? ? ?mov %eax,%edx
  23. 80491d4: 8b 45 e8? ? ?mov -0x18(%ebp),%eax
  24. 80491d7: 89 10? ? ? ?mov %edx,(%eax)
  25. 80491d9: 8b 45 e8? ? ?mov -0x18(%ebp),%eax
  26. 80491dc: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax)
  27. 80491e3: 8b 45 f0? ? ?mov -0x10(%ebp),%eax
  28. 80491e6: 8b 55 e8? ? ?mov -0x18(%ebp),%edx
  29. 80491e9: 89 50 04? ? ?mov %edx,0x4(%eax)
  30. 80491ec: 8b 45 f0? ? ?mov -0x10(%ebp),%eax
  31. 80491ef: 8b 40 04? ? ?mov 0x4(%eax),%eax
  32. 80491f2: 89 45 f0? ? ?mov %eax,-0x10(%ebp)
  33. 80491f5: 8b 45 e8? ? ?mov -0x18(%ebp),%eax
  34. 80491f8: 8b 00? ? ? ?mov (%eax),%eax
  35. 80491fa: 83 ec 08? ? ?sub $0x8,%esp
  36. 80491fd: 50? ? ? ? ?push %eax
  37. 80491fe: 68 08 a0 04 08 push $0x804a008
  38. 8049203: e8 28 fe ff ff call 8049030 <printf@plt>
  39. 8049208: 83 c4 10? ? ?add $0x10,%esp
  40. 804920b: 83 45 f4 01? ?addl $0x1,-0xc(%ebp)
  41. 804920f: 83 7d f4 04? ?cmpl $0x4,-0xc(%ebp) //比较4跟i的大小
  42. 8049213: 7e a7? ? ? ? jle 80491bc <main+0x4a> //
  43. 8049215: b8 00 00 00 00 mov $0x0,%eax
  44. 804921a: 8b 4d fc mov -0x4(%ebp),%ecx
  45. 804921d: c9 leave
  46. 804921e: 8d 61 fc lea -0x4(%ecx),%esp
  47. 8049221: c3 ret

C语言代码???

#include <stdio.h>
#include <stdlib.h>

typedef struct link {
	int  elem;
	struct link* next;
} Link;

int main()
{
    printf("评测结果:成功\n评测脚本:C\n返回结果:");//此代码不体现在汇编代码中
	int i;
	Link* p = NULL;
	Link* temp = (Link*) malloc(sizeof(Link));
	temp->elem = 0;
	temp->next = NULL;
    //**********Begin********
	p = temp;
    for (i = 1; i <= 4; i++) {
        Link* new_node = (Link*) malloc(sizeof(Link));
        new_node->elem = i*i;
        new_node->next = NULL;

        temp->next = new_node;
        temp = temp->next;
        printf("%d\n", new_node->elem);
    }
    //**********End**********
	return 0;
}

?

文章来源:https://blog.csdn.net/axxdxzz/article/details/135046252
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。