home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 13029 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  2.2 KB

  1. Path: sparky!uunet!psinntp!cubetech.com!imladris!moebius!peterc
  2. From: peterc@cubetech.com (Peter Creath)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: A few more suggestions for THINK C
  5. Date: Fri, 24 Jul 92 20:42:21 CDT
  6. Organization: Cube Technologies
  7. Message-ID: <dx3uv972.9c6tdb@moebius.cubetech.com>
  8. Reply-To: peterc@cubetech.com
  9. Distribution: comp
  10.             
  11. Lines: 60
  12.  
  13.  
  14. In article <SRO.92Jul21221949@media-lab.media.mit.edu> (comp.sys.mac.programmer), sro@media.mit.edu (Shawn O'Donnell) writes:
  15. > Pardon my ignorance if THINK C already has such a function.  Better
  16. > tell me now what it is.  
  17.  
  18. I take this disclaimer too!  Does Think C automatically exclude functions
  19. which are not called when linking the final object?  (Please tell
  20. me it does -- why have a 27k ANSI library when you just want sprintf()?)
  21.  
  22. Enough of that.  I know it doesn't currently label variables
  23. during disassembly (this would be a BIG plus...I suppose you'd have
  24. to use things like "offsetof(theStruct, element)", and if you're on
  25. that track, howzabout "sizeof(theStruct)" when doing struct calculations?
  26.  
  27. Also, how about having the compiler keep track of which variable/pointer
  28. is in which register?  I've seen generated code do this:
  29.  
  30. lea        myVariable,A0
  31. move.w    #0x04,D0
  32. muls.w    #0x0304,D0
  33. add.w    D0,A0
  34. move.l    (A0),D1
  35. lea        myVariable,A0    /* note the redundance -- the correct address */
  36. move.w    #0x04,D0        /* is already in A0 */
  37. muls.w    #0x0304,D0
  38. add.w    D0,A0
  39. move.l    0x04(A0),D1
  40. lea        myVariable,A0
  41. move.w    #0x04,D0
  42. muls.w    #0x0304,D0
  43. add.w    D0,A0
  44. move.l    0x08(A0),D1
  45.  
  46. Which could be optimized to:
  47. lea        myVariable,A0
  48. move.w    #0x04,D0
  49. muls.w    #0x0304,D0
  50. add.w    D0,A0
  51. move.l    (A0),D1
  52. move.l    0x04(A0),D1
  53. move.l    0x08(A0),D1
  54.  
  55. or even:
  56. lea        myVariable,A0
  57. move.w    #0x04,D0
  58. muls.w    #0x0304,D0
  59. add.w    D0,A0
  60. move.l    (A0)+,D1
  61. move.l    (A0)+,D1
  62. move.l    (A0)+,D1
  63.  
  64. This usually occurs when using lots of struct elements...(particularly
  65. arrays of structs)...
  66.  
  67. (and how about "DBF" command support during loop optimization?)
  68.  
  69. ----------------------------------------------------------------------------
  70. Peter Creath                 "When I was a boy I was told that anybody could
  71. peterc@cubetech.com           become president; I'm beginning to believe it."
  72.                                                            -- Clarence Darrow
  73.