[Sdcc-user] code problem

 [Sdcc-user] code problem From: Gregor Konermann - 2000-06-24 22:07:35 Attachments: Message as HTML ```Hi all! I have a problem with this code (simple ascii-string to int conversion): int String2Int(unsigned char *s) { int i=3D0; int j=3D0; int factor=3D1; while (!(s[i]=3D=3D0)) i++; i--; while (i>=3D0) // <----------------------------------- here=B4s the = problem !=20 { j=3Dj+(factor*((s[i])-0x30)); factor*=3D10; i--; // <----------------------------------------------- i is = decreased here } return (j); } when i is 0, it will be decreased to 0xff, but the loop will not = terminate. It seems as if sdcc does not recognize the signed int, so = 0xff is larger than 0 and the loop goes on. Is this a "bug" of sdcc or am I doing something wrong??? Many greetings from germany, Gregor ```

 [Sdcc-user] code problem From: Gregor Konermann - 2000-06-24 22:07:35 Attachments: Message as HTML ```Hi all! I have a problem with this code (simple ascii-string to int conversion): int String2Int(unsigned char *s) { int i=3D0; int j=3D0; int factor=3D1; while (!(s[i]=3D=3D0)) i++; i--; while (i>=3D0) // <----------------------------------- here=B4s the = problem !=20 { j=3Dj+(factor*((s[i])-0x30)); factor*=3D10; i--; // <----------------------------------------------- i is = decreased here } return (j); } when i is 0, it will be decreased to 0xff, but the loop will not = terminate. It seems as if sdcc does not recognize the signed int, so = 0xff is larger than 0 and the loop goes on. Is this a "bug" of sdcc or am I doing something wrong??? Many greetings from germany, Gregor ```
 RE: [Sdcc-user] code problem From: Sandeep Dutta - 2000-06-25 00:15:10 Attachments: Message as HTML ```Hi Gregor, There was a problem with the register allocator that caused this problem. Fixed now.... Sandeep -----Original Message----- From: sdcc-user-admin@... [mailto:sdcc-user-admin@...]On Behalf Of Gregor Konermann Sent: Saturday, June 24, 2000 3:02 PM To: sdcc-user@... Subject: [Sdcc-user] code problem Hi all! I have a problem with this code (simple ascii-string to int conversion): int String2Int(unsigned char *s) { int i=0; int j=0; int factor=1; while (!(s[i]==0)) i++; i--; while (i>=0) // <----------------------------------- here´s the problem ! { j=j+(factor*((s[i])-0x30)); factor*=10; i--; // <----------------------------------------------- i is decreased here } return (j); } when i is 0, it will be decreased to 0xff, but the loop will not terminate. It seems as if sdcc does not recognize the signed int, so 0xff is larger than 0 and the loop goes on. Is this a "bug" of sdcc or am I doing something wrong??? Many greetings from germany, Gregor ```