Originally Posted by tautvilis
Hello, in class we started to study assembly and some questions came to my mind. While i couldnt find the answers by myself I had to ask them here. So I compiled a "hello, world" program written in C in my linux and then executed objdump -D file.out. In the book the same operation is executed with the same X86 processor(mine is also x86) and the machine instructions differ. Why and how can?
Well, think about English: you can write different words to give the same meaning.
The reason can be understand if you write down phrases with different words but same meaning.
You can use different word to say the same thing.
A good exercise is to compile your program your program using different optimization flags: (in gcc -O, -O2 for example, but in the manual you find many flags)
A simple example (i do not know x86 assembly sufficiently to write code on the fly - but I hope you get the idea):
IF i < 7 is equal to IF i <= 6 (i is integer)
Coding is almost like writing ... you can use different styles, even writing assembly code :-)