suppose we want to write a console app that outputs the string "hello world" to the screen using c++,c, assembly or any other languages.will the machine code generated by these languages be the same?
thanks
Printable View
suppose we want to write a console app that outputs the string "hello world" to the screen using c++,c, assembly or any other languages.will the machine code generated by these languages be the same?
thanks
Errrrr... JAVA uses bytecode.
Hi
Some aspects of your question, and an explanation of TheSpecialists comment,
can be found in this thread[1] (read the whole thing).
In short: No.
More lengthy: What do you mean by "same" machine code?
Let us consider "c" only. There are lots of compilers available.
Each compiler has its own flavour of producing/optimising/aligning code/data.
If you do a "printf" only, you will possibly find similarities, but never exactly the
same machine code (exception might be the simplest arithmetical operations).
Even using the same compiler, while changing some flags you will have a
bunch of different outputs.
However: A call to a fixed API function will always be a call to a fixed API function.
In such a sense, they will (partly) produce the same code.
Example:
could look likeCode:x=0;
orCode:mov dword ptr [ebp-4],0
etc.Code:mov eax,dword ptr [ebp-4]
xor eax,eax
mov dword ptr [ebp-4],eax
; although, very unlikely
Cheers.
[1] http://www.antionline.com/showthread...hreadid=265616
after reading the thread i have another question.
since all compiled language gets turn to machine code and assembly mnemonics are machine code,would'nt it be possible to read the machine code and assign the right mnemonic to it?
Why did you edit your post so that JAVA is no longer listed with those languages... I thought it was pretty funny.
it won't be funny if u were a newbie now would it?
EDIT:u want to know what's even funnier?after reading ur post i immediately posted "how'd u know?" then when i realise the poster was the same person i quickly deleted my post and posted this one.hahaha.anyway back to the question
Im worse than that... im an AO senior member. Once you've got to that stage you can just spurt out something randomly and a few people will always assume your right and you know something.Quote:
it won't be funny if u were a newbie now would it?
^ already linkedQuote:
The think its the processor and if we go deeper the ALU, all need to understand the compiled program. The compiled program is just a series of opcodes, that can be easily converted back to ASM, with no major hassle.
so any program written for any language specifically for the x86 processor can be diaasembled into assembly language for the x86 processor,right?
Hi
Disassembling of compiled code into assembly language is nothing mysterious.
Assembler opcodes (text editor) are representatives of machine code (hex-editor),
eg
There is only one difficulty, namely when the executable is packedCode:0F84h (a sequence of 0 and 1's) is jz // "do jump if "
0F85h (a sequence of 0 and 1's) is jnz // "do not jump if "
and selfmodifying (besides a few tricks to hinder disassemblers).
Cheers.