Code: Select all
char MyFunction(char c) {
if (c>0x5F)
c-=32;
char c2=c;
const unsigned char *FontPtr=&Font5x8[c];
unsigned char v=*FontPtr++;
return c2*v;
}
Code: Select all
char MyFunction(char c)
{
char c2;
const unsigned char * FontPtr = &Font5x8[c];
unsigned char v;
if(c > 0x5F)
{
c -= 32;
}
c2 = c;
v = *FontPtr++;
return c2 * v;
}
Let's check what is happening if as index the variable 'c2' is used instead of 'c'. So the original code is:
Code: Select all
..
if (c>0x5F)
c-=32;
char c2=c;
const unsigned char *FontPtr=&Font5x8[c2];
..
Code: Select all
char c2;
const unsigned char * FontPtr = &Font5x8[c2];
unsigned char v;
if(c > 0x5F)
{
c -= 32;
}
c2 = c;
v = *FontPtr++;