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