Bug in 4.[12] BSD C compiler with "asm" statement

Marc Elvy elvy at harvard.ARPA
Wed Jul 4 11:11:57 AEST 1984


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 at harvard.{arpa,uucp} )
			     Aiken Computation Laboratory
				  Harvard University



More information about the Comp.bugs.4bsd.ucb-fixes mailing list