Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!csd4.milw.wisc.edu!indri!eta!nic.MR.NET!umn-d-ub!umn-cs!mmm!manning From: manning@mmm.UUCP (Arthur T. Manning) Newsgroups: comp.os.os9 Subject: C compiler 3.0 BUG with inline assembly! Summary: semicolons DO have a purpose all by themselves Keywords: #asm, #endasm, crackerjack_compiler Message-ID: <1248@mmm.UUCP> Date: 6 Apr 89 03:44:35 GMT Reply-To: manning@mmm.UUCP (Arthur T. Manning) Followup-To: flame Microware for not telling you about this Distribution: usa Organization: 3M Engineering Systems & Technology Lab, St. Paul MN Lines: 38 In the following code, the compiler concatenates the two SEPERATE sections of assembly together as though they were all inside the if statement's scope. In the second case (with only a semicolon added) the compiler does what it is expected to do. Apparently "}" is not enough for the compiler to know that the if{} has ended and to put the rest of the assembly code outside the scope. Would you believe we found this bug in an interrupt service routine? We would never have found it without our VMETRO vme bus debugger. if(foo) { #asm move.l a1,a2 #endasm } /* end of if's scope, right? */ /* Wrong! The compiler doesn't think so, and puts these together. */ #asm move.l a2,a3 #endasm if(foo) { #asm move.l a1,a2 #endasm } ; /* REALLY the end of if's scope */ /* the compiler knows now that the semicolon is there... */ #asm move.l a2,a3 #endasm -- Arthur T. Manning Phone: 612-733-4401 3M Center 518-1 FAX: 612-736-3122 St. Paul MN 55144-1000 U.S.A. Email: manning@mmm.uucp