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

89c66x 128b DATA and parameters

Hello everybody,

I've a question concerning the internal RAM of derivatives such p89c66x and passing parameters.

As far I've understood, the internal RAM has 256 bytes in 89c66x. the 128 first bytes are for stack, registers, bit registers and the functions parameters, the remaining 128 bytes are general purpose RAM.

When passing parameters in a function, the parameters space is allocated in the first 128 bytes. Each parameter of a coded function has its space allocated here.

When the application has many functions, the available space decrease dangerously !
Currently, I've only 30 bytes remaining in this segment and I've just coded the low-level and general purpose functions. This means I've still to code the application.
I'll surely have a lack of space in this segment....

Is there a way to put the space allocation of these parameters in XDATA or to tell the linker to allocate memory only when the function is called ?

Note that reducing the number of functions isn't a solution for me. My application needs really many functions in order to be well coded.

Thanks
Best regards
Stephane

Parents
  • Well, let's take an example.
    Here is a function and the associated LST file specially coded for the sample :

    #include "reg51f.h"
    #include "tdef.h"
    
    void GLCD_DisplayValue (U32 u32Value, U8 u8NumberOfIntegerDigits, U8 u8NumberOfDecimalDigits)
    {
    	xdata U8 u8Size=0; 			/* Size of the table */
    	xdata U8 au8ValueToDisplay[10];		/* String where is converted the value */
    	xdata S8 s8CharNumber=0;		/* Character number in the string */
    
    	u32Value=0;
    	u8NumberOfIntegerDigits=0;
    	u8NumberOfDecimalDigits=0;
    	u8Size=0;
    	au8ValueToDisplay[0]=0;
    	s8CharNumber=0;
    }
    
    MODULE INFORMATION:   STATIC OVERLAYABLE
       CODE SIZE        =     28    ----
       CONSTANT SIZE    =   ----    ----
       XDATA SIZE       =     12    ----
       PDATA SIZE       =   ----    ----
       DATA SIZE        =   ----       6
       IDATA SIZE       =   ----    ----
       BIT SIZE         =   ----    ----
    

    When linking, here is what I can see in the *.M51 file :
                TYPE    BASE      LENGTH    RELOCATION   SEGMENT NAME
                -----------------------------------------------------
    
                * * * * * * *   D A T A   M E M O R Y   * * * * * * *
    ...
                DATA    0037H     0006H     UNIT         ?DT?_GLCD_DISPLAYVALUE?GLCD
    ...
                * * * * * * *  X D A T A   M E M O R Y  * * * * * * *
                XDATA   02B8H     000CH     UNIT         ?XD?GLCD
    


    We can see that the 6 bytes of parameters are located in DATA segment.
    Now, when I've many functions, the DATA segment has only the allocations of the parameters. To confirm, I've moved all the variables to XDATA and now, the remaining bytes allocated in DATA are only parameters.

    And I don't know how to move these parameters somewhere else. Is it really possible ? As I've not put any variable in DATA segment, the 128 bytes are used by parameters, registers and stack. And now, there is only 30 bytes remaining !

    Is there an issue or I have not understood something ?

    Regards
    Stephane

Reply
  • Well, let's take an example.
    Here is a function and the associated LST file specially coded for the sample :

    #include "reg51f.h"
    #include "tdef.h"
    
    void GLCD_DisplayValue (U32 u32Value, U8 u8NumberOfIntegerDigits, U8 u8NumberOfDecimalDigits)
    {
    	xdata U8 u8Size=0; 			/* Size of the table */
    	xdata U8 au8ValueToDisplay[10];		/* String where is converted the value */
    	xdata S8 s8CharNumber=0;		/* Character number in the string */
    
    	u32Value=0;
    	u8NumberOfIntegerDigits=0;
    	u8NumberOfDecimalDigits=0;
    	u8Size=0;
    	au8ValueToDisplay[0]=0;
    	s8CharNumber=0;
    }
    
    MODULE INFORMATION:   STATIC OVERLAYABLE
       CODE SIZE        =     28    ----
       CONSTANT SIZE    =   ----    ----
       XDATA SIZE       =     12    ----
       PDATA SIZE       =   ----    ----
       DATA SIZE        =   ----       6
       IDATA SIZE       =   ----    ----
       BIT SIZE         =   ----    ----
    

    When linking, here is what I can see in the *.M51 file :
                TYPE    BASE      LENGTH    RELOCATION   SEGMENT NAME
                -----------------------------------------------------
    
                * * * * * * *   D A T A   M E M O R Y   * * * * * * *
    ...
                DATA    0037H     0006H     UNIT         ?DT?_GLCD_DISPLAYVALUE?GLCD
    ...
                * * * * * * *  X D A T A   M E M O R Y  * * * * * * *
                XDATA   02B8H     000CH     UNIT         ?XD?GLCD
    


    We can see that the 6 bytes of parameters are located in DATA segment.
    Now, when I've many functions, the DATA segment has only the allocations of the parameters. To confirm, I've moved all the variables to XDATA and now, the remaining bytes allocated in DATA are only parameters.

    And I don't know how to move these parameters somewhere else. Is it really possible ? As I've not put any variable in DATA segment, the 128 bytes are used by parameters, registers and stack. And now, there is only 30 bytes remaining !

    Is there an issue or I have not understood something ?

    Regards
    Stephane

Children
No data