[net.bugs.4bsd] Pascal compiler generates unassemblable code

chris@umcp-cs.UUCP (Chris Torek) (11/24/84)

Index: ucb/pascal/src/pccaseop.c 4.2BSD Fix

Description:
	The Pascal compiler generates case instructions "by hand"
	when given the -J option.  However, in doing so, it emits
	"blssu" instructions for out-of-range entries; sometimes
	the destination label of this branch is too far away for
	the Vax (the branch must be a byte displacement from the
	current PC).  Normally, the compiler uses "jxxx" instructions,
	which the assembler expands as necessary; but here, someone
	goofed.

Repeat-By:
	Compile an enourmous Pascal program using -J.  In particular,
	try compiling TeX after installing the "others" case clause.

Fix:
	Emit "jlssu" instead of "blssu".  Another alternative would
	be to rearrange things so that the "case range error" code
	lies right after the "jmp" instruction used to branch to
	one of the in-range statements; however, this would require
	much more work, so guess which one I did?

	Here's a context diff, even though there's only ONE "blssu"
	in the entire ucb/pascal/src directory...

RCS file: RCS/pccaseop.c,v
retrieving revision 1.2
diff -b -c -r1.2 pccaseop.c
*** /tmp/,RCSt1002891	Fri Nov 23 23:38:42 1984
--- pccaseop.c	Fri Nov 23 23:37:44 1984
***************
*** 286,292
  	    putprintf("	subl2	$%d,%s", 0, ctab[1].cconst, FORCENAME);
  	    putprintf("	cmpl	$%d,%s", 0,
  		    ctab[count].cconst - ctab[1].cconst, FORCENAME);
! 	    putprintf("	blssu	%s%d", 0, LABELPREFIX, ctab[0].clabel);
  	    putprintf("	ashl	$2,%s,%s", 0, FORCENAME, FORCENAME);
  	    putprintf("	jmp	*%s%d(%s)", 0,
  		    LABELPREFIX, fromlabel, FORCENAME);

--- 286,292 -----
  	    putprintf("	subl2	$%d,%s", 0, ctab[1].cconst, FORCENAME);
  	    putprintf("	cmpl	$%d,%s", 0,
  		    ctab[count].cconst - ctab[1].cconst, FORCENAME);
! 	    putprintf("	jlssu	%s%d", 0, LABELPREFIX, ctab[0].clabel);
  	    putprintf("	ashl	$2,%s,%s", 0, FORCENAME, FORCENAME);
  	    putprintf("	jmp	*%s%d(%s)", 0,
  		    LABELPREFIX, fromlabel, FORCENAME);
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland