xref: /csrg-svn/lib/libc/vax/gen/umodsi3.s (revision 47826)
1*47826Sdonn/*-
2*47826Sdonn * Copyright (c) 1991 The Regents of the University of California.
3*47826Sdonn * All rights reserved.
4*47826Sdonn *
5*47826Sdonn * %sccs.include.redist.c%
6*47826Sdonn */
7*47826Sdonn
8*47826Sdonn#if defined(LIBC_SCCS) && !defined(lint)
9*47826Sdonn	.asciz "@(#)umodsi3.s	6.1 (Berkeley) 04/05/91"
10*47826Sdonn#endif /* LIBC_SCCS and not lint */
11*47826Sdonn
12*47826Sdonn/*
13*47826Sdonn * Unsigned modulus, GCC flavor.
14*47826Sdonn */
15*47826Sdonn
16*47826Sdonn#include "DEFS.h"
17*47826Sdonn
18*47826Sdonn#define	DIVIDEND	4(ap)
19*47826Sdonn#define	DIVISOR		8(ap)
20*47826Sdonn
21*47826SdonnENTRY(__umodsi3,0)
22*47826Sdonn	movl	DIVISOR,r2
23*47826Sdonn	jlss	Leasy		# big divisor: settle by comparison
24*47826Sdonn	movl	DIVIDEND,r0
25*47826Sdonn	jlss	Lhard		# big dividend: need extended division
26*47826Sdonn	divl3	r2,r0,r1	# small divisor and dividend: signed modulus
27*47826Sdonn	mull2	r2,r1
28*47826Sdonn	subl2	r1,r0
29*47826Sdonn	ret
30*47826SdonnLhard:
31*47826Sdonn	clrl	r1
32*47826Sdonn	ediv	r2,r0,r1,r0
33*47826Sdonn	ret
34*47826SdonnLeasy:
35*47826Sdonn	subl3	r2,DIVIDEND,r0
36*47826Sdonn	jcc	Ldifference	# if divisor goes in once, return difference
37*47826Sdonn	movl	DIVIDEND,r0	# if divisor is bigger, return dividend
38*47826SdonnLdifference:
39*47826Sdonn	ret
40