Article View: comp.sys.mac
Article #14390Code generation bug in MPW Pascal
From: newbery
Date: Mon, 09 Feb 1987 04:37
Date: Mon, 09 Feb 1987 04:37
36 lines
1372 bytes
1372 bytes
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)
Technical Details
Message-ID:
<12620@vuwcomp.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!husc6!seismo!munnari!vuwcomp!newberyShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!husc6!seismo!munnari!vuwcomp!newbery From: newbery@vuwcomp.UUCP Newsgroups: comp.sys.mac Subject: Code generation bug in MPW Pascal Message-ID: <12620@vuwcomp.UUCP> Date: Sun, 8-Feb-87 23:37:12 EST Article-I.D.: vuwcomp.12620 Posted: Sun Feb 8 23:37:12 1987 Date-Received: Wed, 11-Feb-87 07:34:35 EST Organization: Comp Sci, Victoria Univ., Wellington, New Zealand Lines: 36 Keywords: MPW, Pascal