147826Sdonn/*- 2*61225Sbostic * Copyright (c) 1991, 1993 3*61225Sbostic * The Regents of the University of California. All rights reserved. 447826Sdonn * 547994Sdonn * This code is derived from software contributed to Berkeley by 647994Sdonn * Donn Seeley at UUNET Technologies, Inc. 747994Sdonn * 847826Sdonn * %sccs.include.redist.c% 947826Sdonn */ 1047826Sdonn 1147826Sdonn#if defined(LIBC_SCCS) && !defined(lint) 12*61225Sbostic .asciz "@(#)umodsi3.s 8.1 (Berkeley) 06/04/93" 1347826Sdonn#endif /* LIBC_SCCS and not lint */ 1447826Sdonn 1547826Sdonn/* 1647826Sdonn * Unsigned modulus, GCC flavor. 1747826Sdonn */ 1847826Sdonn 1947826Sdonn#include "DEFS.h" 2047826Sdonn 2147826Sdonn#define DIVIDEND 4(ap) 2247826Sdonn#define DIVISOR 8(ap) 2347826Sdonn 2447826SdonnENTRY(__umodsi3,0) 2547826Sdonn movl DIVISOR,r2 2647826Sdonn jlss Leasy # big divisor: settle by comparison 2747826Sdonn movl DIVIDEND,r0 2847826Sdonn jlss Lhard # big dividend: need extended division 2947826Sdonn divl3 r2,r0,r1 # small divisor and dividend: signed modulus 3047826Sdonn mull2 r2,r1 3147826Sdonn subl2 r1,r0 3247826Sdonn ret 3347826SdonnLhard: 3447826Sdonn clrl r1 3547826Sdonn ediv r2,r0,r1,r0 3647826Sdonn ret 3747826SdonnLeasy: 3847826Sdonn subl3 r2,DIVIDEND,r0 3947826Sdonn jcc Ldifference # if divisor goes in once, return difference 4047826Sdonn movl DIVIDEND,r0 # if divisor is bigger, return dividend 4147826SdonnLdifference: 4247826Sdonn ret 43