Sonsivri

Electronics => Pic C Languages => Topic started by: devetka on February 07, 2022, 06:03:38 06:03



Title: ccs picc pcwhd compiler confusion
Post by: devetka on February 07, 2022, 06:03:38 06:03
Code:
[code]having some weird questions about how this compiler works .. I noticed some time ago it is mostly case insensitive (weird for C) but some other stuff is weirder ..

how does this work ?!

lcd_putc(char c) takes single char as parameter.
it handles the single char only ..

[code]
void lcd_putc(char c)
{
   switch (c)
   {
      case '\a'   :  lcd_gotoxy(1,1);     break;

      case '\f'   :  lcd_send_byte(0,1);
                     delay_ms(2);
                    #if defined(LCD_EXTENDED_NEWLINE)
                     g_LcdX = 0;
                     g_LcdY = 0;
                    #endif
                     break;

     #if defined(LCD_EXTENDED_NEWLINE)
      case '\r'   :  lcd_gotoxy(1, g_LcdY+1);   break;
      case '\n'   :
         while (g_LcdX++ < LCD_LINE_LENGTH)
         {
            lcd_send_byte(1, ' ');
         }
         lcd_gotoxy(1, g_LcdY+2);
         break;
     #else
      case '\n'   : lcd_gotoxy(1,2);        break;
     #endif
    
      case '\b'   : lcd_send_byte(0,0x10);  break;
    
     #if defined(LCD_EXTENDED_NEWLINE)
      default     :
         if (g_LcdX < LCD_LINE_LENGTH)
         {
            lcd_send_byte(1, c);
            g_LcdX++;
         }
         break;
     #else
      default     : lcd_send_byte(1,c);     break;
     #endif
   }
}

but then I call it with char * parameter and it works ?!?!?

Code:
 lcd_putc("\fline1\nline2");

?!

where is the lcd_putc(char *) defined... I assume there is somewhere lcd_putc(char *) that calls lcd_putc(char) for each char in lcd_putc but I can not find it anywhere?![/code][/code]


Title: Re: ccs picc pcwhd compiler confusion
Post by: Manuel on February 07, 2022, 09:31:21 09:31
Helpful ? : https://www.ccsinfo.com/forum/viewtopic.php?t=36234

Dig More, maybe can find into CCS manual..

Take care,
X!


Title: Re: ccs picc pcwhd compiler confusion
Post by: gan_canny on February 07, 2022, 02:46:13 14:46
As best as I remember CCS has a unique way of passing a collection of chars ( aka string). It has an inbuilt special function that sends a single char and repeats calls to that special function until all the chars are passed. The compiler spots the passing of more than a single char and replaces it with multiple single char actions.


Title: Re: ccs picc pcwhd compiler confusion
Post by: devetka on February 08, 2022, 06:53:34 18:53
@manuel, awesome, I was not the only one baffled by this :D

@gan_canny looks like that ...

I went through listing and lcd_putc(char) and lcd_putc(rom char *) are def on different addresses and lcd_putc(rom char*) I disassembled and it calls lcd_putc(char) ... but I failed to find anything about it in the documentation other than that lcd_putc(constant string) works...