#include <stdio.h>
int main()
{
int a = 100;
int b = 25;
if (a > b) {
printf ("The higher value is %d\n", a);
} else {
printf ("The higher value is %d\n", b);
}
return 0;
}
$ cat ifthen.s
.file "ifthen.c"
.section .rodata
.LC0:
.string "The higher value is %d\n"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
movl $100, 28(%esp)
movl $25, 24(%esp)
movl 28(%esp), %eax
cmpl 24(%esp), %eax
jle .L2
movl $.LC0, %eax
movl 28(%esp), %edx
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
jmp .L3
.L2:
movl $.LC0, %eax
movl 24(%esp), %edx
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
.L3:
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (Ubuntu 4.4.1-4ubuntu8) 4.4.1"
.section .note.GNU-stack,"",@progbits
#include <stdio.h>
int main()
{
int i;
int j;
for (i = 0; i < 1000; i++) {
j = i * 5;
printf ("The answer is %d\\n", j);
}
return (0);
}
.file "for.c"
.section .rodata
.LC0:
.string "The answer is %d\\n"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
movl $0, 28(%esp)
jmp .L2
.L3:
movl 28(%esp), %edx
movl %edx, %eax
sall $2, %eax
addl %edx, %eax
movl %eax, 24(%esp)
movl $.LC0, %eax
movl 24(%esp), %edx
movl %edx, 4(%esp)
movl %eax, (%esp)
call printf
addl $1, 28(%esp)
.L2:
cmpl $999, 28(%esp)
jle .L3
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (Ubuntu 4.4.1-4ubuntu8) 4.4.1"
.section .note.GNU-stack,"",@progbits
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |