arch/sparc/lib/divdi3.S

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

File Facts

System
Linux kernel
Corpus path
arch/sparc/lib/divdi3.S
Extension
.S
Size
5086 bytes
Lines
272
Domain
Architecture Layer
Bucket
arch/sparc
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration implementation candidate

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.

 */

#include <linux/export.h>
	.text
	.align 4
	.globl __divdi3
__divdi3:
	save %sp,-104,%sp
	cmp %i0,0
	bge .LL40
	mov 0,%l4
	mov -1,%l4
	sub %g0,%i1,%o0
	mov %o0,%o5
	subcc %g0,%o0,%g0
	sub %g0,%i0,%o0
	subx %o0,0,%o4
	mov %o4,%i0
	mov %o5,%i1
.LL40:
	cmp %i2,0
	bge .LL84
	mov %i3,%o4
	xnor %g0,%l4,%l4
	sub %g0,%i3,%o0
	mov %o0,%o3
	subcc %g0,%o0,%g0
	sub %g0,%i2,%o0
	subx %o0,0,%o2
	mov %o2,%i2
	mov %o3,%i3
	mov %i3,%o4
.LL84:
	cmp %i2,0
	bne .LL45
	mov %i1,%i3
	cmp %o4,%i0
	bleu .LL46
	mov %i3,%o1
	mov	32,%g1
	subcc	%i0,%o4,%g0
1:	bcs	5f
	 addxcc %o1,%o1,%o1	! shift n1n0 and a q-bit in lsb
	sub	%i0,%o4,%i0	! this kills msb of n
	addx	%i0,%i0,%i0	! so this cannot give carry
	subcc	%g1,1,%g1
2:	bne	1b
	 subcc	%i0,%o4,%g0
	bcs	3f
	 addxcc %o1,%o1,%o1	! shift n1n0 and a q-bit in lsb
	b	3f
	 sub	%i0,%o4,%i0	! this kills msb of n
4:	sub	%i0,%o4,%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,%o4,%i0
3:	xnor	%o1,0,%o1
	b .LL50
	mov 0,%o2
.LL46:
	cmp %o4,0
	bne .LL85
	mov %i0,%o2
	mov 1,%o0

Annotation

Implementation Notes