home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19957 < prev    next >
Encoding:
Text File  |  1992-12-17  |  2.6 KB  |  68 lines

  1. Path: sparky!uunet!gossip.pyramid.com!olivea!spool.mu.edu!agate!apple!mumbo.apple.com!gallant.apple.com!wintermute.apple.com!user
  2. From: ksand@apple.com (Kent Sandvik )
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Anyone else seen this MPW C bug?
  5. Message-ID: <ksand-161292233609@wintermute.apple.com>
  6. Date: 17 Dec 92 07:39:19 GMT
  7. References: <1992Dec17.024634.5959@netcom.com>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.programmer
  10. Distribution: na
  11. Organization: (Evil Eye Creature from Mars, Inc.)
  12. Lines: 54
  13.  
  14. In article <1992Dec17.024634.5959@netcom.com>, ray@netcom.com (Ray Fischer)
  15. wrote:
  16. > I just came across an incredibly blatant MPW C bug, and I'm having a
  17. > hard time believing that it hasn't been fixed yet.  Briefly, if you
  18. > multiply a long integer by constant 12 with the mc68020 option on, the
  19. > MPW compiler generates the wrong code!  
  20. > This is with MPW C 3.2; if there is a newer version that fixes the problem
  21. > that I haven't heard about, I'd really appreciate someone letting me
  22. > know about it.
  23. > If you want to try it yourself, here's a sample program.
  24. > Use the mc68020 option.
  25. > main() {
  26. >   long a,b;
  27. >   a = 3000;
  28. >   b = a * 12;
  29. >   return b;
  30. > }
  31. > The compiler generates an LEA to multiply by 3 (which is good) but
  32. > then uses an ASL.W to multiply by 4 (instead of ASL.L)!
  33.  
  34. This output is from the MPW 3.2.4 C compiler (latest ETO CD),
  35. the -mc68020 flag enabled:
  36.  
  37. 00000000: 4E56 0000      'NV..'            LINK       A6,#$0000
  38. 00000004: 48E7 0300      'H...'            MOVEM.L    D6/D7,-(A7)
  39. 00000008: 2C3C 0000 0BB8 ',<....'          MOVE.L     #$00000BB8,D6
  40. 0000000E: 2206           '".'              MOVE.L     D6,D1
  41. 00000010: 2041           ' A'              MOVEA.L    D1,A0
  42. 00000012: 41F0 8A00      'A...'            LEA        $00(A0,A0.L*2),A0
  43. 00000016: 2208           '".'              MOVE.L     A0,D1
  44. 00000018: E581           '..'              ASL.L      #$2,D1
  45. 0000001A: 2E01           '..'              MOVE.L     D1,D7
  46. 0000001C: 2007           ' .'              MOVE.L     D7,D0
  47. 0000001E: 4CEE 00C0 FFF8 'L.....'          MOVEM.L    -$0008(A6),D6/D7
  48. 00000024: 4E5E           'N^'              UNLK       A6
  49. 00000026: 4E75           'Nu'              RTS        
  50. 00000028: 846D 6169      '.mai'            OR.W       $6169(A5),D2
  51. 0000002C: 6E00 0000      'n...'            BGT        *+$0002             ;
  52. 0000002E
  53.  
  54. As you see, the compiler is now generating .L instructions.
  55.  
  56. Cheers,
  57. Kent
  58.  
  59. -------------------
  60. Kent Sandvik (UUCP: ....!apple!ksand; INTERNET: ksand@apple.com)
  61. DISCLAIMER: Private activities on the Net.        
  62. "Don't just do something!  Stand there!"  -- Mystery Science Theater 3000
  63.