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

##### Functions

    almul             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:         <@(#)almul.s	2.3 (Berkeley) 1/28/87\0>
       9:         .even
      10: #endif LIBC_SCCS
      11:
      12: /*
      13:  * almul(lhs, rhs)
      14:  *	long	*lhs, rhs;
      15:  *
      16:  * 32-bit "*=" routine for fixed point hardware.  Also recommended for floating
      17:  * hardware, for compatility & speed.  Credit to an unknown author who slipped
      18:  * it under the door.  Calls to aldiv are generated automatically by the C
      19:  * compiler.
      20:  */
      21: #include "DEFS.h"
      22:
      23: ASENTRY(almul)
      24:         mov     r2,-(sp)        / save r2-4
      25:         mov     r3,-(sp)
      26:         mov     r4,-(sp)
      27:         mov     8.(sp),r4       / r4 = lhs
      28:         mov     2(r4),r2        / r2 = loint(*lhs)
      29:         sxt     r1              / r1 = sxt(loint(*lhs)) - hiint(*lhs)
      30:         sub     (r4),r1
      31:         mov     12.(sp),r0      / r0 = loint(rhs)
      32:         sxt     r3              / r3 = sxt(loint(rhs)) - hiint(rhs)
      33:         sub     10.(sp),r3
      34:         mul     r0,r1           / MAGIC = loint(rhs) * hiint(*lhs)'
      35:         mul     r2,r3           /       + loint(*lhs) * hiint(rhs)'
      36:         add     r1,r3
      37:         mul     r2,r0           / prod (r0:r1) = loint(lhs)*loint(rhs)
      38:         sub     r3,r0           / hiint(prod) -= MAGIC
      39:         mov     r0,(r4)+        / *lhs = prod
      40:         mov     r1,(r4)
      41:         mov     (sp)+,r4        / restore regsisters
      42:         mov     (sp)+,r3        /   and return
      43:         mov     (sp)+,r2
      44:         rts     pc

#### Defined functions

almul defined in line 23; never used

Last modified: 1987-01-28 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 770 |