A very basic version can now be found in the addrqual branch: Declaring a named address space:
__adressmod <set> <name>; where set should be a function taking no arguments and name is the name of the new address space. sdcc will then ensure that set is executed before each access to a variable in the address space name (and no set function of another address space is executed). E.g. void set1(void); void set2(void); __adressmod set1 space1; __adressmod set2 space2; space1 int i, j; space2 int k; void f(void) { k = i + j; } in f set1() will be called first, then i and j will be added, then set2() will be called and the result of the addition will be stored in k. The idea is that the set functions does some magic (set some page register, i/o location or memory mapped whatever) necessary to map the variables in the named address space into the physical address space. This allows for a flexible approach to bankswitching. Next steps: * Tell the linker about it, i.e. put i and j into a section named space1 instead of the generic _DATA. * Fix bugs (so far this is only very lightly tested and only on Z80/Z180/R2K) Other ports and more complicated operations, like pointer lookup with pointers residing in one named address space pointing to a variable in another address space or passing variables as arguments might currently be broken. * More efficient placement of the calls to set function (this is NP-hard in general, but I have some ideas about using the limited tree-width of the control-flow graph to approach this problem). * Implement __adressmod read1 write1 space1; which would give named address spaces for memory that cannot be mapped into the processor's physical address space. Philipp ------------------------------------------------------------------------------ RSA(R) Conference 2012 Save $700 by Nov 18 Register now http://p.sf.net/sfu/rsa-sfdev2dev1 _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user