Am 19.10.2010 12:14, schrieb JMGross: > Well, there IS an application where PIC is required (even if it can > be solved using non-PIC code as well): If you need to place > functions in RAM, but don't want to place them there permanently (by > putting them into the data segment and hoping they will be there > untouched ever after PUC). A prominent example is a flashing > function, which is copied from flash to ram when needed.
in such cases, it's also a possibility to create a linker file and compile the function separately for a location in RAM. then embed the binary as byte array in the application. however if you plan to move code at runtime, you have to ensure a few other things than just position independent assembler for a function: - you probably can not use any global variables. at least moving them by the same offset as the code won't work. using absolute addresses would keep the variables working, but do you really need the same variables when the code runs from RAM and when it runs from Flash? - such a function also must not make calls to any other code that is not moved. this includes support code that the compiler adds (libc, libgcc). tha's important in the case of moving a function to RAM so that it can erase the Flash for a software upgrade. compiling separately and embedding as array like mentioned above helps in this case. you would not want to have the entire application in position independent code, as the MSP430 instruction set has no direct support to do this very efficient. one of the issues is the "call" instruction which takes the target address as absolute address in the form of an immediate value. chris ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Mspgcc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mspgcc-users
