double_prec_mult.s 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # mach: bfin
  2. .include "testutils.inc"
  3. start
  4. // This function computes an integer 32x32 multiply,
  5. // and returns the upper 32 bits of the result.
  6. // If the complete 64 bit result is required, one must
  7. // write the partial results as they are computed.
  8. // To change this code for a fractional 32x32, one needs
  9. // to adjust the shifts for magnitude of -15, and use a
  10. // fractional multiply at the end for the upper word halves
  11. // (instead of the integer one).
  12. loadsym P0, input_a;
  13. loadsym P1, input_b;
  14. loadsym P2, output;
  15. P4 = 10;
  16. LSETUP ( loop1 , loop1end ) LC0 = P4;
  17. loop1:
  18. R0 = [ P0 ++ ];
  19. R1 = [ P1 ++ ];
  20. // begin integer double precision routine
  21. // 32 x 32 -> 32
  22. A1 = R0.H * R1.L (M), A0 = R0.L * R1.L (FU);
  23. A1 += R1.H * R0.L (M,IS);
  24. A0 = A0 >>> 16;
  25. A0 += A1;
  26. A0 = A0 >>> 16;
  27. A0 += R0.H * R1.H (IS);
  28. R7 = A0.w;
  29. loop1end:
  30. [ P2 ++ ] = R7; // store 32 bit output
  31. // test results
  32. loadsym P1, output;
  33. R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0xab6b );
  34. R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0xa627 );
  35. R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0xa0e3 );
  36. R0 = [ P1 ++ ]; DBGA ( R0.H , 0xfeae ); DBGA ( R0.L , 0x9b9f );
  37. pass
  38. .data
  39. input_a:
  40. .dw 0x0000
  41. .dw 0xfabc
  42. .dw 0x0000
  43. .dw 0xfabc
  44. .dw 0x0000
  45. .dw 0xfabc
  46. .dw 0x0000
  47. .dw 0xfabc
  48. .dw 0x0000
  49. .dw 0xfabc
  50. .dw 0x0000
  51. .dw 0xfabc
  52. .dw 0x0000
  53. .dw 0xfabc
  54. .dw 0x0000
  55. .dw 0xfabc
  56. .dw 0x0000
  57. .dw 0xfabc
  58. .dw 0x0000
  59. .dw 0xfabc
  60. .align 4;
  61. input_b:
  62. .dw 0x1000
  63. .dw 0x4010
  64. .dw 0x1000
  65. .dw 0x4011
  66. .dw 0x1000
  67. .dw 0x4012
  68. .dw 0x1000
  69. .dw 0x4013
  70. .dw 0x1000
  71. .dw 0x4014
  72. .dw 0x1000
  73. .dw 0x4015
  74. .dw 0x1000
  75. .dw 0x4016
  76. .dw 0x1000
  77. .dw 0x4017
  78. .dw 0x1000
  79. .dw 0x4018
  80. .dw 0x1000
  81. .dw 0x4019
  82. .align 4;
  83. output:
  84. .space (40);