1/*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Donn Seeley at UUNET Technologies, Inc. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11#if defined(LIBC_SCCS) && !defined(lint) 12 .asciz "@(#)umodsi3.s 6.2 (Berkeley) 04/15/91" 13#endif /* LIBC_SCCS and not lint */ 14 15/* 16 * Unsigned modulus, GCC flavor. 17 */ 18 19#include "DEFS.h" 20 21#define DIVIDEND 4(ap) 22#define DIVISOR 8(ap) 23 24ENTRY(__umodsi3,0) 25 movl DIVISOR,r2 26 jlss Leasy # big divisor: settle by comparison 27 movl DIVIDEND,r0 28 jlss Lhard # big dividend: need extended division 29 divl3 r2,r0,r1 # small divisor and dividend: signed modulus 30 mull2 r2,r1 31 subl2 r1,r0 32 ret 33Lhard: 34 clrl r1 35 ediv r2,r0,r1,r0 36 ret 37Leasy: 38 subl3 r2,DIVIDEND,r0 39 jcc Ldifference # if divisor goes in once, return difference 40 movl DIVIDEND,r0 # if divisor is bigger, return dividend 41Ldifference: 42 ret 43