multiply.c 424 B

12345678910111213141516171819202122232425
  1. // See LICENSE for license details.
  2. // *************************************************************************
  3. // multiply function (c version)
  4. // -------------------------------------------------------------------------
  5. int multiply( int x, int y )
  6. {
  7. int i;
  8. int result = 0;
  9. for (i = 0; i < 32; i++) {
  10. if ((x & 0x1) == 1)
  11. result = result + y;
  12. x = x >> 1;
  13. y = y << 1;
  14. }
  15. return result;
  16. }