As we know each processor
has its own instruction set (ex-8085 processor has its own INSTRUCTION SET).So to execute any instruction by using that processor
the instruction must be one of from its instruction set (means we can execute only that instruction on 8085 processor which belongs from 8085 instruction set).
so here my question is if we write any program (assume we write program using c language) then after compiling using compiler( as we know compiler generates code which is executable on machine ex..gcc or turbo c) it generates code which is used to run on machine i.e the code (set of instruction which belongs from that processor INSTRUCTION SET) to execute on processor.so how our compiler knows which processor we are using and converts the whole program to instructions which are executable by our processor.
example- 1) if we install turbo c on machine which has Pentium processor.so if we execute our c program on this machine it must convert whole program to set of instruction which belong from Pentium processor INSTRUCTION SET And if we install turbo c on machine which has i5 processor then it must convert the whole program to set of instruction which belongs from i7 processor INSTRUCTION SET.
so how the compiler knows which processor we are using and why the compiler is different for OS it must be different for the processor according to above explanation?
(i'm finding an answer to this question from long time and SORRY FOR lengthy statement)