1/* 2 * Copyright (c) 1988 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11#if defined(LIBC_SCCS) && !defined(lint) 12 .asciz "@(#)urem.s 5.1 (Berkeley) 01/30/91" 13#endif /* LIBC_SCCS and not lint */ 14 15/* 16 * Unsigned remainder. 17 * 18 * urem(dividend, divisor) 19 */ 20#include "DEFS.h" 21 22ASENTRY(urem, 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 37/* 38 * aurem(dividendp, divisor) -- like urem but uses address of dividend. 39 * Implements %= avoiding side effects in the dividend expression. 40 */ 41ASENTRY(aurem, 0) 42 bitl $0x80000000,8(fp) # if (divisor & 0x80000000){ 43 jeql 1f 44 movl *4(fp),r0 45 cmpl 8(fp),r0 # if (divisor <= dividend ) 46 jgtru 2f 47 subl2 8(fp),r0 # return(dividend-divisor); 48 # else return(dividend);} 49 jbr 2f 501: 51 clrl r2 # return(dividend%divisor); 52 movl *4(fp),r3 53 ediv 8(fp),r2,r1,r0 542: 55 movl r0,*4(fp) 56 ret 57