# # File: if2_mod.s # Author: William T Krieger, Oct 2003 # # My modification of the if2 test case demonstrating a simple # if-else stmt. .text FMT0: .ascii "Enter 2 numbers: \0" FMT1: .ascii "%d%d\0" FMT2: .ascii "Yes, x equals y!\12\0" FMT3: .ascii "No, q does NOT equal y\12\0" .align 4 # # Function: _main() # void _main() # Demonstrates a simple if-else stmt. .globl _main _main: pushl %ebp # enter _main() movl %esp,%ebp addl $-8,%esp # adjust stack for 2 variables # x = -4(%ebp); y = -8(%ebp) pushl $FMT0 # call printf( fmt) call _printf addl $4,%esp leal -8(%ebp),%eax # call scanf( fmt, &x, &y) pushl %eax leal -4(%ebp),%eax pushl %eax pushl $FMT1 call _scanf addl $12,%esp # compare x, y movl -4(%ebp),%eax # eax = x cmpl -8(%ebp),%eax # compare( eax, y) jne ELSE1 # if NOT equal, jump to ELSE1 pushl $FMT2 # call printf( fmt2) call _printf addl $4,%esp jmp DONE ELSE1: pushl $FMT3 # call printf( fmt3) call _printf addl $4,%esp DONE: movl %ebp, %esp # exit _main() pop %ebp ret