View Single Post
Old Feb 24th, 2005, 9:50 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
        .file   "test.c"
        .section        .rodata
.LC0:
        .string "%d\n"
        .text
.globl main
        .type   main, @function
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
        movl    $3, 4(%esp)
        movl    $5, (%esp)
        call    binomial
        movl    %eax, 4(%esp)
        movl    $.LC0, (%esp)
        call    printf
        movl    $0, %eax
        leave
        ret
        .size   main, .-main
.globl factorial
        .type   factorial, @function
factorial:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $12, %esp
        cmpl    $1, 8(%ebp)
        jg      .L3
        movl    $1, -12(%ebp)
        jmp     .L2
.L3:
        movl    $1, -4(%ebp)
        movl    $2, -8(%ebp)
.L4:
        movl    -8(%ebp), %eax
        cmpl    8(%ebp), %eax
        jle     .L7
        jmp     .L5
.L7:
        movl    -4(%ebp), %eax
        imull   -8(%ebp), %eax
        movl    %eax, -4(%ebp)
        leal    -8(%ebp), %eax
        incl    (%eax)
        jmp     .L4
.L5:
        movl    -4(%ebp), %eax
        movl    %eax, -12(%ebp)
.L2:
        movl    -12(%ebp), %eax
        leave
        ret
        .size   factorial, .-factorial
.globl binomial
        .type   binomial, @function
binomial:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %esi
        pushl   %ebx
        subl    $16, %esp
        cmpl    $0, 8(%ebp)
        jle     .L10
        cmpl    $0, 12(%ebp)
        jns     .L10
        movl    8(%ebp), %eax
        cmpl    12(%ebp), %eax
        jle     .L10
        jmp     .L9
.L10:
        movl    $1, -12(%ebp)
        jmp     .L8
.L9:
        movl    8(%ebp), %eax
        movl    %eax, (%esp)
        call    factorial
        movl    %eax, %ebx
        movl    12(%ebp), %eax
        movl    %eax, (%esp)
        call    factorial
        movl    %eax, %esi
        movl    12(%ebp), %edx
        movl    8(%ebp), %eax
        subl    %edx, %eax
        movl    %eax, (%esp)
        call    factorial
        imull   %esi, %eax
        movl    %eax, -16(%ebp)
        movl    %ebx, %eax
        cltd
        idivl   -16(%ebp)
        movl    %eax, -16(%ebp)
        movl    -16(%ebp), %eax
        movl    %eax, -12(%ebp)
.L8:
        movl    -12(%ebp), %eax
        addl    $16, %esp
        popl    %ebx
        popl    %esi
        popl    %ebp
        ret
        .size   binomial, .-binomial
        .section        .note.GNU-stack,"",@progbits
        .ident  "GCC: (GNU) 3.3.5 (Debian 1:3.3.5-3)"
__________________

tempest is offline   Reply With Quote