Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!orsvax1!pyrnj!caip!lll-crg!hoptoad!gnu From: gnu@hoptoad.uucp (John Gilmore) Newsgroups: net.micro.68k Subject: Re: asm construct in PCC's: workaround Message-ID: <716@hoptoad.uucp> Date: Mon, 21-Apr-86 12:20:16 EST Article-I.D.: hoptoad.716 Posted: Mon Apr 21 12:20:16 1986 Date-Received: Wed, 23-Apr-86 22:06:05 EST References: <293@Shasta.ARPA> <581@mtxinu.UUCP> Organization: Nebula Consultants in San Francisco Lines: 37 In article <581@mtxinu.UUCP>, ed@mtxinu.UUCP (Ed Gould) writes: > ...there is a bug in the 4.2BSD compiler, > and possibly other PCC derivatives as well. I don't remember the > nature of the bug in any detail, but the workaround is to place > a null statement (extra semicolon) before the asm(): > > ;asm("whatever"); The bug occurs when the asm() is preceded by an if-statement, e.g.: if (flag) do_something(); asm("now do this"); PCC injects the asm() into the output before it recognizes that the if statement is done, so the asm() is effectively placed inside the if statement. Having it scan a null statement before the asm() works. Now for a bit of soapboxing: I had to maintain a large piece of code containing asm()'s (the Sun boot proms, which developed out of code written at Stanford by Luis Trabb-Pardo and others). Eventually I gave up; there were too many dependencies on the compiler: where it allocated variables, what the peephole optimizer would accept and understand, etc. Every time Richard Tuck improved the Sun C compiler, my code would break in obscure ways. I always ended up compiling it with both compilers and diff-ing the .s files and reading the diffs. For each compiler release over 3-1/2 years. While this was a great check on the generated code and helped Richard avoid bugs, it took a lot of time. I finally rewrote all the asm() parts so the assembler code was in separate foo.s files, my life became easier, my code became more maintainable, I found a good lover, my ship came in, and my soapboxing is over. -- John Gilmore {sun,ptsfa,lll-crg,ihnp4}!hoptoad!gnu jgilmore@lll-crg.arpa Post no bills.