Terminate program execution.
STOP can also be used to terminate a program.
When an END statement is encountered, all interrupts are disabled and a never-ending loop is generated.
When a STOP is encountered the interrupts will not be disabled. Only a never ending loop will be created.
In an embedded application you probably do not want to end the application. But there are cases where you do want to end the application. For example when you control some motors, and you determine a failure, you do not want to use a Watchdog reset because then the failure will occur again. In that case you want to display an error, and wait for service personal to fix the failure.
It is important to notice that without the END statement, your program can behave strange in certain cases. For example :
Note that there is no END statement. So what will happen? The program will print "Hello". But as the compiler places the library code behind the program code, the micro will execute the library code ! But without being called. As most library code are assembler sub routines that end with a RET, your program will most likely crash, or reset and repeat for ever.
Print "Hello" ' print this
End ' end program execution and disable all interrupts