ins_adjb@jhunix.HCF.JHU.EDU (Daniel Jay Barrett) (02/13/89)
I have discovered 2 bugs in Manx 3.6a. Both of these bugs
cause "cc" to generate code that "as" rejects. Enclosed are minimal
programs that exhibit these bugs. (I have enclosed a complete "shar"
file containing the programs, their assembly language output, and
very similar programs that do not exhibit the bugs. Enjoy. :-))
Does Jim Goodnow have an e-mail address where I can send this?
Anyway, the programs are very simple. In a nutshell:
/* #1: This gives the assembler error:
tst.l #.1
^
File ram:ctmpA72.888; Line 6 # Opcode operands did not match.
src=0 dst=400
*/
awful()
{
if ("any string")
exit(0);
}
/* #2: This gives the assembler error:
rol.w #-8,d0
^
File ram:ctmpA72.888; Line 8 # Opcode operands did not match.
src=1008400 dst=1
*/
typedef struct
{
unsigned index:24,
constraint:8;
} position;
foo(p)
position p;
{
char c;
c = p.constraint;
}
# This is a shell archive. Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by crabcake!barrett on Sat Feb 11 20:38:25 EST 1989
# Contents: COMPILING README rolwBug.asm rolwBug.c rolwNoBug.asm rolwNoBug.c
# tstlBug.asm tstlBug.c tstlNoBug.asm tstlNoBug.c
echo x - COMPILING
sed 's/^@//' > "COMPILING" <<'@//E*O*F COMPILING//'
tstlBug.c: Compile simply with "cc tstlBug.c".
This generates the following ASSEMBLER ERROR:
tst.l #.1
^
File ram:ctmpA72.888; Line 6 # Opcode operands did not match.
src=0 dst=400
----------------------------------------------------------------------
rolwBug.c: Compile with "cc +L rolwBug.c".
This generates the following ASSEMBLER ERROR:
rol.w #-8,d0
^
File ram:ctmpA72.888; Line 8 # Opcode operands did not match.
src=1008400 dst=1
@//E*O*F COMPILING//
chmod u=rw,g=r,o=r COMPILING
echo x - README
sed 's/^@//' > "README" <<'@//E*O*F README//'
What I have discovered
----------------------
I have discovered two bugs in the Manx 3.6a compiler. Both
of these bugs cause the compiler to generate assembly code that the
assembler rejects.
Enclosed are two sample programs that exhibit the errors.
"tstlBug.c" generates a "tst.l" instruction that the assembler dislikes,
and "rolwBug.c" generates a "rol.w" instruction that the assembler
also dislikes.
Also enclosed are:
tstlBug.asm: The assembly language produced from tstlBug.c
rolwBug.asm: The assembly language produced from rolwBug.c
tstlNoBug.c: A legal version of tstlBug.c
tstlNoBug.asm: Its assembly language output
rolwNoBug.c: A legal version of rolwBug.c
rolwNoBug.asm: Its assembly language output
To compile these programs
-------------------------
See the enclosed file "COMPILING".
What about older versions of "cc"?
----------------------------------
tstlBug.c produces the same assembler error using Manx cc
V3.4 and V3.2.
However, both V3.4 and V3.2 refuse to compile rolwBug.c,
citing errors 118 ("field is too wide" for index:24) and 120
("invalid type for field" for both index:24 and constraint:8).
Where did this code come from?
------------------------------
From the GNU Project version of "grep", "E?GREP", but cut
down massively to produce minimal programs exhibiting the bugs.
@//E*O*F README//
chmod u=rw,g=r,o=r README
echo x - rolwBug.asm
sed 's/^@//' > "rolwBug.asm" <<'@//E*O*F rolwBug.asm//'
;:ts=8
public _foo
_foo:
link a5,#.2
movem.l .3,-(sp)
lea 8(a5),a0
move.l (a0),d0
rol.w #-8,d0
and.w #255,d0
move.b d0,-1(a5)
@.4
movem.l (sp)+,.3
unlk a5
rts
@.2 equ -2
@.3 reg
public .begin
dseg
end
@//E*O*F rolwBug.asm//
chmod u=rw,g=r,o=r rolwBug.asm
echo x - rolwBug.c
sed 's/^@//' > "rolwBug.c" <<'@//E*O*F rolwBug.c//'
typedef struct
{
unsigned index:24,
constraint:8;
} position;
foo(p)
position p;
{
char c;
c = p.constraint;
}
@//E*O*F rolwBug.c//
chmod u=rw,g=r,o=r rolwBug.c
echo x - rolwNoBug.asm
sed 's/^@//' > "rolwNoBug.asm" <<'@//E*O*F rolwNoBug.asm//'
;:ts=8
public _foo
_foo:
link a5,#.2
movem.l .3,-(sp)
lea 8(a5),a0
move.l (a0),d0
and.w #255,d0
move.b d0,-1(a5)
@.4
movem.l (sp)+,.3
unlk a5
rts
@.2 equ -2
@.3 reg
public .begin
dseg
end
@//E*O*F rolwNoBug.asm//
chmod u=rw,g=r,o=r rolwNoBug.asm
echo x - rolwNoBug.c
sed 's/^@//' > "rolwNoBug.c" <<'@//E*O*F rolwNoBug.c//'
typedef struct
{
unsigned constraint:8,
index:24;
} position;
foo(p)
position p;
{
char c;
c = p.constraint;
}
@//E*O*F rolwNoBug.c//
chmod u=rw,g=r,o=r rolwNoBug.c
echo x - tstlBug.asm
sed 's/^@//' > "tstlBug.asm" <<'@//E*O*F tstlBug.asm//'
;:ts=8
public _awful
_awful:
link a5,#.2
movem.l .3,-(sp)
tst.l #.1
beq .4
clr.w -(sp)
jsr _exit
add.w #2,sp
@.4
@.5
movem.l (sp)+,.3
unlk a5
rts
@.2 equ 0
@.3 reg
@.1
dc.b 97,110,121,32,115,116,114,105,110,103,0
ds 0
public _exit
public .begin
dseg
end
@//E*O*F tstlBug.asm//
chmod u=rw,g=r,o=r tstlBug.asm
echo x - tstlBug.c
sed 's/^@//' > "tstlBug.c" <<'@//E*O*F tstlBug.c//'
awful()
{
if ("any string")
exit(0);
}
@//E*O*F tstlBug.c//
chmod u=rw,g=r,o=r tstlBug.c
echo x - tstlNoBug.asm
sed 's/^@//' > "tstlNoBug.asm" <<'@//E*O*F tstlNoBug.asm//'
;:ts=8
public _awful
_awful:
link a5,#.2
movem.l .3,-(sp)
dseg
@.4
dc.b 97
dc.b 110
dc.b 121
dc.b 32
dc.b 115
dc.b 116
dc.b 114
dc.b 105
dc.b 110
dc.b 103
dc.b 0
cseg
lea .4,a0
move.l a0,d0
beq .5
clr.w -(sp)
jsr _exit
add.w #2,sp
@.5
@.6
movem.l (sp)+,.3
unlk a5
rts
@.2 equ 0
@.3 reg
public _exit
public .begin
dseg
end
@//E*O*F tstlNoBug.asm//
chmod u=rw,g=r,o=r tstlNoBug.asm
echo x - tstlNoBug.c
sed 's/^@//' > "tstlNoBug.c" <<'@//E*O*F tstlNoBug.c//'
awful()
{
static char c[] = "any string";
if (c)
exit(0);
}
@//E*O*F tstlNoBug.c//
chmod u=rw,g=r,o=r tstlNoBug.c
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
18 55 468 COMPILING
38 182 1333 README
19 33 213 rolwBug.asm
12 18 125 rolwBug.c
18 31 199 rolwNoBug.asm
12 18 123 rolwNoBug.c
24 41 267 tstlBug.asm
5 7 42 tstlBug.c
36 63 347 tstlNoBug.asm
6 12 64 tstlNoBug.c
188 460 3181 total
!!!
wc COMPILING README rolwBug.asm rolwBug.c rolwNoBug.asm rolwNoBug.c tstlBug.asm tstlBug.c tstlNoBug.asm tstlNoBug.c | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
--
Dan Barrett ins_adjb@jhunix.UUCP UUCP
barrett@cs.jhu.edu (128.220.13.4) ARPA
Dept. of Computer Science, Johns Hopkins University, Baltimore, MD 21218