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

how to force constants into hconst

I am having a bit of a problem with constant arrays on the ds80c400 i.e. char y[] = {1,2,3,4};

Note: the ds80c400 has a 16M contiguous memory map.

example 1:
in the following code the array is placed in segment CONST.

#include <stdio.h>
char foo (int x)
{
  char y[] = { 1,2,3,4};
  return(y[x]);
}

example 2:
in the following code the array is placed in segment CODE.

#include <stdio.h>
char foo (int x)
{
  char y[] = { 1,2,3,4};
  printf("1234%d",1);
  return(y[x]);
}


Is there a compliler switch to force the compiler to place these in HCONST or ECODE by default?

Parents
  • first of all

    char code y[] = { 1,2,3,4};
    
    will place it in the const segment not the hconst segment. The correct way to place this in the hconst is
    char const far y[] = { 1,2,3,4};
    

    second, I guess I did not express my intial case clearly (sorry).

    when the compiler creates the array, it copies the initialize data from a segment which is located in the const/code segment to the array in xdata.

    in the first case the const segment is used, however the uv2 environment does not define the const segment for the ds80c400 and due to maintenance issues we do not want to manually define the const segment.

Reply
  • first of all

    char code y[] = { 1,2,3,4};
    
    will place it in the const segment not the hconst segment. The correct way to place this in the hconst is
    char const far y[] = { 1,2,3,4};
    

    second, I guess I did not express my intial case clearly (sorry).

    when the compiler creates the array, it copies the initialize data from a segment which is located in the const/code segment to the array in xdata.

    in the first case the const segment is used, however the uv2 environment does not define the const segment for the ds80c400 and due to maintenance issues we do not want to manually define the const segment.

Children
No data