Hector Martin wrote: >> The one thing that wouldn't work with my scheme is if there is a jump to >> one of the first 8 bytes in the application (except 0). But I think this is >> quite rare. > > What about a relative branch to the user code instead of an absolute goto? > > ORG 0 > bra START You're right, I didn't consider a relative branch. I think this is quite rare with compilers, but I don't know this for a fact. > > goto 8 > goto 10 ; this is in case there's a skip instruction at the end of the > user code > > goto > goto > goto > goto This looks like it would work and solve the issue, though. >> Hi-Tech puts some basic context saving code at the interrupt vectors, >> followed by a goto. If no interrupt functions are defined, it doesn't >> generate any interrupt vector code. The goto that is at the reset vector is >> preceded by a nop in some cases (seems to be required by some erratas). > > Do you have an example handy? (hex or asm) psect intcode 000008 CFD8 FF5F movff status,saved_regsh+30 00000C CFFA FF5E movff pclath,saved_regsh+29 000010 CFFB FF5D movff pclatu,saved_regsh+28 000014 EF9B F057 goto save psect intcodelo 000018 CFD8 FF40 movff status,saved_regsl+3 00001C CFE0 F010 movff bsr,saved_bsrl 000020 EFE9 F058 goto savelo save and savelo are the locations where the rest of the context is saved and the user interrupt routine started. The reset vector is simple: powerup: nop ; Suggested Microchip errata workaround goto start >> This looks like it might complicate things. Do you really have to redirect >> the interrupts? Isn't it enough to check at boot? > I'm considering this feature experimental, and it's optional (the user > code has to include a magic word somewhere indicating it wants this > patching done, otherwise it just proceeds normally). The idea is to let > people write really simple programs (with no interrupts or only basic > interrupts, and no UART use) and automatically patch them to support > bootloader resetting via UART (which amounts to hijacking the interrupt > vector, just like the reset vector). Makes sense in your case. Gerhard -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist