[comp.sys.mac] Code generation bug in MPW Pascal

newbery@vuwcomp.UUCP (02/09/87)

MPW Pascal can generate bad code when widening a signedByte to a char. Consider
the following code fragment.
----------------------------------------------------------------------
VAR
	p	: Ptr;

PROCEDURE test(ch:CHAR);
BEGIN
{$R+ }
	ch := CHR(ORD(ch) MOD 128);	{--- this statement will fail with a CHECK ERROR ---}
	.
	.
END;

BEGIN
	.
	.
	p^ := $FF;
	.
	.
	test(CHAR(p^));
------------------------------------------------------------------------


MPW Pascal generates an EXT.W to widen the signedByte to a Word
(CHAR is word aligned),
thus $FF becomes $FFFF instead of $00FF and test falls over with a CHECK ERROR.

This may or may not be of interest to someone :-)

-- 
Michael Newbery

ACSnet:	newbery@vuwcomp.nz  UUCP: {ubc-vision,alberta}!calgary!vuwcomp!newbery
Une boule qui roule tue les poules.		(Landslides kill chickens)