# 2.11BSD#431 - /usr/src/lib/libc/pdp/crt/alrem.s

##### Functions

    alrem             X

##### Macros

    one               X

       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:         <@(#)alrem.s	2.4 (2.11BSD GTE) 12/26/92\0>
       9:         .even
      10: #endif LIBC_SCCS
      11:
      12: /*
      13:  * alrem(lhs, rhs)
      14:  *	long	*lhs, rhs;
      15:  *
      16:  * 32-bit "/=" routine.  Calls to aldiv are generated automatically by the C
      17:  * compiler.  See lrem for more detailed comments.
      18:  */
      19: #include "DEFS.h"
      20:
      21: /*
      22:  * Alrem for floating point hardware.  Check for divide by zero.  Don't want
      23:  * floating divide trap in integer math.
      24:  */
      25: #define one     040200
      26:
      27: ASENTRY(alrem)
      28:         tst     4(sp)           / divide by zero check
      29:         bne     1f
      30:         tst     6(sp)
      31:         bne     1f
      32:         mov     2(sp),r1        / return lhs
      33:         mov     (r1)+,r0
      34:         mov     (r1),r1
      35:         rts     pc
      36: 1:
      37:         setl
      38:         mov     2(sp),r1
      39:         movif   (r1),fr0        / fr0 = *lhs
      40:         movf    fr0,fr2         / fr2 = *lhs
      41:         movif   4(sp),fr3       / fr3 = rhs
      42:         divf    fr3,fr0         / fr0 = *lhs/rhs
      43:         modf    $one,fr0        / fr1 = integer((*lhs/rhs) * 1.0)
      44:         mulf    fr3,fr1         / fr1 = integer(*lhs/rhs) * rhs
      45:         subf    fr1,fr2         / fr2 = *lhs - (integer(*lhs/rhs) * rhs)
      46:         movfi   fr2,(r1)        / *lhs = fr2
      47:         mov     (r1)+,r0        / and return result
      48:         mov     (r1),r1
      49:         seti
      50:         rts     pc
      51: #ifdef  never
      52: /*
      53:  * Alrem for fixed point hardware.
      54:  */
      55: .globl  lrem                    / 32-bit "%" routine
      56:
      57: ASENTRY(alrem)
      58:         mov     r2,-(sp)        / need a register to point at the lhs
      59:         mov     8.(sp),-(sp)    / The fixed point remainder algorithm is long
      60:         mov     8.(sp),-(sp)    /   enough that it just doesn't make sense
      61:         mov     8.(sp),r2       /   to bother repeating it.  We just translate
      62:         mov     2(r2),-(sp)     /   the call for lrem and let it do the work
      63:         mov     (r2),-(sp)      /   and return its results (also stuffing it
      64:         jsr     pc,lrem         /   into *lhs)
      65:         add     8.,sp           / clean up stack
      66:         mov     r0,(r2)+        / store high word,
      67:         mov     r1,(r2)         /   and low
      68:         mov     (sp)+,r2        / restore r2
      69:         rts     pc              /   and return
      70: #endif

#### Defined functions

alrem defined in line 57; never used

#### Defined macros

one defined in line 25; used 1 times

- in line 43

Last modified: 1992-12-27 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 759 |