Avoid saving precious data under stack pointer.

This commit is contained in:
rsc 2006-03-22 16:38:29 +00:00
parent 39ce0d5862
commit bdc14ad478

View file

@ -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:
@ -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