Hi, > The Contiki version for the apple developed and maintained by Oliver does both > things. Maybe he can give you a few hints. Looking at the Contiki sources is > another option. Here we go... When it comes to loading code at runtime you may first think about the loadable modules feature of the cc65 linker. However the special thing about these modules is that they are relocatable. But to keep the runtime loader/relocator small it does _NOT_ resolve external references from the module into the static code. There's a hack used in Contiki 1.x to have those references resolved anyway and I can provide hints if necessary. But if you "only" want to load different pieces of code at a fixed address known at link time I'd rather suggest to have the cc65 linker write several files and load them into that fixed address using straight file I/O. I explained this approach in detail incl. sample code / sample linker config in a usenet thread: http://groups.google.de/group/comp.sys.apple2.programmer/browse_thread/thread/729db7aa540a74f0 Regarding the initialization I did the initial work in Contiki 1.x which I than mostly ported "back" into the cc65 Apple2 C-Library startup code. The general idea is to put everything being part of the INIT segment at the end of the generated binary file. So it get's loaded into memory where later the BSS will reside. The startup code copies (not relocates) the INIT segment content behind the BSS and then jumps to it. This allows to have all initialization code incl. BSS zero-ing etc. to reside in the INIT segment. Later on the INIT segment will be overwritten by the heap or stack. - If you generally want to have that behaviour on any of the other cc65 targets you (or someone else - maybe a target maintainer ;-) would need to model the startup code in the way described above. Uz however already marked all suitable stuff (i.e. the constructors) in the sources shared between the targets as belonging to the INIT segment :-) - To have your own code be part of that game is technically easy: Just put the stuff in question into the INIT segment. However the question is, when/how to call it. a) As first statement in main() when the heap is still empty and the stack still small - dirty but will most probably just work. b) As part of the C-Library initialization through a constructor. Clean but only for assembler code and requiring additional knowledge for instance about the order of constructor execution to make sure your code gets called last: http://www.cc65.org/doc/ca65-10.html#ss10.14 Good luck, Oliver ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo@musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.Received on Mon Jul 6 09:53:45 2009
This archive was generated by hypermail 2.1.8 : 2009-07-06 09:53:48 CEST