From: SourceForge.net <no...@so...> - 2010-08-23 20:26:43
|
Bugs item #2944399, was opened at 2010-02-02 06:39 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2944399&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: mcs51(8051) target >Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: dfulab (dfulab) >Assigned to: Maarten Brock (maartenbrock) Summary: short or truncated to 8-bit Initial Comment: Compiler Version: SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.1 #5471 (Jul 2 2009) (MINGW32) SDCCCFLAGS = -mmcs51 --model-small Short source code that shows the "bug": ----------------------------------------------------------- unsigned short Addr1(void) { return (0x1234); } void func16(unsigned short Dummy) { Dummy; } void Test(void) { unsigned short a, b; a = 0x01 | Addr1(); func16(a); b = Addr1(); b |= 0x01; func16(b); } "a" and "b" logically should have the same results that is passed into their func16( ) call. In reality, a has been truncated and wrong values passed while b has been treated correctly as full 16-bit "or". 133 _Test: 134 ; test.c:14: a = 0x01 | Addr1(); 135 lcall _Addr1 136 mov b,dpl 137 mov a,#0x01 138 orl a,b 139 mov dpl,a 140 mov dph,b ; Problem is right here!!! b has the lower 8-bit value and it over-written the call parameter to func16(unsigned short)! 141 ; test.c:15: func16(a); 142 lcall _func16 Contrast this with the code for b 143 ; test.c:17: b = Addr1(); 144 lcall _Addr1 145 mov r2,dpl 146 mov r3,dph 147 ; test.c:18: b |= 0x01; 148 orl ar2,#0x01 149 ; test.c:19: func16(b); 150 mov dpl,r2 151 mov dph,r3 ; The upper 8-bit has been preserved correctly 152 ljmp _func16 ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2010-08-23 22:26 Message: Fixed in SDCC 2.9.7 #5944. ---------------------------------------------------------------------- Comment By: Philipp Krause (spth) Date: 2010-05-21 15:14 Message: Looks like this really is a mcs51 bug. The Z80 port generates correct code for both a and b. Philipp ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2944399&group_id=599 |