home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / arch / 10957 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  3.7 KB

  1. Xref: sparky comp.arch:10957 comp.lang.misc:3811
  2. Path: sparky!uunet!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
  3. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  4. Newsgroups: comp.arch,comp.lang.misc
  5. Subject: Re: how to advocate new software/hardware features (Re: Hardware Support for Numeric Algorithms)
  6. Message-ID: <TMB.92Nov20135549@arolla.idiap.ch>
  7. Date: 20 Nov 92 21:55:49 GMT
  8. References: <1992Nov13.200222.23955@sal.wisc.edu> <id.OS0V.0DI@ferranti.com>
  9.     <TMB.92Nov17222432@arolla.idiap.ch> <id.MT2V.RXE@ferranti.com>
  10. Reply-To: tmb@idiap.ch
  11. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  12.     Perceptive)
  13. Lines: 76
  14. NNTP-Posting-Host: arolla.idiap.ch
  15. In-reply-to: peter@ferranti.com's message of Wed, 18 Nov 1992 20:09:18 GMT
  16.  
  17. In article <id.MT2V.RXE@ferranti.com> peter@ferranti.com (peter da silva) writes:
  18.  
  19.    In article <TMB.92Nov17222432@arolla.idiap.ch> tmb@idiap.ch writes:
  20.    > I somehow don't follow your reasoning. If _some_ FORTH implementations
  21.    > provide a particular machine specific feature, then it's "in the
  22.    > language",
  23.  
  24.    The 16*16/16 operation, "*/", is in the language definition. All Forth
  25.    implementations I ever used, back when I was using Forth extensively,
  26.    provided this operator.
  27.  
  28.    I haven't used a 32-bit Forth, but I would consider any implementation
  29.    that did not promote ALL the 16-bit operations incompetant.
  30.  
  31. So, is there a "32*32/32" operation in the FORTH standard? A
  32. "64*64/64" operation? A "128*128/128" operation?
  33.  
  34. These are machine and implementation specific features, and different
  35. languages provide access to them in different ways. On most 16bit
  36. machines, the C paradigm (*) works quite admirably, just like the
  37. FORTH paradigm does. On most 32bit (or 64bit or...), neither language
  38. has a standard paradigm for expressing this.
  39.  
  40. (*)    int x=...,y=...;
  41.     long product=x*(long)y;
  42.     int result = product/z;
  43.  
  44. Certainly the original intent of the C language seems to have been
  45. that (*) should continue to work (translating automatically into what
  46. you call "32*32/32"). Hence, had it not been for the (maybe
  47. unfortunate) decision to make "long" 32bits on 32bit workstation, C
  48. would actually be somewhat more portable in its support of the idea of
  49. word*word->double_word instructions.
  50.  
  51. For more concrete and portable support, I'd suggest standardizing the
  52. interface to an implementation-dependent include file like the
  53. following:
  54.  
  55.   /* 32bit workstation/compiler with 64bit "long long". */
  56.  
  57.   #ifdef __GCC__
  58.   typedef int big_product_arg;
  59.   #define bits_int_big_product_arg 32
  60.   typedef long long big_product_result;
  61.   #define bits_in_big_product_result 64
  62.   #define BIG_MULTIPLY(x,y) ((big_product_result)(x)*(big_product_result)(y))
  63.   #endif
  64.  
  65.   /* 32bit workstation/compiler without "long long". Note that this is less
  66.      efficient than what the machine might provide. At fault is the absence of a
  67.      64bit type to hold the result of the multiplication. */
  68.  
  69.   #ifdef __SUNC__
  70.   typedef int big_product_arg;
  71.   #define bits_int_big_product_arg 16
  72.   typedef long big_product_result;
  73.   #define bits_in_big_product_result 32
  74.   #define BIG_MULTIPLY(x,y) ((big_product_result)(x)*(big_product_result)(y))
  75.   #endif
  76.  
  77.   /* 16bit machine with 32bit long. */
  78.  
  79.   #ifdef __PDP11__
  80.   typedef int big_product_arg;
  81.   #define bits_int_big_product_arg 16
  82.   typedef long big_product_result;
  83.   #define bits_in_big_product_result 32
  84.   #define BIG_MULTIPLY(x,y) ((big_product_result)(x)*(big_product_result)(y))
  85.   #endif
  86.  
  87. You can first standardize this for yourself, then share it with other
  88. people that are trying to solve similar problems to what you are
  89. doing, and finally, if it turns out to be useful, this may become
  90. supported by compiler vendors.
  91.  
  92.                 Thomas.
  93.