> > I agree that falling off the end of main() is not a good idea, but the > > code won't wander off into uninitialzed code space. Code generated by > > the Hi-Tech compilers jumps back to the beginning after the closing > > brace of main(). > > 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. After inspecting the assembler generated by HiTech, I can tell you that HiTech defines "global start" at the head of the assembler file, and at the end of the program instructions it does an "ljmp start". > > 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". _______________________________________________________________________ Adam Woodworth SMTP : adam@mirkwood.com HTTP : http://www.mirkwood.com HAM : N1ZNN _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist