#2 V220a atoi() does not work anymore

closed-postponed
Johan Knol
5
2013-05-25
2000-03-28
Michael Schmitt
No

the following code works with V219Ga but does not with the current release.

xdata unsigned char KeyBuffer[8];

unsigned int Translate()
{
unsigned int temps;

LastKeyPressed = getchar();
KeyBuffer[ 0 ] = LastKeyPressed;
putchar( LastKeyPressed );

LastKeyPressed = getchar();
KeyBuffer[ 1 ] = LastKeyPressed;
putchar( LastKeyPressed );

LastKeyPressed = getchar();
KeyBuffer[ 2 ] = LastKeyPressed;
putchar( LastKeyPressed );

LastKeyPressed = getchar();
KeyBuffer[ 3 ] = LastKeyPressed;
putchar( LastKeyPressed );

LastKeyPressed = getchar();
KeyBuffer[ 4 ] = LastKeyPressed;
putchar( LastKeyPressed );

KeyBuffer[ 5 ] = 0x00;

putchar(' ');
putchar(KeyBuffer[0]);
putchar(KeyBuffer[1]);
putchar(KeyBuffer[2]);
putchar(KeyBuffer[3]);
putchar(KeyBuffer[4]);

temps= atoi( &KeyBuffer[0] ); // <- atoi()

printf(" %d",temps);
return (temps);
// return atoi( &KeyBuffer[0] );
}

with V219Ga the output is
24555 24555 24555
with V220a i get
24555 24555 2555

so KeyBuffer[] holds to correct value, but atoi () does not convert correct.

Michael

Discussion

  • Sandeep Dutta
    Sandeep Dutta
    2000-03-30

    • assigned_to: nobody --> sandeep
     
  • Without a modification of the code above, but with some modification of the rest of the sources (outside the function), this function works in V220a.

    so atoi() seems to work, but it is unclear to me why it did not work when i posted this message.

    assume this bug to be closed.

     
  • Mehmet Kendi
    Mehmet Kendi
    2000-04-05

    It seem, that SDCC has problem with pointers, pointing
    into XDATA region.
    I \"solved\" a similar problem with the volatile qualifier.

     
  • Johan Knol
    Johan Knol
    2001-03-27

    • assigned_to: sandeep --> johanknol
     
  • Johan Knol
    Johan Knol
    2001-03-27

    Logged In: YES
    user_id=63512

    Can you confirm this still exists in 2.2.2pre?

     
  • Johan Knol
    Johan Knol
    2001-04-07

    • milestone: 100100 --> unreproducable
    • status: open --> closed-postponed