0
$\begingroup$

I know when I compile my C program to machine code it gets compiled into something that specific computer can understand

But I thought computers can only understand 1's and 0's (high/low) so why doesn't my program look like a bunch of strange symbols and not 1's and 0's?

ie: "UHâÂHÉÏHç=7∞Ë1…âE¸â»HɃ]√êˇ%¶LçïASˇ%ÖêhÈÊ"

There must be one last piece I'm missing where these symbols get converted to 1's and 0's somehow

$\endgroup$

2 Answers 2

3
$\begingroup$

This is a result of the program that opened the file.

All files on the system are in binary. What matters is how you interpret it.

The editor you used has displayed the digits in their common form:

"UH...." is the equivalent hexadecimal "5548...." which is binary "101010101001000...."

Thus you need a Hex or Binary editing program to 'view' the '1's and '0's.

$\endgroup$
3
0
$\begingroup$

Machine/object code is specific to the interpreter/parser. What you mean to say by "1's and 0's" is binary code, which is what is presented to the machine when the interpreter/parser receives the machine/object code as input.

$\endgroup$
6
  • $\begingroup$ So at run time there is a parser that translates the machine code to binary code? $\endgroup$
    – MobileMon
    May 27, 2015 at 20:43
  • $\begingroup$ @MobileMon Yes, depending on the language. However, this is not necessarily true of all languages, but eventually, if the code is to be run on the machine, it is translated to binary at some point. $\endgroup$ May 27, 2015 at 20:49
  • $\begingroup$ Now I'm not sure I quite understand. Please explain depending on the language. Also I'm not talking java or byte code here, I understand how the JVM works, I just mean the object file/executable file is not binary so at some point it needs to be binary $\endgroup$
    – MobileMon
    May 27, 2015 at 20:55
  • $\begingroup$ The Java compiler translates source code to machine/object code, and the Java interpreter translates machine/object code directly to binary, which is then sent off to the machine. $\endgroup$ May 27, 2015 at 21:01
  • $\begingroup$ I think you are confused yourself, please see the accepted answer $\endgroup$
    – MobileMon
    May 27, 2015 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.