home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib32.zoo / lattice / _mulsi3.s < prev    next >
Text File  |  1992-06-15  |  1KB  |  51 lines

  1. ; long integer multiplication routine
  2. ;
  3. ; written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
  4. ;
  5. ;
  6. ; Revision 1.1, kub 03-90
  7. ; first version, replaces the appropriate routine from fixnum.s.
  8. ; This one is longer, but normally faster because __umulsi3 is no longer
  9. ; called for multiplication. Rather, the code is inlined here. See the
  10. ; comments in _umulsi3.s
  11.  
  12.     text
  13.     even
  14.     xdef    __CXM22
  15.  
  16. __CXM22:
  17.     movem.l    d2-d3,-(sp)
  18.     move.l    d1,d2
  19.     move.l    d1,d3
  20.     swap    d2
  21.     move.l    d0,d1
  22.     swap    d0
  23.     
  24.     move.w    d0,-(sp)    ; sign flag
  25.     bpl.s    1$        ; is u negative ?
  26.     neg.w    d1        ; yes, force it positive
  27.     negx.w    d0
  28. 1$:    tst.w    d2        ; is v negative ?
  29.     bpl.s    2$
  30.     neg.w    d3        ; yes, force it positive ...
  31.     negx.w    d2
  32.     not.w    (sp)        ;  ... and modify flag word
  33. 2$:
  34.     ext.l    d0        ; u.h <> 0 ?
  35.     beq.s    3$
  36.     mulu.w    d3,d0        ; r  = v.l * u.h
  37. 3$:    tst.w    d2        ; v.h <> 0 ?
  38.     beq.s    4$
  39.     mulu.w    d1,d2        ; r += v.h * u.l
  40.     add.w    d2,d0
  41. 4$:    swap    d0
  42.     clr.w    d0
  43.     mulu.w    d3,d1        ; r += v.l * u.l
  44.     add.l    d1,d0
  45.     tst.w    (sp)+        ; should the result be negated ?
  46.     bpl.s    5$        ; no, just return
  47.     neg.l    d0        ; else r = -r
  48. 5$    movem.l    (sp)+,d2-d3
  49.     rts
  50.     end
  51.