os-k/obj/kaleid/common/ltoa.S

77 lines
1.2 KiB
ArmAsm

.file "convert.c"
.text
.p2align 4,,15
.globl ltoa
.type ltoa, @function
ltoa:
.LFB2:
.cfi_startproc
leal -2(%rdx), %ecx
movq %rdi, %rax
cmpl $34, %ecx
ja .L2
testq %rdi, %rdi
js .L11
jne .L7
leaq 1(%rsi), %r9
movb $48, (%rsi)
.L5:
movb $0, (%r9)
movq %rsi, %rdi
movabsq $reverse, %rax
jmp *%rax
.p2align 4,,10
.p2align 3
.L11:
negq %rax
movl $1, %edi
.L4:
movslq %edx, %r8
movq %rsi, %r9
movabsq $digits, %r10
jmp .L6
.p2align 4,,10
.p2align 3
.L8:
movq %rcx, %r9
.L6:
cqto
leaq 1(%r9), %rcx
idivq %r8
movzbl (%r10,%rdx), %edx
testq %rax, %rax
movb %dl, -1(%rcx)
jne .L8
testl %edi, %edi
je .L9
addq $2, %r9
movb $45, (%rcx)
jmp .L5
.p2align 4,,10
.p2align 3
.L7:
xorl %edi, %edi
jmp .L4
.p2align 4,,10
.p2align 3
.L2:
xorl %eax, %eax
ret
.p2align 4,,10
.p2align 3
.L9:
movq %rcx, %r9
jmp .L5
.cfi_endproc
.LFE2:
.size ltoa, .-ltoa
.section .rodata
.align 32
.type digits, @object
.size digits, 36
digits:
.byte 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43
.byte 0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50
.byte 0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a
.ident "GCC: (GNU) 7.3.0"