clarify the purpose of this project
[nyanglibc.git] / stdio-common / _itoa.s
blobc6d7ac7e7c35dc63286a58922bab363c367cc794
1 .text
2 .p2align 4,,15
3 .globl _itoa_word
4 .hidden _itoa_word
5 .type _itoa_word, @function
6 _itoa_word:
7 leaq _itoa_lower_digits(%rip), %r8
8 leaq _itoa_upper_digits(%rip), %rax
9 testl %ecx, %ecx
10 cmovne %rax, %r8
11 cmpl $10, %edx
12 je .L11
13 cmpl $16, %edx
14 je .L5
15 cmpl $8, %edx
16 movl %edx, %ecx
17 je .L6
18 .p2align 4,,10
19 .p2align 3
20 .L8:
21 movq %rdi, %rax
22 xorl %edx, %edx
23 subq $1, %rsi
24 divq %rcx
25 movq %rax, %rdi
26 movzbl (%r8,%rdx), %eax
27 testq %rdi, %rdi
28 movb %al, (%rsi)
29 jne .L8
30 .L1:
31 movq %rsi, %rax
32 ret
33 .p2align 4,,10
34 .p2align 3
35 .L5:
36 movq %rdi, %rax
37 shrq $4, %rdi
38 subq $1, %rsi
39 andl $15, %eax
40 testq %rdi, %rdi
41 movzbl (%r8,%rax), %eax
42 movb %al, (%rsi)
43 jne .L5
44 jmp .L1
45 .p2align 4,,10
46 .p2align 3
47 .L6:
48 movq %rdi, %rax
49 shrq $3, %rdi
50 subq $1, %rsi
51 andl $7, %eax
52 testq %rdi, %rdi
53 movzbl (%r8,%rax), %eax
54 movb %al, (%rsi)
55 jne .L6
56 jmp .L1
57 .p2align 4,,10
58 .p2align 3
59 .L11:
60 movabsq $-3689348814741910323, %rcx
61 .p2align 4,,10
62 .p2align 3
63 .L4:
64 movq %rdi, %rax
65 subq $1, %rsi
66 mulq %rcx
67 shrq $3, %rdx
68 leaq (%rdx,%rdx,4), %rax
69 addq %rax, %rax
70 subq %rax, %rdi
71 testq %rdx, %rdx
72 movzbl (%r8,%rdi), %eax
73 movq %rdx, %rdi
74 movb %al, (%rsi)
75 jne .L4
76 movq %rsi, %rax
77 ret
78 .size _itoa_word, .-_itoa_word
79 .p2align 4,,15
80 .globl _fitoa_word
81 .hidden _fitoa_word
82 .type _fitoa_word, @function
83 _fitoa_word:
84 subq $40, %rsp
85 movq %rsi, %r9
86 leaq 32(%rsp), %rsi
87 call _itoa_word
88 leaq 32(%rsp), %rdi
89 cmpq %rdi, %rax
90 jnb .L22
91 movq %rdi, %rsi
92 xorl %edx, %edx
93 subq %rax, %rsi
94 .p2align 4,,10
95 .p2align 3
96 .L21:
97 movzbl (%rax,%rdx), %ecx
98 movb %cl, (%r9,%rdx)
99 addq $1, %rdx
100 cmpq %rsi, %rdx
101 jne .L21
102 leaq 33(%rsp), %rdx
103 addq $1, %rax
104 addq $40, %rsp
105 subq %rax, %rdx
106 movq %rdx, %rax
107 addq %r9, %rax
109 .p2align 4,,10
110 .p2align 3
111 .L22:
112 movq %r9, %rax
113 addq $40, %rsp
115 .size _fitoa_word, .-_fitoa_word
116 .hidden _itoa_upper_digits
117 .hidden _itoa_lower_digits