1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
.text
.type atoll,@function
.global atoll
atoll:
movl 4(%esp),%ecx
push %edi
xorl %edi,%edi # sign = 0
decl %ecx
.Lspaces:
incl %ecx # while ( isspace(*p) ) p++;
movb (%ecx),%al
cmpb $' ',%al
je .Lspaces
subb $9,%al
cmpb $5,%al
jc .Lspaces # c = *p - 9;
cmpb $'+'-9,%al # if ( c == '+' - 9 ) p++;
je .Lpos
cmpb $'-'-9,%al # else if ( c == '-' - 9 ) sign = -sign, p++;
jne .Lnosign
decl %edi
.Lpos: incl %ecx
.Lnosign:
push %ebx
push %esi
push %ebp
movl $10,%ebp
xorl %esi,%esi # Hi(value) = 0;
xorl %eax,%eax # Lo(value) = 0;
.Lcont: movzbl (%ecx),%ebx # while ( (unsigned) (*p - '0') < 10 )
inc %ecx
subl $'0',%ebx
cmpl %ebp,%ebx
jnc .Lfini
imull %ebp,%esi # value *= 10,
mull %ebp
addl %edx,%esi
addl %ebx,%eax # value += (*p - '0');
adcl $0,%esi
jmp .Lcont
.Lfini: xchg %edx,%esi # return sign== 0 ? +value
xorl %edi,%eax # sign==-1 ? -value
xorl %edi,%edx
subl %edi,%eax
sbbl %edi,%edx
pop %ebp
pop %esi
pop %ebx
pop %edi
ret
.Lende:
.size atoll,.Lende-atoll
|