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
subl $24, %esp-------
andl $-16, %esp-------为什么要这样减24在加负16呢,这是干什么?
movl $0, %eax
subl %eax, %esp-----为什么给eax赋0,再和esp减,这是在做什么?为什么,不直接减?
movl $100, -4(%ebp)
movl $25, -8(%ebp)-------为什么要一会用ebp一会用esp呢用esp是不那个数往高地址方向存还是往低地址方向存呢?
movl -4(%ebp), %eax
cmpl -8(%ebp), %eax
jle .L2
movl -4(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC0, (%esp)
call printf
jmp .L3
.L2:
movl -8(%ebp), %eax
movl %eax, 4(%esp)
movl $.LC0, (%esp)
call printf
.L3:
movl $0, (%esp)
call exit
以上是按照professional assembly language 书上
#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);