xref: /original-bsd/lib/libc/tahoe/gen/umodsi3.s (revision c3e32dec)
1/*
2 * Copyright (c) 1988, 1993
3 *	The Regents of the University of California.  All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Computer Consoles Inc.
9 */
10
11#if defined(LIBC_SCCS) && !defined(lint)
12	.asciz "@(#)umodsi3.s	8.1 (Berkeley) 06/04/93"
13#endif /* LIBC_SCCS and not lint */
14
15/*
16 * Unsigned remainder for GCC.
17 *
18 * __umodsi3(dividend, divisor)
19 */
20#include "DEFS.h"
21
22ENTRY(__umodsi3, 0)
23	bitl	$0x80000000,8(fp)	#  if (divisor & 0x80000000){
24	jeql	1f
25	movl	4(fp),r0
26	cmpl	8(fp),r0		#  if (divisor <= dividend )
27	jgtru	2f
28	subl2	8(fp),r0		#       return(dividend-divisor);
292:					#  else return(dividend);}
30	ret
311:
32	clrl	r2			#  return(dividend%divisor);
33	movl	4(fp),r3
34	ediv	8(fp),r2,r1,r0
35	ret
36