Jumping to the reset vector will re-run the program from the beginning, but it's not performing a reset! - the stack will still be set at where ever it was previously!, and any other registers you assume reset values for will not be valid.
If you are using a 18F series then it has got a software RESET instruction. Tying a port to MCLR is a good idea but keep in mind to use a RC Delay network. Normally when the PIC starts the data direction registers are set as input so no prob. Still in some cases you find your PIC freeze.
It is not unheard of to reset the PIC from code, however, you method is unacceptable. For one, as Nigel points out, the stack remains full thus an overflow could occur.
The second point is this is a compiled language, thus the complier MUST know what's going on. Jumping to other places in assembly code without returning will likely break it since the compiler has no understanding of what the asm block does. I believe it is very ill-advised to use the PICC18's reset asm instruction directly as well. The asm reset will work at runtime, the compiler can't mess this up, but the compiler will think it needs to build code that expects to keep executing from there, which may confuse it. It may not compile as well as it could. As a minimum example, say you have this in a function, it'll build code for returning from it even though the code is unreachable.
PICC has a reset instruction. I forget whether it's capitalized or if it has a "()" at the end. But anyways, the compiler will take care of how to implement it whether your part has a reset assembly instruction or not. In any case the compiler should be fully aware what it needs to do and make optimum code. It should clear the stack out, probably TRIS the ports, jump to the start of code, and will reinitialize variables as necessary.
I would check the datasheets! - on later PIC's it continues from where it stopped (from a SLEEP instruction) when the WDT times out. Earlier devices did a soft reset from a SLEEP/WDT - I spent ages trying to get a 16F628 to wake from sleep and couldn't understand why my code wasn't working properly :lol:
On the 16 series chips the stack is a circular buffer and so it doesn't matter if it gets reset or not it will still work fine. I'm not sure what the emulator will make of it though.
Mike.
Edit, just tried it in the emulator and it works as expected.
Errr...Am I half asleep or doing a "org 0x00" will not reset anything, including the PC ? :roll:
The org "instruction" is not an instruction interpreted by the CPU, it's a pseudo-instruction that tells the assembler to place the following instructions from location 0x00.
As it was already pointed out, the RESET instruction is what you are looking for, even if I don't think that a correct way to resume from an abnormal condition is to reset everything... doing so is, I think, a bad habit... a PIC is not running on Windows