Annotation of 43BSDReno/pgrm/lisp/franz/tahoe/dsmult.c, revision 1.1

1.1     ! root        1: /* Copyright (c) 1982, Regents, University of California */
        !             2: /*
        !             3:  * dsmult(top,bot,mul) --
        !             4:  * multiply an array of longs on the stack, by mul.
        !             5:  * the element top through bot (inclusive) get changed.
        !             6:  * if you expect a carry out of the most significant,
        !             7:  * it is up to you to provide a space for it to overflow.
        !             8:  */
        !             9: 
        !            10: struct vl
        !            11:        {long high;
        !            12:        long low;
        !            13:        };
        !            14: 
        !            15: dsmult(top,bot,mul)
        !            16: long *top, *bot, mul;
        !            17: {
        !            18:        register long *p;
        !            19:        struct vl work;
        !            20:        long add = 0;
        !            21: 
        !            22:        for(p = top; p >= bot; p--) {
        !            23:                asm("emul       (r12),12(fp),-64(fp),-60(fp)");
        !            24: /* *p has 30 bits of info, mul has 32 yielding a 62 bit product. */
        !            25:                *p = work.low & 0x3fffffff; /* the stack gets the low 30 bits */
        !            26:                add = work.high;        /* we want add to get the next 32 bits.
        !            27:                                           on a 68k you might better be able to
        !            28:                                           do this by shifts and tests on the
        !            29:                                           carry but I don't know how to do this
        !            30:                                           from C, and the code generated here
        !            31:                                           will not be much worse.  Far less
        !            32:                                           bad than shifting work.low to the
        !            33:                                           right 30 bits just to get the top 2.
        !            34:                                           */
        !            35:                add <<= 2;
        !            36:                if(work.low < 0) add += 2;
        !            37:                if(work.low & 0x40000000) add += 1;
        !            38:        }
        !            39:        p[1] = work.low;  /* on the final store want all 32 bits. */
        !            40: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.