Here is my code.When i is 100,the result of the serial is 96.But When i is 10000,the result is still 96.If i change"a++" into "Serial.print(1)",the result changed. :~
probably an optimization issue, the compiler probably knew that "a" was useless and didn't bother running your for-loop, but if you tell it to output "1", then it's forced to actually send that out the serial port, thus the for-loop remained in that case
solve the problem by using a NOP instruction in the for-loop, that's what I would do. Or make "i" volatile.