On Sat, 2004-10-02 at 22:08, steve@tla.co.nz wrote: > > Are you absolutely certain of that? Does HiTech put a "goto" at the > > end brace? I would be very surprised and disturbed if they did. > > What would you say is the correct thing to do in this situation ? Nothing, since proper code would NEVER have the situation. > > Remember, that if execution DOES go into "never never" land, and all > > of that place is uninitialized, the PIC will simply see 3ff as the op > > code. Since that is an invalid op code it will treat it as a NOP and > > increment the PC. Eventually the PC will wrap and hit address 0, which > > of course is the first instruction of your program, which will "rerun" > > your program, giving the ILLUSION that the program "restarted". > > ILLUSION ? > Is that a newly defined C keyword ? No, why do you think I think that? > You have assumed that the locater has put main() at the highest > address in memory. What happens (according to you scheme) if > main() is located immediately before detonate() ? The reason I gave WAS SPECIFIC TO THE EXAMPLE, in which case there WAS ONLY MAIN, NOTHING ELSE, I also specified that ALL OTHER LOCATIONS WERE UNDEFINED. > You have also assumed PIC architecture, operation based on an > undefined opcode and that the instruction returned from all > addressable memory between the top of rom and PC rollover be > executed as a NOP. Read the datasheet and show me where an undefined op code in the PIC architecture IS NOT TREATED AS A NOP? > My personal preference would be a jmp $ after the closing brace, > but I think I'd take Hi-Tech's approach over a mixture of undefined > assumptions producing an illusion. My personal preference is that the compiler didn't do more then it was asked of. There is no such this as "exiting main" on the PIC, to define a behaviour is simply silly since it SHOULD NEVER HAPPEN. Sloppy coding is the ONLY reason something like this would happen, and the compiler "fixing" sloppy coding is what I'm really against. ----------------------------- Herbert's PIC Stuff: http://repatch.dyndns.org:8383/pic_stuff/ _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist