From: sandmann AT clio DOT rice DOT edu (Charles Sandmann) Message-Id: <9606052140.AA12180@clio.rice.edu> Subject: bugs (fwd) To: djgpp-workers AT delorie DOT com Date: Wed, 5 Jun 1996 16:40:19 -0600 (CDT) Content-Type: text Content-Length: 2492 I didn't look at this in any detail, just FYI. Forwarded message: > From: Matthias Grimrath > Date: Wed, 5 Jun 1996 19:06:08 +0100 (MESZ) > > ------- Bugs in the C Compiler ------- > // Two bugs are in here: > // 1.) CC1 always extends a value in a register to a long, even > // if it is not necessary. In (3), c needs to be zero extend > // from a byte to a short, but CC1 produces a 'andl $255,%eax'. > // 'subb %ah,%ah' would be enough. > // > // 2.) Obviously CC1 is unware about the fact, that the > // 'call/jmp' instructions can be used with a > // memory operand. A 'call [dword ptr address]' (Intel syntax) > // can be written in AT&T syntax as 'call address(,1)' > // > // compile with gcc -S -O3 and look how (3) and (4) are compiled > #include > > long test(unsigned char b, unsigned short c, long d, char *s, int num) > __attribute__ (( regparm(3) )); > > unsigned short jaja; > > long test(unsigned char a, unsigned short c, long d, char *s, int num) > { > jaja = c + a; // (3) > return d; > } > > long (*procptr)(unsigned char b, unsigned short c, long d, char *s, int num) > __attribute__ (( regparm(3) )) = test; > > int main(void) > { > procptr(2, 1, 3, "You see\n", 0); // (4) > cprintf("don't you?\n"); > } > > > ------------ Bugs in as ----------- > A line like > movw +0x8(%ebp),%ax > doesn't assemble. Why is a '+' prefix not allowed? > > gas doesn't decides on the phase of the moon whether or > not to ignore segment prefixes. It ignores it only for > reg/mem or mem/reg operands, where reg is 'eax' and mem is > an absolute address. > > gas also ignores segment prefixes for the string instructions. > > I once downloaded the sources for gas and found that gas ignores > segment prefixes only for those instructions which have a > memory address but not an r/m field in the instruction pattern. > Gas checks for the presence of this field whether this instruction > can have a prefix or not. > > To work around, you may also type the segment registers as > instructions, e.g. 'fs; mov (%ebx),%ax' instead of typing > '.byte XX; ...' > > ---------------- Other bugs ----------- > the LIMITS.H include file doesn't check for signed or unsigned > characters! > > ---------------- Bugs in FSDB ---------- > lgs lkjkl,%eax not printed > > ret xxx - xxx should be a number but really is junk > > segment overrides for string instructions are not shown. > > 'lcall' is disassembled as 'call'