1
# Copyright (C) 2000 MySQL AB
2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License as published by
4
# the Free Software Foundation; version 2 of the License.
6
# This program is distributed in the hope that it will be useful,
7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
# GNU General Public License for more details.
11
# You should have received a copy of the GNU General Public License
12
# along with this program; if not, write to the Free Software
13
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Optimized int64_t2str function for Intel 80x86 (gcc/gas syntax)
16
# Some set sequences are optimized for pentuimpro II
18
.file "longlong2str-x86.s"
24
.globl int64_t2str_with_dig_vector
25
.type int64_t2str_with_dig_vector,@function
27
int64_t2str_with_dig_vector:
28
subl $80,%esp # Temporary buffer for up to 64 radix-2 digits
33
movl 100(%esp),%esi # esi = Lower part of val
34
movl 112(%esp),%ebx # ebx = Radix
35
movl 104(%esp),%ebp # ebp = Higher part of val
36
movl 108(%esp),%edi # edi = dst
39
jge .L144 # Radix was positive
40
negl %ebx # Change radix to positive
41
testl %ebp,%ebp # Test if given value is negative
43
movb $45,(%edi) # Add sign
44
incl %edi # Change sign of val
49
.L144: # Test that radix is between 2 and 36
51
addl $-2,%eax # Test that radix is between 2 and 36
53
ja .Lerror # Radix was not in range
55
leal 92(%esp),%ecx # End of buffer
56
movl %edi, 108(%esp) # Store possible modified dest
57
movl 116(%esp), %edi # dig_vec_upper
58
testl %ebp,%ebp # Test if value > 0xFFFFFFFF
60
cmpl %ebx, %esi # Test if <= radix, for easy loop
61
movl %esi, %eax # Value in eax (for Llow)
64
# Value is one digit (negative or positive)
66
movl 108(%esp),%edi # get dst
68
incl %edi # End null here
72
# Value in ebp:esi. div the high part by the radix,
73
# then div remainder + low part by the radix.
74
movl %ebp,%eax # edx=0,eax=high(from ebp)
78
movl %eax,%ebp # edx=result of last, eax=low(from esi)
81
movl %eax,%esi # ebp:esi = quotient
82
movb (%edx,%edi),%dl # Store result number in temporary buffer
84
movb %dl,(%ecx) # store value in buff
85
ja .Llongdiv # (Higher part of val still > 0)
88
.Llow: # Do rest with integer precision
89
# Value in 0:eax. div 0 + low part by the radix.
93
movb (%edx,%edi),%dl # bh is always zero as ebx=radix < 36
99
movl 108(%esp),%edi # get dst
102
leal 92(%esp),%esi # End of buffer
103
.Lmov: # mov temporary buffer to result (%ecx -> %edi)
112
movl %edi,%eax # Pointer to end null
113
movb $0,(%edi) # Store the end null
124
xorl %eax,%eax # Wrong radix
128
.size int64_t2str_with_dig_vector,.Lfe3-int64_t2str_with_dig_vector
131
# This is almost equal to the above, except that we can do the final
132
# loop much more efficient
137
.globl longlong10_to_str
138
.type longlong10_to_str,@function
145
movl 100(%esp),%esi # Lower part of val
146
movl 104(%esp),%ebp # Higher part of val
147
movl 108(%esp),%edi # get dst
148
movl 112(%esp),%ebx # Radix (10 or -10)
150
jge .L10_10 # Positive radix
152
negl %ebx # Change radix to positive (= 10)
154
testl %ebp,%ebp # Test if negative value
156
movb $45,(%edi) # Add sign
158
negl %esi # Change sign of val (ebp:esi)
163
leal 92(%esp),%ecx # End of buffer
164
testl %ebp,%ebp # Test if value > 0xFFFFFFFF
166
cmpl $10, %esi # Test if <= radix, for easy loop
167
movl %esi, %ebx # Value in eax (for L10_low)
170
# Value is one digit (negative or positive)
178
# val is stored in in ebp:esi
179
movl %ebp,%eax # High part of value
181
divl %ebx # Divide by 10
184
divl %ebx # Divide by 10
186
movl %eax,%esi # quotent in ebp:esi
187
addl $48,%edx # Convert to ascii
188
movb %dl,(%ecx) # store value in buff
193
movl %esi,%ebx # Move val to %ebx
196
# The following code uses some tricks to change division by 10 to
197
# multiplication and shifts
198
movl $0xcccccccd,%esi
200
.L10_40: # Divide %ebx with 10
205
leal (%edx,%edx,4),%eax
207
subb %al,%bl # %bl now contains val % 10
213
jmp .Lcopy_end # Shared end with int64_t2str
216
.size int64_t10_to_str,.L10end-int64_t10_to_str