Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!wuarchive!uunet!mcsun!cernvax!chx400!chx400!bernina!neptune!iiic.ethz.ch!umueller From: umueller@iiic.ethz.ch (Urban Dominik Mueller) Newsgroups: comp.sys.amiga.programmer Subject: Re: Manx 5.0d bug (-sr optimization error) Summary: Check your Manx 5.0d version Keywords: manx bug Message-ID: <25118@neptune.inf.ethz.ch> Date: 16 Feb 91 01:28:21 GMT References: <7536@jhunix.HCF.JHU.EDU> Sender: news@neptune.inf.ethz.ch Reply-To: umueller@iiic.ethz.ch (Urban Mueller) Followup-To: comp.sys.amiga.programmer Organization: Departement Informatik, ETH, Zurich Lines: 56 Recently, a Manx 5.0d bug report was posted on this net. Before I explain what happened, a short summary: ==> Make sure your Manx 5.0d compiler 'cc' is dated Sep 28 <== ( The version of 5.0d dated Sep 20 has a *nasty* bug ) The rest is only for the interested. What happens is the following: Whenever the destination an addition with a constant in it is an address register (this is why the mentioned bug only occured when -sr was turned on), Manx tries the following trick (-sr always set, but it can also happen when it's not set): Source code Correct assembler code 5.0d (both versions) -----------------------+-------------------------------------------- main() | move.l d2,a0 ; i moved to a0 { | add.l d2,a0 ; i added to a0 int i; | pea 99(a0) ; a0 + 99 pushed to stack | jsr _func ; function call func( i+i+99 ); | add.w 4,sp ; argument popping } | So far, so good. But when when one part of the addition is a pointer, this happens with Manx 5.0d Sep 20: Source code Buggy assembler code by 5.0d Sep 20 -----------------------+------------------------------------ main() | move.l d2,a0 ; i moved to a0 { | add.l a2,a0 ; p added to a0 char *p; | move.l a0,-(sp) ; result pushed, but 99 forgotten int i; | jsr _func | add.w 4,sp func( p+i+99 ); | } The 5.0d version dated Sep 28 does a nice job again (by just forgetting about that 'pea' trick in that special case): Same source code Correct assembler code by 5.0d Sep 28 -----------------------+-------------------------------------- main() | move.l d2,a0 ; i moved to a0 { | add.l a2,a0 ; p added to a0 char *p; | add.l 99,a0 ; 99 added to a0 int i; | move.l a0,-(sp) ; a0 pushed | jsr _func func( p+i+99 ); | add.w 4,sp } | Hope this helped some people. IMHO it's up to Manx to tell you bugs like this one. There are many people who can't call their BBS. At least I must say that their update service is good, I got that special update for free (hadn't even got to pay any postage). __ | Urban Mueller | / / | Urban Mueller | | USENET: umueller@iiic.ethz.ch | __ / / | Schulhausstr. 83 | | FIDONET: 2:302/906 (AUGL) | \ \/ / | CH-6312 Steinhausen | | "Don't tell my employer" | \__/ | SWITZERLAND |