11.4Srin/*	$NetBSD: umodsi3.S,v 1.4 2020/04/23 03:12:49 rin Exp $	*/
21.1Sfredette
31.1Sfredette/*-
41.3Srin * Copyright (c) 1990 The Regents of the University of California.
51.1Sfredette * All rights reserved.
61.1Sfredette *
71.3Srin * This code is derived from software contributed to Berkeley by
81.3Srin * the Systems Programming Group of the University of Utah Computer
91.3Srin * Science Department.
101.1Sfredette *
111.1Sfredette * Redistribution and use in source and binary forms, with or without
121.1Sfredette * modification, are permitted provided that the following conditions
131.1Sfredette * are met:
141.1Sfredette * 1. Redistributions of source code must retain the above copyright
151.1Sfredette *    notice, this list of conditions and the following disclaimer.
161.1Sfredette * 2. Redistributions in binary form must reproduce the above copyright
171.1Sfredette *    notice, this list of conditions and the following disclaimer in the
181.1Sfredette *    documentation and/or other materials provided with the distribution.
191.3Srin * 3. Neither the name of the University nor the names of its contributors
201.3Srin *    may be used to endorse or promote products derived from this software
211.3Srin *    without specific prior written permission.
221.1Sfredette *
231.3Srin * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
241.3Srin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251.3Srin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261.3Srin * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
271.3Srin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281.3Srin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291.3Srin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301.3Srin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311.3Srin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321.3Srin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331.3Srin * SUCH DAMAGE.
341.1Sfredette */
351.1Sfredette
361.1Sfredette#include <machine/asm.h>
371.1Sfredette
381.1Sfredette#if defined(LIBC_SCCS) && !defined(lint)
391.3Srin#if 0
401.3Srin	RCSID("from: @(#)umodsi3.s	5.1 (Berkeley) 6/7/90")(
411.3Srin#else
421.4Srin	RCSID("$NetBSD: umodsi3.S,v 1.4 2020/04/23 03:12:49 rin Exp $")
431.3Srin#endif
441.1Sfredette#endif /* LIBC_SCCS and not lint */
451.1Sfredette
461.3Srin/* unsigned % unsigned */
471.3Srin#ifndef __mc68010__
481.4Srin/* XXX sun3 need this for bootloader */
491.3SrinENTRY(__umodsi3)
501.3Srin	movel	4(%sp),%d1
511.3Srin#ifdef __mcoldfire__
521.3Srin	remul	8(%sp),%d0:%d1
531.3Srin	divul	8(%sp),%d1
541.3Srin#else
551.3Srin	divull	8(%sp),%d0:%d1
561.3Srin#endif
571.3Srin	rts
581.3SrinEND(__umodsi3)
591.3Srin#else
601.1SfredetteENTRY(__umodsi3)
611.1Sfredette| NB: this requires that __udivsi3 preserve the %a0
621.1Sfredette| register, and that it returns the modulus in %d1:
631.3Srin	movel	(%sp)+, %a0	| pop the return address
641.1Sfredette	jsr	_C_LABEL(__udivsi3)
651.1Sfredette	movel	%d1, %d0	| move the modulus into %d0
661.3Srin	jmp	(%a0)		| return
671.3SrinEND(__umodsi3)
681.3Srin#endif /* __mc68010__ */
69