I have sketch when is fully functional on Mega328.
Now I have some errors when I tried to compile a program for Mega8 :
C:\DOCUME~1\Notebook\LOCALS~1\Temp/cchjwH1j.s: Assembler messages:
C:\DOCUME~1\Notebook\LOCALS~1\Temp/cchjwH1j.s:29: Error: illegal opcode jmp for mcu atmega8
C:\DOCUME~1\Notebook\LOCALS~1\Temp/cchjwH1j.s:269: Error: illegal opcode jmp for mcu atmega8
I have selected board : Arduino NG w ATMEGA8...
In sketch I using WDT, HW serial, SW serial and some IF, delays and write to ports. Arduino IDE is 1.0.2
Please can you help me find source of this problem?
The Atmega8 doesn't have a "jmp" instruction. It has a "ijmp" which jumps to whereever the Z register is pointing. This compiles (not tested on an Atmega8 but works on a Atmega328):
I put some extra stuff in there, because Optiboot (bootloader) expects certain things, like the stack pointer to be correct, and the USART to be in a default state.
I should point out however that this is not the same as doing a hardware reset (pushing the reset button). All this does is jump back to the start of the code. It doesn't set IO ports back to inputs, and things like that.
Really, you should never need to do a software reset like that. A "watchdog" reset would be better because that is an actual reset.