From: SourceForge.net <no...@so...> - 2003-01-04 15:01:25
|
Bugs item #542397, was opened at 2002-04-11 10:36 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=542397&group_id=599 Category: msc51(8051) target >Group: fixed >Status: Closed Resolution: Fixed Priority: 5 Submitted By: Nobody/Anonymous (nobody) >Assigned to: Bernhard Held (bernhardheld) Summary: Compiler produces bad 'add a,a'. Initial Comment: Hello! When compiling the file src.c with the following contents, is can not be assembled, because the compiler produced the forbidden instruction "add a,a" (instead of "add a,acc"). The assembler says: ?ASxxxx-Error-<a> in line 287 of src.asm <a> machine specific addressing or addressing mode error removing src.rel Is is also interesting, that the asm code produced by the compiler also contains a valid instruction "add a,acc" just a few lines above the "add a,a"! src.c: #include <at89s8252.h> char foo(char x_byte) { SBUF= x_byte; while (!TI); TI= 0; return(x_byte); } void main(void) { foo('0'+TI*2+RI); } Compiler is SDCC V2.3.0, Windows binaries. Attached files (in ZIP) are: src.c and src.asm Greetings, Patrick Gehriger ---------------------------------------------------------------------- >Comment By: Bernhard Held (bernhardheld) Date: 2003-01-04 10:50 Message: Logged In: YES user_id=203539 Fixed by Wim in 2.3.2 ---------------------------------------------------------------------- Comment By: Wim Lewis (wiml) Date: 2002-09-19 02:40 Message: Logged In: YES user_id=110010 I went through the 8051 register allocator & code generator the other day and found where this was happening. I've committed the change to CVS. ---------------------------------------------------------------------- Comment By: Wim Lewis (wiml) Date: 2002-09-14 09:07 Message: Logged In: YES user_id=110010 Fixing sdcc to generate syntactically valid assembly for this is easy (I will submit a patch). However, this unmasks a deeper problem; the assembly output is incorrect and passes the wrong value to foo(). The problem is the expression ('0'+TI*2+RI) when TI and RI are sbit variables. The aopGet(AOP_CRY) emits some code which puts the value of the bit register into the accumulator. However, the register allocator doesn't seem to know that this will happen, and has stored an intermediate result in the accumulator as well. The intermediate result gets clobbered by the value fetched from RI. I don't think I understand sdcc's register allocator well enough to fix this. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=542397&group_id=599 |