1*34438Sbostic/* 2*34438Sbostic * Copyright (c) 1988 Regents of the University of California. 3*34438Sbostic * All rights reserved. 4*34438Sbostic * 5*34438Sbostic * This code is derived from software contributed to Berkeley by 6*34438Sbostic * Computer Consoles Inc. 7*34438Sbostic * 8*34438Sbostic * Redistribution and use in source and binary forms are permitted 9*34438Sbostic * provided that this notice is preserved and that due credit is given 10*34438Sbostic * to the University of California at Berkeley. The name of the University 11*34438Sbostic * may not be used to endorse or promote products derived from this 12*34438Sbostic * software without specific prior written permission. This software 13*34438Sbostic * is provided ``as is'' without express or implied warranty. 14*34438Sbostic */ 1529702Ssam 16*34438Sbostic#if defined(LIBC_SCCS) && !defined(lint) 17*34438Sbostic_sccsid:.asciz "@(#)udiv.s 1.3 (Berkeley) 05/23/88" 18*34438Sbostic#endif /* LIBC_SCCS and not lint */ 19*34438Sbostic 2029702Ssam/* 2129702Ssam * Unsigned divide. 2229702Ssam * 2329702Ssam * udiv(dividend, divisor) 2429702Ssam */ 2529702Ssam#include "DEFS.h" 2629702Ssam 2729702SsamASENTRY(udiv, 0) 2829702Ssam bitl $0x80000000,8(fp) # if (divisor & 0x80000000){ 2929702Ssam jeql 1f 3029702Ssam cmpl 8(fp),4(fp) # if (divisor > dividend ) 3129702Ssam jlequ 2f 3229702Ssam clrl r0 # return(0); 3329702Ssam ret 3429702Ssam2: # else 3529702Ssam movl $1,r0 # return(1);} 3629702Ssam ret 3729702Ssam1: 3832977Sdonn clrl r2 # return(dividend/divisor); 3932977Sdonn movl 4(fp),r3 4032977Sdonn ediv 8(fp),r2,r0,r1 4129702Ssam ret 4232977Sdonn 4332977Sdonn/* 4432977Sdonn * audiv(dividendp, divisor) -- like udiv but uses address of dividend. 4532977Sdonn * Implements /= avoiding side effects in the dividend expression. 4632977Sdonn */ 4732977SdonnASENTRY(audiv, 0) 4832977Sdonn bitl $0x80000000,8(fp) # if (divisor & 0x80000000){ 4932977Sdonn jeql 1f 5032977Sdonn cmpl 8(fp),*4(fp) # if (divisor > dividend ) 5132977Sdonn jlequ 2f 5232977Sdonn clrl r0 # return(0); 5332977Sdonn jbr 3f 5432977Sdonn2: # else 5532977Sdonn movl $1,r0 # return(1);} 5632977Sdonn jbr 3f 5732977Sdonn1: 5832977Sdonn clrl r2 # return(dividend/divisor); 5932977Sdonn movl *4(fp),r3 6032977Sdonn ediv 8(fp),r2,r0,r1 6132977Sdonn3: 6232977Sdonn movl r0,*4(fp) 6332977Sdonn ret 64