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

using idata

i tried to make a space but it's still said "missing ';' before '_at_'"
i wrote :
char idata nim[14] _at_ 0x00;

and is idata starting address at 0x80?
and data starting address at 0x00?

so, if i want to set an array starting at the first address of idata, is it right if i define the array as idata and starting address at 0x00?

or i should starting at 0x80?

thanks very much

sincerly,
hardian

  • I created the following program:

    char idata nim[14] _at_ 0x00;
    
    void main (void)
    {
    }
    

    And compiled it with no errors. The following listing file was generated:

    C51 COMPILER V6.10  TEST                                                                   01/26/2001 19:19:14 PAGE 1   
    
    
    C51 COMPILER V6.10, COMPILATION OF MODULE TEST
    OBJECT MODULE PLACED IN .\test.OBJ
    COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\test.c DEBUG OBJECTEXTEND CODE SYMBOLS
    
    stmt level    source
    
       1          char idata nim[14] _at_ 0x00;
       2          
       3          void main (void)
       4          {
       5   1      }
       6          
    C51 COMPILER V6.10  TEST                                                                   01/26/2001 19:19:14 PAGE 2   
    
    ASSEMBLY LISTING OF GENERATED OBJECT CODE
    
    
                 ; FUNCTION main (BEGIN)
                                               ; SOURCE LINE # 3
                                               ; SOURCE LINE # 4
                                               ; SOURCE LINE # 5
    0000 22                RET     
                 ; FUNCTION main (END)
    
    C51 COMPILER V6.10  TEST                                                                   01/26/2001 19:19:14 PAGE 3   
    
    NAME                                    CLASS   MSPACE  TYPE    OFFSET  SIZE
    ====                                    =====   ======  ====    ======  ====
    
    
    main . . . . . . . . . . . . . . . . .  PUBLIC   CODE   PROC     0000H  -----
    nim. . . . . . . . . . . . . . . . . .  PUBLIC   IDATA  ARRAY    0000H  14
    
    
    MODULE INFORMATION:   STATIC OVERLAYABLE
       CODE SIZE        =      1    ----
       CONSTANT SIZE    =   ----    ----
       XDATA SIZE       =   ----    ----
       PDATA SIZE       =   ----    ----
       DATA SIZE        =   ----    ----
       IDATA SIZE       =   ----    ----
       BIT SIZE         =   ----    ----
    END OF MODULE INFORMATION.
    
    
    C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
    

    Jon


  • The problem with the line below:

    char idata nim[14] _at_ 0x00;

    is the absolte setting to 0x00. Address 0 is the location of bank 0 registers in the 8051. You cannot use this as an absolute location.

    If you want the array to be in idata, all you need is:
    char idata nim[14];

    The linker will place this in the idata space. If you must have this array at absolute address 0x80, then:

    char idata nim[14] _at_ 0x80;

    will place the array at absolute address 80h. You should only use absolute addressing when you need to access external memory or memory mapped peripherals.

  • You should only use absolute addressing when you need to access external memory

    In general, you wouldn't need it for external memory (XDATA).

    Only use it if there's a specific reason why something has to be at a specific, fixed address location.

    otherwise, let the compiler sort out the allocation of variables in the available memory space.