arch/sparc/lib/udivdi3.S

Source file repositories/reference/linux-study-clean/arch/sparc/lib/udivdi3.S

File Facts

System
Linux kernel
Corpus path
arch/sparc/lib/udivdi3.S
Extension
.S
Size
4833 bytes
Lines
248
Domain
Architecture Layer
Bucket
arch/sparc
Inferred role
Architecture Layer: arch/sparc
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

This file is part of GNU CC.

 */

	.text
	.align 4
	.globl __udivdi3
__udivdi3:
	save %sp,-104,%sp
	mov %i3,%o3
	cmp %i2,0
	bne .LL40
	mov %i1,%i3
	cmp %o3,%i0
	bleu .LL41
	mov %i3,%o1
	! Inlined udiv_qrnnd
	mov	32,%g1
	subcc	%i0,%o3,%g0
1:	bcs	5f
	 addxcc %o1,%o1,%o1	! shift n1n0 and a q-bit in lsb
	sub	%i0,%o3,%i0	! this kills msb of n
	addx	%i0,%i0,%i0	! so this cannot give carry
	subcc	%g1,1,%g1
2:	bne	1b
	 subcc	%i0,%o3,%g0
	bcs	3f
	 addxcc %o1,%o1,%o1	! shift n1n0 and a q-bit in lsb
	b	3f
	 sub	%i0,%o3,%i0	! this kills msb of n
4:	sub	%i0,%o3,%i0
5:	addxcc	%i0,%i0,%i0
	bcc	2b
	 subcc	%g1,1,%g1
! Got carry from n.  Subtract next step to cancel this carry.
	bne	4b
	 addcc	%o1,%o1,%o1	! shift n1n0 and a 0-bit in lsb
	sub	%i0,%o3,%i0
3:	xnor	%o1,0,%o1
	! End of inline udiv_qrnnd
	b .LL45
	mov 0,%o2
.LL41:
	cmp %o3,0
	bne .LL77
	mov %i0,%o2
	mov 1,%o0
	mov 0,%o1
	wr %g0, 0, %y
	udiv %o0, %o1, %o0
	mov %o0,%o3
	mov %i0,%o2
.LL77:
	mov 0,%o4
	! Inlined udiv_qrnnd
	mov	32,%g1
	subcc	%o4,%o3,%g0
1:	bcs	5f
	 addxcc %o2,%o2,%o2	! shift n1n0 and a q-bit in lsb
	sub	%o4,%o3,%o4	! this kills msb of n
	addx	%o4,%o4,%o4	! so this cannot give carry
	subcc	%g1,1,%g1
2:	bne	1b
	 subcc	%o4,%o3,%g0
	bcs	3f
	 addxcc %o2,%o2,%o2	! shift n1n0 and a q-bit in lsb
	b	3f
	 sub	%o4,%o3,%o4	! this kills msb of n
4:	sub	%o4,%o3,%o4
5:	addxcc	%o4,%o4,%o4

Annotation

Implementation Notes