Hello, I write code C using C51 for DP8051 (of DCD). I start to experience problem with the too small 256-bytes internal memory. It seems that when adding an automatic idata variables (function-internal) even to functions that are never called, the number of bytes used in the idata memory grows. I have read some information about the fact that the compiler will not use stack, and instead will choose which variables it can overlay on the same memory locations. I still think that if a function is never called then another parameter in it should not change the number of idata bytes used. I have also found that adding automatic idata variables to some functions will change the number of used idata bytes (after compile and build) while adding the same variable to another function may not change the used idata bytes after compilation. this is expected, but still is like a mist to me, since I don't have the knoledge that will help me to get the best out of the comiler. The following code demonstrates what I saw:
static void Cmd_parser_write (UINT8 DPP_megablock, UINT16 write_addr, UINT8 write_value) { UINT8 idata DPP_save_val = DPP; // UINT8 idata temp_memcheck0;// ### remove this comment // UINT8 idata temp_memcheck1;// ### remove this comment DPP = DPP_megablock; XBYTE[write_addr] = write_value; DPP = DPP_save_val; } /* end of Cmd_parser_write */ static void Cmd_parser_read (UINT8 DPP_megablock, UINT16 read_addr, UINT8 DPP_storage, UINT16 storage_addr) { UINT8 idata DPP_save_val = DPP; UINT8 idata data_read; // UINT8 idata temp_memcheck0;// ### remove this comment // UINT8 idata temp_memcheck1;// ### remove this comment DPP = DPP_megablock; data_read = XBYTE[read_addr]; DPP = DPP_storage; XBYTE[storage_addr] = data_read; DPP = DPP_save_val; } /* end of Cmd_parser_read */
TYPE BASE LENGTH RELOCATION SEGMENT NAME ----------------------------------------------------- * * * * * * * D A T A M E M O R Y * * * * * * * REG 0000H 0008H ABSOLUTE "REG BANK 0" REG 0008H 0008H ABSOLUTE "REG BANK 1" REG 0010H 0008H ABSOLUTE "REG BANK 2" DATA 0018H 0008H UNIT ?DT?C2C_IF_DRIVER BIT 0020H.0 0001H.1 UNIT _BIT_GROUP_ BIT 0021H.1 0000H.3 UNIT ?BI?PCC_GLOBALS BIT 0021H.4 0000H.1 UNIT ?BI?_PCC_TIMER_1_WAIT?PCC_SERVICE_ROUTINES BIT 0021H.5 0000H.1 UNIT ?BI?PCC_UART_DRIVER BIT 0021H.6 0000H.1 UNIT ?BI?LOG?LOG 0021H.7 0000H.1 *** GAP *** DATA 0022H 002CH UNIT _DATA_GROUP_ DATA 004EH 0008H UNIT ?DT?_FLOOR?FLOOR DATA 0056H 0004H UNIT ?DT?_PCC_TIMER_1_WAIT?PCC_SERVICE_ROUTINES DATA 005AH 0004H UNIT ?DT?LOG?LOG DATA 005EH 0001H UNIT ?DT?PCC_GLOBALS DATA 005FH 0001H UNIT ?DT?_CMD_PARSER_CALC_TX_GAINS?PCC_CMD_PARSER IDATA 0060H 0049H UNIT _IDATA_GROUP_ IDATA 00A9H 0011H UNIT ?ID?_CMD_PARSER_CALC_TX_GAINS?PCC_CMD_PARSER IDATA 00BAH 0004H UNIT ?ID?MPC_PCC_IF_DRIVER IDATA 00BEH 0002H UNIT ?ID?UART_COM_GETCHAR?PCC_UART_DRIVER IDATA 00C0H 0002H UNIT ?ID?UART_GET_RBUFLEN?PCC_UART_DRIVER IDATA 00C2H 0001H UNIT ?ID?_PCC_TIMER_1_WAIT?PCC_SERVICE_ROUTINES IDATA 00C3H 0001H UNIT ?STACK