.file "p2.c" .text .globl maximum .type maximum,@function maximum: pushl %ebp movl %esp, %ebp movl 8(%ebp),%eax # eax is x movl 12(%ebp),%ecx # ecx is y cmpl %ecx,%eax # compute x-y, set CC jle .L2 # jump if x-y <= 0 movl %eax, %eax # return x jmp .L1 .L2: movl %ecx, %eax # return y .L1: leave ret .Lfe1: .size maximum,.Lfe1-maximum .section .rodata .align 32 .LC0: .string "The maximum of %d and %d is %d\n" .text .globl main .type main,@function main: pushl %ebp movl %esp, %ebp pushl %ebx movl $10, %ebx # x=10 movl $20, %ecx # y=20 pushl %ecx # push y pushl %ebx # push x call maximum pushl %eax # push return value pushl %ecx # push y pushl %ebx # push x pushl $.LC0 # push address of fmt string call printf movl $100, %ebx # x=100 movl $20, %ecx # y=20 pushl %ecx # push y pushl %ebx # push x call maximum pushl %eax # push return value pushl %ecx # push y pushl %ebx # push x pushl $.LC0 # push address of fmt string call printf movl $10, %ebx # x=10 movl $10, %ecx # y=10 pushl %ecx # push y pushl %ebx # push x call maximum pushl %eax # push return value pushl %ecx # push y pushl %ebx # push x pushl $.LC0 # push address of fmt string call printf movl $-10, %ebx # x=-10 movl $-20, %ecx # y=-20 pushl %ecx # push y pushl %ebx # push x call maximum pushl %eax # push return value pushl %ecx # push y pushl %ebx # push x pushl $.LC0 # push address of fmt string call printf pop %ebx # restore ebx leave ret