---------------------------- main.c ------------------------------------ /* main.c the main program for this example */ /* The next line is a 'macro' that tells the compiler to find the specification of the printf command in a file called stdio.h, the 'header' file for the 'standard input/output' (stdio) package. */ #include /* The next line says that we will use a function called mult2_number that takes two floating point inputs and produces a floating point result. */ float mult2(float num, float t); int main() { /* Allocate space for variables and initialize some of them. */ float number = 50; float number3; float t = 10; if (number > 0 && number < 100) { number3 = mult2(number, t); }else{ number3 = mult2(number+1,t); } /* printf behaves like Matlab's fprintf, except that it uses double quotes in place of single, and it requires a '\n' whenever a new line is desired. Another difference from Matlab: commands can be broken between two lines without using "..." */ printf("%f (possibly incremented) squared times %f is %f. \n", number,t,number3); return 0; } --------------------- main.s, produced by gcc main.c -S -------------- .file "main.c" .section .rodata .align 4 .LC5: .string "%f (possibly incremented) squared times %f is %f. \n" .align 4 .LC3: .long 1120403456 .text .globl main .type main, @function main: leal 4(%esp), %ecx andl $-16, %esp pushl -4(%ecx) pushl %ebp movl %esp, %ebp pushl %ecx subl $52, %esp movl $0x42480000, %eax movl %eax, -16(%ebp) movl $0x41200000, %eax movl %eax, -8(%ebp) flds -16(%ebp) fldz fxch %st(1) fucompp fnstsw %ax sahf seta %al xorl $1, %eax testb %al, %al jne .L2 flds -16(%ebp) flds .LC3 fucompp fnstsw %ax testb $69, %ah sete %al xorl $1, %eax testb %al, %al jne .L2 movl -8(%ebp), %eax movl %eax, 4(%esp) movl -16(%ebp), %eax movl %eax, (%esp) call mult2 fstps -12(%ebp) jmp .L5 .L2: flds -16(%ebp) fld1 faddp %st, %st(1) movl -8(%ebp), %eax movl %eax, 4(%esp) fstps (%esp) call mult2 fstps -12(%ebp) .L5: flds -12(%ebp) flds -8(%ebp) flds -16(%ebp) fxch %st(2) fstpl 20(%esp) fstpl 12(%esp) fstpl 4(%esp) movl $.LC5, (%esp) call printf movl $0, %eax addl $52, %esp popl %ecx popl %ebp leal -4(%ecx), %esp ret .size main, .-main .ident "GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-51)" .section .note.GNU-stack,"",@progbits