1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         <@(#)aldiv.s	2.4 (2.11BSD GTE) 12/26/92\0>
   9:         .even
  10: #endif LIBC_SCCS
  11: 
  12: /*
  13:  * aldiv(lhs, rhs)
  14:  *	long	*lhs, rhs;
  15:  *
  16:  * 32-bit "/=" routine.  Calls to aldiv are generated automatically by the C
  17:  * compiler.  See ldiv for more detailed comments.
  18:  */
  19: #include "DEFS.h"
  20: 
  21: /*
  22:  * Aldiv for floating point hardware.  Check for divide by zero.  Don't want
  23:  * floating divide trap in integer math.
  24:  */
  25: ASENTRY(aldiv)
  26:         tst     4(sp)           / divide by zero check
  27:         bne     1f
  28:         tst     6(sp)
  29:         bne     1f
  30:         mov     2(sp),r1        / return lhs
  31:         mov     (r1)+,r0        /
  32:         mov     (r1),r1
  33:         rts     pc
  34: 1:
  35:         setl
  36:         mov     2(sp),r1        / r1 = lhs
  37:         movif   (r1),fr0        / fr0 = *lhs
  38:         movif   4(sp),fr1       / fr1 = rhs
  39:         divf    fr1,fr0         / fr0 /= rhs
  40:         movfi   fr0,(r1)        / *lhs = fr0
  41:         mov     (r1)+,r0        / and return result
  42:         mov     (r1),r1
  43:         seti
  44:         rts     pc
  45: #ifdef  never
  46: /*
  47:  * Aldiv for fixed point hardware.
  48:  */
  49: .globl  ldiv                    / 32-bit "/" routine
  50: 
  51: ASENTRY(aldiv)
  52:         mov     r2,-(sp)        / need a register to point at the lhs
  53:         mov     8.(sp),-(sp)    / The fixed point divide algorithm is long
  54:         mov     8.(sp),-(sp)    /   enough that it just doesn't make sense
  55:         mov     8.(sp),r0       /   to bother repeating it.  We just translate
  56:         mov     2(r0),-(sp)     /   the call for ldiv and let it do the work
  57:         mov     (r0),-(sp)      /   and return its results (also stuffing it
  58:         jsr     pc,ldiv         /   into *lhs)
  59:         add     8.,sp           / clean up stack
  60:         mov     r0,(r2)+        / store high word,
  61:         mov     r1,(r2)         /   and low
  62:         mov     (sp)+,r2        / restore r2
  63:         rts     pc              /   and return
  64: #endif

Defined functions

aldiv defined in line 51; never used
Last modified: 1992-12-27
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2059
Valid CSS Valid XHTML 1.0 Strict