Previously I had used atmega328p for my projects as a standalone microcontroller, and now I want to replace that with atmega 8a. Although I replaced that and is working fine except for the starting delay i.e unlike atmega 328p, it takes around 9-10 seconds to start working for the first time. Can it be removed? If I am not wrong ,the problem is because of bootloader. Is there any solution for this?
The ATmega8 official bootloader is called "Arduino NG". It was one of the first Arduino boards. There was no auto-reset via the DTR signal to upload a sketch and the reset button had to be pressed, and then there was about 10 seconds that a sketch could be uploaded.
You could get an OptiBoot bootloader or make one yourself. With a little luck that bootloader is less than 512 bytes. You would also have to add a new board to the "boards.txt" file.
Another option is to use a programmer to upload the sketch. Then the bootloader will be removed and the sketch starts immediately.
Did you try the new Arduino IDE 1.6.10 ? It has the -flto option enabled by default, and that should shrink the code and sram usage by 5 to 20% for an ATmega8.
This core appears to have optiboot for atmega8 - https://github.com/MCUdude/MiniCore