From: SourceForge.net <no...@so...> - 2005-12-10 10:42:14
|
Bugs item #1376320, was opened at 2005-12-08 15:27 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1376320&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: msc51(8051) target Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: sign error in datatype long Initial Comment: Hi, We have found a serious bug when using 32-bit signed values for the 8051 target. We have attached a code-snippet that can reproduce the problem. When using SDCC the compiler treats the signed value as unsigned. The code-snippet that we have attached works when compiled with KEIL, but not in SDCC. We are using a Nordic VLSI nRF24E1 board. We have been using SDCC 2.5.0 #1020 (Aug 16 2005), on a Gentoo-box. we have compiled the c-program with the command "sdcc -mmcs51 signed.c -o signed.hex" There is no error-message, it just produces wrong code. Kind Regards, Sidsel Jensen (pu...@di...) & Anders Egeskov (eg...@di...) ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2005-12-10 11:42 Message: Logged In: YES user_id=888171 Allthough sfr definition is different, that is not the issue. The real problem is that SDCC reduces the if statement to P0 = 0x00. And it happens for short int too, only not for char. ---------------------------------------------------------------------- Comment By: Jesus Calvino-Fraga (jesusc) Date: 2005-12-10 09:31 Message: Logged In: YES user_id=603650 Definition of special function registers in Keil and sdcc is different. Please try again using the right syntax for sdcc (section 3.4.1.7 of the user manual): sfr at 0x80 P0; sfr at 0x94 P0_DIR; Jesus ---------------------------------------------------------------------- Comment By: Sidsel Jensen (purplehex) Date: 2005-12-09 23:48 Message: Logged In: YES user_id=1401112 here is the code-snippet that wasn't uploaded: sfr P0 = 0x80; sfr P0_DIR = 0x94; void main(void) { signed long dat; unsigned long comp; P0_DIR = 0x00; dat = 3; comp = 5; dat -= comp; if(dat<0) P0 = 0xFF; else P0 = 0x00; } /Sidsel ---------------------------------------------------------------------- Comment By: Bernhard Held (bernhardheld) Date: 2005-12-08 15:40 Message: Logged In: YES user_id=203539 There's no attachment! You can't attach anything unless you're logged in to SF. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=1376320&group_id=599 |