Annotation of 43BSD/ucb/lisp/franz/68k/dsmult.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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