home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / coding / dsp / c5xug.exe / INTMULT.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-05-02  |  2.0 KB  |  68 lines

  1. ;**************************************************************
  2. ;  
  3. ;                 intmult.asm
  4. ;  
  5. ;                 staff
  6. ;  
  7. ;                 05-02-91
  8. ;  
  9. ;           (C) Texas Instruments Inc., 1992 
  10. ;  
  11. ;           Refer to the file 'license.txt' included with this 
  12. ;           this package for usage and license information. 
  13. ;  
  14. ;**************************************************************
  15. Example 7-xx. 32-bit Integer Multiplication
  16.  
  17.  
  18.  
  19.    .title "32-bit Optimized Integer Multiplication"
  20.    .def    MPY32
  21.  
  22. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  23. ; This routine multiplies two 32-bit signed integers resulting
  24. ; in a 64-bit product. The operands are fetched from data
  25. ; memory and the result is written back to data memory.
  26. ; Data Storage:
  27. ;    X1,X0        32-bit operand
  28. ;    Y1,Y0        32-bit operand
  29. ;    W3,W2,W1,W0    64-bit product
  30. ; Entry Conditions:
  31. ;    DP  = 6, SXM = 1
  32. ;    OVM = 0
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34.  
  35. X1     .set    300h    ;DP=6
  36. X0     .set    301h    ;DP=6
  37. Y1     .set    302h    ;DP=6
  38. Y0     .set    303h    ;DP=6
  39. W3     .set    304h    ;DP=6
  40. W2     .set    305h    ;DP=6
  41. W1     .set    306h    ;DP=6
  42. W0     .set    307h    ;DP=6
  43.  
  44.  
  45.        .text
  46.  
  47.  
  48. MPY32:       BIT       X0,0        ;TC = X0 bit#15
  49.        LT       X0           ;T = X0
  50.        MPYU    Y0           ;P = X0Y0
  51.        SPL       W0           ;Save W0
  52.        SPH       W1           ;Save partial W1
  53.        MPY       Y1           ;P = X0Y1
  54.        LTP       X1           ;Acc = X0Y1, T = X1
  55.        MPY       Y0           ;P = X1Y0
  56.        MPYA    Y1           ;Acc = X0Y1+X1Y0, P=X1Y1
  57.        ADDS    W1           ;Acc = X0Y1+X1Y0+X0Y02^-16
  58.        SACL    W1           ;Save final W1
  59.        BSAR    16           ;Shift Acc right by 16
  60.        XC       1,TC        ;If MSB of X0 is 1
  61.        ADD       Y1           ;Add Y1
  62.        BIT       Y0,0        ;TC = Y0 bit#15
  63.        APAC            ;ACC = X1Y1 + (X0Y1+X1Y0)2^-16
  64.        XC       1,TC        ;IF MSB of Y0 is 1
  65.        ADD       X1           ;Add X1
  66.        SACL    W2           ;Save W2
  67.        SACH    W3           ;Save W3
  68.