On Wed, 2005-06-29 at 19:49 -0400, Olin Lathrop wrote: > Peter Onion wrote: > > The only thing about the order that matters that you can ensure the isr > > tail code (with context restore and retfie) comes last. > > Yes, within that segment. However, my point was how do you guarantee that > this segment even follows the ISR startup code at all? The startup code > needs to be at an absolute address. Yes you are right, and I think I've said somewhere else that the isr context save code is in an absolute segment at location 4. It then jumps to a label at the top of the isr handlers segment. > I could see the linker not allowing > absolute and relocatable segments with the same name. On the other hand, > maybe it's fine with that, I've never tried. You are right. start up code is in a differently named (absolute) segment. Handlers go in a segment called "handlers" which is relocatable. > > I think it would be a pretty perverse linker that put code from the same > > segment in any order other than the order it comes across it while > > processing the command line arguments. > > Maybe, but it could also do it backwards or whatever. I would stay away > from this unless it is specified in the linker manual. Who was talking about using "undocumented MPASM features" the other week ? ;-) I've got a little example working which has interrupt handers for serial receive and TMR0 and startup code for USART and TMR0 in "chained segments" and it works fine. The main code has nothing in it but the context save for the isr, a call to "startSetup" and a calls to getChar, waitWms and putchar in an endless loop. waitWms sets a counter and starts up TMR0 interrupts. The TMR0 interrupt handler decrements a counter (at 1ms intervals) until it reaches zero then it stops the interrupts. waitWms just sits and waits until the counter becomes zero then returns. The USART rx interrupt puts chars in a circular buffer while the "waitWms" is pausing so upto 16 chars can be buffered. Peter -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist