Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site harvard.ARPA Path: utzoo!linus!vaxine!wjh12!harvard!elvy From: elvy@harvard.ARPA (Marc Elvy) Newsgroups: net.bugs.4bsd,net.unix,net.lang.c Subject: Bug in 4.[12] BSD C compiler with "asm" statement Message-ID: <314@harvard.ARPA> Date: Tue, 3-Jul-84 21:11:57 EDT Article-I.D.: harvard.314 Posted: Tue Jul 3 21:11:57 1984 Date-Received: Tue, 10-Jul-84 04:40:31 EDT Organization: Aiken Computation Lab, Harvard Lines: 52 Subject: Bug in "asm" statement in 4.X BSD C compiler Index: /lib/ccom and its neigbors Description: The "asm" statement is handled incorrectly in both the 4.1BSD and 4.2BSD C compilers. An "asm" after an "if" is placed within the range of the "if"; braces make no difference. Repeat-By: Compile the following C program. This was prepared explicitly for illustration purposes (which is why R11 is assumed), so please do not waste your time hassling me about the philosophical problems with "asm" statements. main () { register int flag = 0; if (flag == 1) flag = 0; asm ("movl $666, r11"); } The relevant portion of the assembly language produced follows. clrl r11 cmpl r11,$1 jneq L16 clrl r11 movl $666, r11 /* Here is the "asm" statement. */ L16: ret Note that the "movl" should be AFTER the label, not before. Unfortunately, I have not discovered why this is done, but I suspect that the asm statement is dumped before the if statement is completely processed. Marc Marc A. Elvy ( elvy@harvard.{arpa,uucp} ) Aiken Computation Laboratory Harvard University