This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

extern type in 'C' and PUBLIC type in asm mismatch

Anyone seen this one?

I have a data structure in assembly (bit-mapped font) that I want to reference in C.

The 'C' code looks like this:

extern code unsigned char *FONT1;

and the assembly looks like this:
NAME FONT1
?CO?FONT1 SEGMENT CODE
PUBLIC FONT1
RSEG ?CO?FONT1
FONT1:

...

END

the linker error message is this:

***ERROR L103: EXTERNAL ATTRIBUT DO NOT MATCH PUBLIC SYMBOL: FONT1

the only other real clue I have is what's generated when I compile my "LCD" module with the "SRC" option. Here's a snip of that:

?PR?lcd_init?LCD SEGMENT CODE
?PR?_lcd_wr_image?LCD SEGMENT CODE
?DT?_lcd_wr_image?LCD SEGMENT DATA OVERLAYABLE
?PR?lcd_clr?LCD SEGMENT CODE
?PR?_lcd_wr_char?LCD SEGMENT CODE
?DT?_lcd_wr_char?LCD SEGMENT DATA OVERLAYABLE
?PR?_lcd_wr_string?LCD SEGMENT CODE
?DT?_lcd_wr_string?LCD SEGMENT DATA OVERLAYABLE
?PR?_lcd_set_line?LCD SEGMENT CODE
?PR?lcd_status?LCD SEGMENT CODE
?PR?lcd_title?LCD SEGMENT CODE
?CO?LCD SEGMENT CODE
EXTRN CODE (FONT1)
EXTRN CODE (?C?CLDPTR)
PUBLIC LCD_DATA
PUBLIC LCD_CMD
PUBLIC lcd_title
PUBLIC lcd_status
PUBLIC _lcd_set_line
PUBLIC ?_lcd_wr_string?BYTE
PUBLIC _lcd_wr_string
PUBLIC _lcd_wr_char
PUBLIC lcd_clr
PUBLIC _lcd_wr_image
PUBLIC lcd_init

Notice that the FONT1 extern reference does not include the code segment prefix, but seems to be associated with the ?CO? segment of the local module locally...hmmm... maybe that's OK...

Anyway, thanks for any input!

-ai

  • What happens when you try this?

    extern code unsigned char FONT1 [];

    Jon

  • same problem... I've tried several different types in the 'C' code.

    thanks!

  • Is there any problem with "FONT1" being a module name, a segment name, and an address name all at the same time?

  • I just tried the following simple program and it works great.

    FONT1.A51

    NAME	FONT1
    
    ?CO?FONT1            SEGMENT CODE
    	PUBLIC	FONT1
    
    	RSEG  ?CO?FONT1
    FONT1:
    	DB  'K' ,'e' ,'i' ,'l' ,' ' ,'S' ,'o' ,'f' ,'t' ,'w'
    	DB  'a' ,'r' ,'e' ,000H
    
    	END


    MAIN.C
    #include <reg51.h>
    #include <stdio.h>
    
    extern unsigned char code font1[];
    
    void main (void)
    {
        SCON  = 0x50;   /* SCON: mode 1, 8-bit UART, enable rcvr      */
        TMOD |= 0x20;   /* TMOD: timer 1, mode 2, 8-bit reload        */
        TH1   = 221;    /* TH1:  reload value for 1200 baud @ 16MHz   */
        TR1   = 1;      /* TR1:  timer 1 run                          */
        TI    = 1;      /* TI:   set TI to send first char of UART    */
    
    while (1)
      {
      printf ("%s\n", font1);
      }
    }

    I'm compiling and linking in uVision2 with default compiler, assembler, and linker options. When run in the simulator, the serial window displays the name of my favorite software company! :-)

    Jon

  • Jon,

    The only real difference I see in what you have and what I have is the position of the "code" keyword in the 'C' extern statement.

    I'm not at work right now, so I can't check it out...do you think this is my problem?

    thanks a bunch!

    -alex

  • SO...

    It turns out that the issue had to do with a bad install of either or both the Keil SW and the Cygnal IDE. I reinstalled both and now its all happy.

    thanks,

    ai

  • The only real difference I see in what you have and what I have is the position of the "code" keyword in the 'C' extern statement.

    The postition of the code keyword is all important.

    In this case:

    extern code unsigned char *FONT1;
    
    FONT1 is a pointer that is stored in code memory.

    Whereas, in this case:
    extern unsigned char code font1[];
    
    font1 is a pointer to code space.