Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 03, 2024, 04:47:08 16:47


Login with username, password and session length


Pages: [1]
Print
Author Topic: ccs picc pcwhd compiler confusion  (Read 4932 times)
0 Members and 1 Guest are viewing this topic.
devetka
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 6
-Receive: 131


« 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]
Logged
Manuel
Senior Member
****
Offline Offline

Posts: 329

Thank You
-Given: 680
-Receive: 192


« Reply #1 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!
« Last Edit: February 07, 2022, 09:33:34 09:33 by Manuel » Logged

-> An Apple a Day does not Let U become a Macintosh!
gan_canny
Junior Member
**
Offline Offline

Posts: 89

Thank You
-Given: 101
-Receive: 26


« Reply #2 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.
Logged
devetka
Newbie
*
Offline Offline

Posts: 29

Thank You
-Given: 6
-Receive: 131


« Reply #3 on: February 08, 2022, 06:53:34 18:53 »

@manuel, awesome, I was not the only one baffled by this Cheesy

@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...

Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC