home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / aix / 9107 < prev    next >
Encoding:
Text File  |  1992-08-26  |  1.8 KB  |  60 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!sarah!dinner.asrc.albany.edu!rob
  3. From: rob@dinner.asrc.albany.edu (Robert D. Seals)
  4. Subject: Assembly long multiply for mandelspawn, anyone?
  5. Message-ID: <1992Aug26.175258.7569@sarah.albany.edu>
  6. Sender: news@sarah.albany.edu (News Administrator)
  7. Organization: SUNYA - ASRC, Albany, NY
  8. Date: Wed, 26 Aug 92 17:52:58 GMT
  9. Lines: 49
  10.  
  11.  
  12. Hey,
  13. Has anybody figgered out the POWER assembly code to implement
  14. the fixed point multiply code for mandelspawn? The idea -
  15. like that used in fractint - is to use hardware fixed point
  16. arithmetic to speed up the inner loop multiplies in the
  17. mandelbrot code. Here is the code (note it's compiled
  18. with GCC - the 'inline' keyword) for 68000 and VAX...
  19.  
  20. #ifdef mc68000
  21. static inline unsigned long fracmult(x,y) unsigned long x,y;
  22. { unsigned long high;
  23.   asm("mulsl %3,%1,%0" : "=d" (x), "=d" (high): "0" (x), "d" (y));
  24.   return((high<<LEFTBITS) | (x>>RIGHTBITS));
  25. }
  26.  
  27. static inline unsigned long fracmult2(x,y) unsigned long x,y;
  28. { unsigned long high;
  29.   asm("mulsl %3,%1,%0" : "=d" (x), "=d" (high): "0" (x), "d" (y));
  30.   return((high<<(LEFTBITS+1)) | (x>>(RIGHTBITS-1)));
  31. }
  32. #endif /* mc68000 */
  33.  
  34. #ifdef vax  /* VAX code due to Jussi Maki, thanks */
  35. typedef struct 
  36. { unsigned int i0;
  37.   unsigned int i1;
  38. } int64;
  39.  
  40. static inline unsigned long fracmult(x,y) unsigned long x,y;
  41. { int64 r;
  42.   asm("emul %1,%2,$0,%0" : "=g" (r) : "g" (x), "g" (y));
  43.   return((r.i1<<LEFTBITS) | (r.i0>>RIGHTBITS));
  44. }
  45.  
  46. static inline unsigned long fracmult2(x,y) unsigned long x,y;
  47. { int64 r;
  48.   asm("emul %1,%2,$0,%0" : "=g" (r) : "g" (x), "g" (y));
  49.   return((r.i1<<LEFTBITS+1) | (r.i0>>RIGHTBITS-1));
  50. }
  51. #endif /* vax */
  52.  
  53. I hate it when sparc ipcs on the network are faster than my machine...
  54.  
  55. rob
  56. -- 
  57. ------
  58. Crazy, man.
  59. rob@dinner.asrc.albany.edu
  60.