1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. 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 "@(#)udiv.s 8.1 (Berkeley) 06/04/93" 13#endif /* LIBC_SCCS and not lint */ 14 15/* 16 * Unsigned division, PCC flavor. 17 * udiv() takes an ordinary dividend/divisor pair; 18 * audiv() takes a pointer to a dividend and an ordinary divisor. 19 */ 20 21#include "DEFS.h" 22 23#define DIVIDEND 4(ap) 24#define DIVISOR 8(ap) 25 26ASENTRY(udiv,0) 27 movl DIVISOR,r2 28 jlss Leasy # big divisor: settle by comparison 29 movl DIVIDEND,r0 30 jlss Lhard # big dividend: extended division 31 divl2 r2,r0 # small divisor and dividend: signed division 32 ret 33Lhard: 34 clrl r1 35 ediv r2,r0,r0,r1 36 ret 37Leasy: 38 cmpl DIVIDEND,r2 39 jgequ Lone # if dividend is as big or bigger, return 1 40 clrl r0 # else return 0 41 ret 42Lone: 43 movl $1,r0 44 ret 45 46ASENTRY(audiv,0) 47 movl DIVIDEND,r3 48 movl DIVISOR,r2 49 jlss La_easy # big divisor: settle by comparison 50 movl (r3),r0 51 jlss La_hard # big dividend: extended division 52 divl2 r2,r0 # small divisor and dividend: signed division 53 movl r0,(r3) # leave the value of the assignment in r0 54 ret 55La_hard: 56 clrl r1 57 ediv r2,r0,r0,r1 58 movl r0,(r3) 59 ret 60La_easy: 61 cmpl (r3),r2 62 jgequ La_one # if dividend is as big or bigger, return 1 63 clrl r0 # else return 0 64 clrl (r3) 65 ret 66La_one: 67 movl $1,r0 68 movl r0,(r3) 69 ret 70