Hi Isaac, Thanks for the ideas and for taking the time to elaborate. If I = can't implement them here (mainly because of the complexity of the = microchip fat library with so many callable functions and concerns about = fixed RAM allocations to make the two compatible), the concepts will = come in handy later. Tony Isaac Marino Bavaresco wrote: > Tony Vandiver escreveu: > = >> I'm trying to write a custom bootstrap to load in my application code = >> from an SD card. I want to call file I/O routines located in my = >> bootstrap from my application rather than duplicating the file I/O = >> library functions in the application because it represents about 10% of = >> my code space. Typically when I compile, I compile and link everything = >> that pertains to a project at the same time, but in this instance, do I = >> need to reference an object file from the bootstrap compilation without = >> compiling it into the application project, and if so, how do I keep it = >> from being relocated by the linker without expressly setting the address = >> of each function? I'll start reading the compiler reference material = >> now and see how long it will take me to start drooling. >> >> Thanks for the help, >> >> Tony >> = >> = > > You could put a 'jump table' at a fixed location in your bootstrap's > program space, with each entry jumping to one routine that you may call > from your application. > > The reason for the 'jump table' is to make the entry points fixed, even > if you change your bootstrap code. > > Assuming you are using MPLAB C18 (other Cs may have a slightly different > syntax, but not much even for other MCUs). > > In the bootstrap: > > #pragma code JUMPTABLE =3D 0x1f000 > > void JumpTable( void ) > { > _asm > goto mount; > goto remove; > goto ... > _endasm; > } > > #pragma code > > In your application you call the functions this way: > > typedef void (*func_type1)( void ); // Pointer to a function that take > void and return void; > typedef int (*func_type2)( const char rom * ); // Pointer to a > function that take a string and return int; > .... > > #define mount() ((func_type1)0x1f000)() /* mount entry point is at > 0x1f000 */ > #define remove(name) ((func_type2)0x1f004)(name) /* remove entry point > is at 0x1f004 */ > .... > > void main( void ) > { > mount(); > remove( "backup.bin" ); > } > > Best regards, > > Isaac > __________________________________________________ > Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = > http://br.beta.messenger.yahoo.com/ = > > = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist