Jump to content
Excelsior Forums
White-Elephant

XDS-C Use of constant pointers

Recommended Posts

Hi,

When we absolutely place a variable in modula we would expect this to result in a constant pointer

rather than a normal pointer.

The difference being that constant pointers can be loaded into ROM whereas normal pointers are

allocated space in RAM and then have to be initialized by copying their initial values from ROM.

This wastes RAM and presents a problem in initial setup code that wants to access these pointers before the chip selects have been programmed for the RAM or the RAM copy procedure has run.

For example, in modula

MODULE Example;

FROM SYSTEM IMPORT ADDRESS;

VAR

  TRANRAM1 [ADDRESS(0FFFFFD20H)] : CARDINAL;

 

BEGIN

  TRANRAM1 := 42;

END Example.

currently produces

static unsigned long *TRANRAM1 = (unsigned long *)(X2C_ADDRESS)0x0FFFFFD20u;

X2C_STACK_LIMIT(100000l)

extern int main(int argc, char **argv)

{

   X2C_BEGIN(&argc,argv,1,2000000l,4000000l);

   *TRANRAM1 = 42ul;

   X2C_EXIT();

   return 0;

}

whereas better would be

static unsigned long *const TRANRAM1 = (unsigned long *)(X2C_ADDRESS)0x0FFFFFD20u;

ie

* const TRANRAM1

instead of

* TRANRAM1

How can we tell XDS to generate constant pointers?

Shouldn't this be the default if the output is ANSI-C?

Ahlan

:huh:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×