From: Philipp K. K. <pk...@sp...> - 2011-11-10 16:05:00
|
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 |
From: Philipp K. K. <pk...@sp...> - 2011-11-14 17:53:30
|
Here's a short progress report. Named address spaces are still very experimental, but I think they have progressed to a stage where some of you might want to try them. You can checkout the branch using svn co https://sdcc.svn.sourceforge.net/svnroot/sdcc/branches/addrspacequal/sdcc sdcc-addr The basic stuff seems to work: Variables in named address spaces, pointers pointing to named address spaces including pointers in one space pointing into another. Switching is no longer as inefficient as it was before, and the variables are allocated into segments named just as the address spaces, so you can place them in the linker. There probably still are lots of bugs to be found and fixed, though. For now, those using systems supporting bank-switching (Z180, Rabbit, systems with extra memory management hardware like the Sega video game consoles) might want to try this new feature. Still missing: * Support for memories that cannot be mapped into the processor's address space (e.g. extern, I²C-connected EEPROMS). * More and better error messages when attempting to use named address spaces in a way they are not supposed to be used. * Optimal placement of the bank-switching calls. Philipp |