home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / vms / 21979 < prev    next >
Encoding:
Internet Message Format  |  1993-01-26  |  1.7 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!agate!ucbvax!EQL.CALTECH.EDU!rankin
  2. From: rankin@EQL.CALTECH.EDU (Pat Rankin)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: VAXC divide problems (V3.2)
  5. Message-ID: <930125173835.21c0f8a0@EQL.Caltech.Edu>
  6. Date: 26 Jan 93 01:41:20 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Distribution: world
  9. Organization: The Internet
  10. Lines: 41
  11.  
  12. |>A statement in VAXC such as:
  13. |>   i = (x + 511) / 512;
  14. |>generates ten or so instructions.  Is there anyway to get it to generate:
  15. |>   ADDL3  #511,x,R0
  16. |>   DIVL3  R0,#512,i
  17.  
  18.      Then one of several posters who have refuted this...
  19.  
  20. > That's funny, when I compiled this function:
  21. >
  22. func( int x )
  23. {
  24.     int i;
  25.     i = (x + 511) / 512;
  26.     return( i );
  27. }
  28. >
  29. > VAX C V3.2-044 generated this code:
  30. >       .entry  func,^m<>
  31. >       subl2   #4,sp
  32. >       addl3   #511,4(ap),r0
  33. >       divl2   #512,r0
  34. >       ret
  35.  
  36.      Even CC/NOOPTIMIZE generates only three instructions for the
  37. division (3rd instruction updates `i' on the stack instead of using
  38. a register for it).  "Ten or so" seems to be some sort of hallucination.
  39. Even VAX C V2.2--which is many years old by now--generates the same code
  40. (once the function is changed to use "old style" argument declaration :-).
  41.  
  42. > Don't ask me why it allocated space on the stack without using it,
  43.  
  44.      That makes room for a "hidden automatic variable" at the top of the
  45. stack for use by VAXC$ESTABLISH().  The compiler just allocates that
  46. automatically--so do recent releases of GNU C--rather than attempting
  47. to determine whether VAXC$ESTABLISH is actually called.  VAXC$ESTABLISH
  48. cannot safely be used when the compiler doesn't do this; that's why it's
  49. documented as only being supported when used from VAX C.
  50.  
  51.         Pat Rankin, rankin@eql.caltech.edu
  52.  
  53.