tAvoid saving precious data under stack pointer. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit bdc14ad47876a3bbdbb0df6101c36589855329f1
 (DIR) parent 39ce0d5862cd5fab8c93d60b195610b2ac77a094
 (HTM) Author: rsc <devnull@localhost>
       Date:   Wed, 22 Mar 2006 16:38:29 +0000
       
       Avoid saving precious data under stack pointer.
       
       Diffstat:
         M src/libmp/386/mpvecdigmulsub.s      |      43 +++++++++++++------------------
       
       1 file changed, 18 insertions(+), 25 deletions(-)
       ---
 (DIR) diff --git a/src/libmp/386/mpvecdigmulsub.s b/src/libmp/386/mpvecdigmulsub.s
       t@@ -23,32 +23,27 @@
         */
        .text
        
       -/* XXX: had to use "-4(%esp)" kludge to get around inability to
       - *      push/pop without first adjusting %esp.  This may not be
       - *      as fast as using push/pop (and accessing pushed element
       - *      with "(%esp)".)
       - */
       -
        .p2align 2,0x90
        .globl mpvecdigmulsub
                .type mpvecdigmulsub, @function
        mpvecdigmulsub:
                /* Prelude */
       -        pushl %ebp
       -        movl %ebx, -8(%esp)                /* save on stack */
       -        movl %esi, -12(%esp)
       -        movl %edi, -16(%esp)
       +        pushl %ebp                /* save on stack */
       +        pushl %ebx
       +        pushl %esi
       +        pushl %edi
        
       -        movl        8(%esp), %esi                /* b */
       -        movl        12(%esp), %ecx                /* n */
       -        movl        16(%esp), %ebx                /* m */
       -        movl        20(%esp), %edi                /* p */
       +        leal 20(%esp), %ebp                /* %ebp = FP for now */
       +        movl        0(%ebp), %esi                /* b */
       +        movl        4(%ebp), %ecx                /* n */
       +        movl        8(%ebp), %ebx                /* m */
       +        movl        12(%ebp), %edi                /* p */
                xorl        %ebp, %ebp
       -        movl        %ebp, -4(%esp)
       +        pushl %ebp
        _mulsubloop:
                movl        (%esi, %ebp, 4),%eax        /* lo = b[i] */
                mull        %ebx                        /* hi, lo = b[i] * m */
       -        addl        -4(%esp), %eax                /* lo += oldhi */
       +        addl        0(%esp), %eax                /* lo += oldhi */
                jae        _mulsubnocarry1
                incl        %edx                        /* hi += carry */
        _mulsubnocarry1:
       t@@ -56,23 +51,21 @@ _mulsubnocarry1:
                jae        _mulsubnocarry2
                incl        %edx                        /* hi += carry */
        _mulsubnocarry2:
       -        movl        %edx, -4(%esp)
       +        movl        %edx, 0(%esp)
                incl        %ebp
                loop        _mulsubloop
       -        movl        -4(%esp), %eax
       +        popl %eax
                subl        %eax, (%edi, %ebp, 4)
                jae        _mulsubnocarry3
                movl        $-1, %eax
                jmp done
       -
        _mulsubnocarry3:
                movl        $1, %eax
       -
        done:
                /* Postlude */
       -        movl -8(%esp), %ebx                /* restore from stack */
       -        movl -12(%esp), %esi
       -        movl -16(%esp), %edi
       -        movl %esp, %ebp
       -        leave
       +        popl %edi
       +        popl %esi
       +        popl %ebx
       +        popl %ebp
                ret
       +