# # File: if1_mod.s # Author: William T Krieger, Oct 2003 # # My modification of the if1 test case demonstrating a simple if stmt. .text FMT0: .ascii "Enter a number: \0" FMT1: .ascii "%d\0" FMT2: .ascii "Yes, x is 7!\12\0" .align 4 # # Function: _main() # void _main() # Demonstrates a simple if stmt. .globl _main _main: pushl %ebp # enter _main() movl %esp,%ebp subl $4,%esp # adjust stack for local vars: x = -4(%ebp) pushl $FMT0 # call printf( fmt0) call _printf addl $4,%esp leal -4(%ebp),%eax # call scanf( fmt1, &x) pushl %eax pushl $FMT1 call _scanf addl $8,%esp cmpl $7,-4(%ebp) # compare: x == 7? jne ELSE1 # if NOT equal, jump to ELSE1 pushl $FMT2 # call printf( fmt2) call _printf addl $4,%esp ELSE1: movl %ebp, %esp # exit _main() pop %ebp ret