Converting Program X to Binary: How to Achieve Optimal Efficiency?

In summary: There is no program that can shortcut this process. Anyone who says otherwise is likely trying to sell you something.
  • #1
Steven Ellet
85
3
If I have program X how do I get it in binary form?
 
Technology news on Phys.org
  • #2
Steven Ellet said:
If I have program X how do I get it in binary form?
Your question is very vague.

What do you mean by "program"? Is it source code of some kind? If so, what programming language? Some programming languages, such as C, C++, Fortran, and others require the use of a compiler and linker to translate the human-readable source code into machine code (i.e. a binary) that can run on a computer.
"Program" could also refer to an executable, in which case it is already in binary form.

Please provide additional information
 
  • #3
In the case of binaries for embedded X86 programs, there are variations of EXE2BIN that convert a .EXE file into a binary file (the addresses / offsets for the segments are passed in a parameter file or as command line parameters). The tool sets for other embedded processors, like the ARM, also include utilities for producing binary files (in some cases the linker is able to produce a binary file, similar to producing a X86 .COM file).
 
  • #4
Please provide additional information
Based on you response, it seems I have much to learn. When I say "Program" I mean quite a few things from executable to text documents to chrome, etc - but to start with, something simple. You say an executable is already in binary and yet it is a exe file, I am looking for the 01100 format. i am hoping for a program that can convert for me
 
  • #5
Steven Ellet said:
Based on you response, it seems I have much to learn. When I say "Program" I mean quite a few things from executable to text documents to chrome, etc
Text documents are just that - text that is readable by humans. They are not binary files.
Steven Ellet said:
- but to start with, something simple. You say an executable is already in binary and yet it is a exe file
An exe file is in binary form. The exe2bin tool that rcgldr referred to existed back in the days of DOS. That tool was used to convert an exe file to a different format (but still binary) -- for the exe2bin that I'm referring to, see http://en.wikipedia.org/wiki/Exe2bin.
Steven Ellet said:
, I am looking for the 01100 format. i am hoping for a program that can convert for me
Convert what to binary form? There's no point in converting a text file to binary, and executables already are in binary form. Your question is still unclear.
 
  • #6
Any file consists of a sting of bytes
The bytes in an executable file represnt instructions and data that already have been been formatted in a way that the machine is able to use directly in performing whatever the task of the program is.
A text file is also a sting of bytes, but in that case the bytes are formatted in a way that that they could make sense to a human..
Program source files are text files and compilers are a tool which converts the human readable text into an executable that the machine can process.

However, any file is just a string of bytes, and any string of bytes whatever it's intended purposes is, can be viewed or edited as binary if there is a reason to do so.
You could convert this message into a binary form, though there wouldn't be any good reason to do it.
Binary is just a way of representing values and symbols, text is an other way, and there are other methods of representing values.
Binary is just a way representing values in a way that makes computation simple for a digital machine.
 
  • #7
Anything in a computer is in binary code, text or otherwise. The difference between a simple text file and executables/libraries/drivers is that the binary/hex code of the text file is limited to ASCII codes (http://www.asciitable.com/), whereas executable files may have any hex codes. Download an Hex Editor, it'll show you the hex codes of any file, which you can then translate to binary using this tool for example: http://www.binaryhexconverter.com/hex-to-binary-converter
 
  • #8
Tosh5457 said:
Anything in a computer is in binary code, text or otherwise. The difference between a simple text file and executables/libraries/drivers is that the binary/hex code of the text file is limited to ASCII codes (http://www.asciitable.com/), whereas executable files may have any hex codes. Download an Hex Editor, it'll show you the hex codes of any file, which you can then translate to binary using this tool for example: http://www.binaryhexconverter.com/hex-to-binary-converter
Thank you, I had almost given up hope of being understood. This seems to be what I was looking for, even if it is not a program. https://www.physicsforums.com/members/mark44.147785/-you did not understand my request, as Tosh5457 stated "Anything in a computer is in binary code, text or otherwise." hence "01100 format" Now that an understanding has been made, is there a program that will shortcut this process?
 
  • #9
  • #10
So you want a program that takes an arbitrary file and converts it into a .txt file that contains a bunch of 1s and 0s?
What would you prefer? A linux command? Or maybe a C, Java or Python program?
There exists a linux program/command that can do this. It's called xxd.
Under linux you just open a console and type "xxd - b filename > output.txt".
 
  • #11
DrZoidberg said:
Under linux you just open a console and type "xxd - b filename > output.txt".

Ha! I learn something new every day here, even after all these years. :cool:

Minor correction: no space between - and b:

xxd -b filename > output.txt

Omit the "> output.txt" and the results are displayed directly on the console. Mac OS has this available at the command line in the Terminal application:

Code:
jtbell-iMac:Desktop jtbell$ cat testfile
One two three
Four five six
jtbell-iMac:Desktop jtbell$ xxd -b testfile
0000000: 01001111 01101110 01100101 00100000 01110100 01110111  One tw
0000006: 01101111 00100000 01110100 01101000 01110010 01100101  o thre
000000c: 01100101 00001010 01000110 01101111 01110101 01110010  e.Four
0000012: 00100000 01100110 01101001 01110110 01100101 00100000   five
0000018: 01110011 01101001 01111000 00001010                    six.
 
  • #12
Steven Ellet said:
Thank you, I had almost given up hope of being understood. This seems to be what I was looking for, even if it is not a program. https://www.physicsforums.com/members/mark44.147785/-you did not understand my request, as Tosh5457 stated "Anything in a computer is in binary code, text or otherwise." hence "01100 format" Now that an understanding has been made, is there a program that will shortcut this process?
Yes, all things in a digital computer are in binary form, but at first you were calling everything "programs" and that is what confused people. I think Mark understood your original post as well as it possibly COULD be understood since you clearly did not understand that text files, as you now know, are not programs.
 
  • #13
The Hex Editor program (HxD) I downloaded works great but does half the work I need-the output is in hex. No program or website seem able to handle the code properly, http://www.binaryhexconverter.com/hex-to-binary-converter has a max of max. 7blackblackfff and just results in an error. One example of what won't work has code that is (Hex) 00000000 through 0000F380 and 00 through 0F
 
Last edited by a moderator:
  • #15
Steven Ellet said:
The Hex Editor program (HxD) I downloaded works great but does half the work I need-the output is in hex. No program or website seem able to handle the code properly, http://www.binaryhexconverter.com/hex-to-binary-converter has a max of max. 7blackblackfff and just results in an error. One example of what won't work has code that is (Hex) 00000000 through 0000F380 and 00 through 0F
What is your actual goal here? I mean, hex IS binary, just condensed but trivial to read as binary, so what is it that a binary output will give you that a hex output won't?
 
Last edited by a moderator:
  • #17
Could you be more specific? What exactly is that "code" that you want to convert to binary? What exactly is the binary output supposed to look like? And what do you want to use that binary code for?
 
  • #18
Mark44 said:
The exe2bin tool that rcgldr referred to existed back in the days of DOS. That tool was used to convert an exe file to a different format (but still binary) -- for the exe2bin that I'm referring to, see http://en.wikipedia.org/wiki/Exe2bin.
Maybe it was changed, but the wikipedia article for exe2bin now refers to the version that "existed back in the days of DOS". As mentioned in the wiki article, one usage for exe2bin was to create a .COM image file, and another usage was to create a binary file to be used in a BIOS or device driver. Variations of exe2bin were made to create images for embedded systems, although I'm not sure how this differs much from creating an image to be used in a BIOS. One aspect of this is that initialized data is stored somewhere in the image, and at startup, that data is moved from the stored location in the image to it's targeted location somewhere in read/write memory.
 
  • #19
phinds said:
What is your actual goal here? I mean, hex IS binary, just condensed but trivial to read as binary, so what is it that a binary output will give you that a hex output won't?

DrZoidberg said:
Could you be more specific? What exactly is that "code" that you want to convert to binary? What exactly is the binary output supposed to look like? And what do you want to use that binary code for?
I'm with @phinds and @DrZoidberg here. @Steven Ellet, just what are you looking to do? It's a simple matter to convert from hex to binary (i.e., base-2). Just convert each hex digit to its equivalent four binary digits.
$$\begin{bmatrix} \text{hex} & \text{binary} \\
0 & 0000\\
1 & 0001\\
2 & 0010\\
3 & 0011\\
4 & 0100 \\
5 & 0101 \\
6 & 0110 \\
7 & 0111 \\
8 & 1000 \\
9 & 1001 \\
\text{A} & 1010 \\
\text{B} & 1011 \\
\text{C} & 1100 \\
\text{D} & 1101 \\
\text{E} & 1110 \\
\text{F} & 1111 \end{bmatrix}$$
 
  • #20
  • #21
phinds said:
What is your actual goal here? I mean, hex IS binary, just condensed but trivial to read as binary, so what is it that a binary output will give you that a hex output won't?
My friend is trying to create a new form of programing that he thinks will be faster than what currently exists. I do not know what he requires for this but I want to help him by giving him all he might need. The reason I wanted a program instead of a website is so he can work offline as needed. For all I know he might start from the ground up (which I think would be rather hard).
 
  • #22
This is called a compiler, or for writing really fast code at the same level the hardware operates, an assembler.
 
  • #23
Steven Ellet said:
My friend is trying to create a new form of programing that he thinks will be faster than what currently exists. I do not know what he requires for this but I want to help him by giving him all he might need. The reason I wanted a program instead of a website is so he can work offline as needed. For all I know he might start from the ground up (which I think would be rather hard).
Which STILL gives me no idea whatsoever why you need a binary view of anything.

EDIT: and by the way, if your friend can't even write his own program to output binary from any file, the thought that he is going to "create a new form of programing that he thinks will be faster than what currently exists" is hilarious.
 
Last edited:
  • #24
phinds said:
Which STILL gives me no idea whatsoever why you need a binary view of anything.

EDIT: and by the way, if your friend can't even write his own program to output binary from any file, the thought that he is going to "create a new form of programing that he thinks will be faster than what currently exists" is hilarious.
My friend understands programing better than I do, so he might need something totally unrelated to binary and hex. I am just making a stab at what he might need. and like I said, he might be starting from scratch. if anyone has any ideas that would help make a new form of programing, please post. (Absolutely NO naysayers or tearing down the idea)
 
  • #25
If you don't know any details of what he's doing, then all we can do is flail around blindly in the dark. Thread closed.
 
  • Like
Likes pbuk

What is the purpose of converting a program to binary?

The purpose of converting a program to binary is to make it readable and executable by a computer. Binary code is the most basic form of instructions that a computer can understand and execute.

What is binary code and how does it work?

Binary code is a coding system that uses only two digits, 0 and 1, to represent data and instructions. It works by breaking down instructions into a series of 0s and 1s, which the computer can then interpret and execute.

How do I convert a program to binary?

To convert a program to binary, you can use a compiler or an assembler. These tools take the source code of a program and convert it into machine code, which is in binary form, making it executable by the computer.

What are the advantages of using binary code?

The main advantage of using binary code is that it is the most fundamental and reliable form of coding for computers. It allows for more efficient storage and processing of data, making programs run faster and more efficiently.

Are there any downsides to using binary code?

One downside of using binary code is that it can be difficult for humans to read and understand. This is why high-level programming languages were developed, which can be converted into binary code by a compiler. Additionally, manually converting a program to binary can be a time-consuming and error-prone process.

Similar threads

  • Programming and Computer Science
Replies
29
Views
2K
  • Programming and Computer Science
Replies
33
Views
3K
Replies
13
Views
2K
  • Programming and Computer Science
Replies
33
Views
2K
  • Programming and Computer Science
Replies
5
Views
758
  • Programming and Computer Science
Replies
22
Views
919
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
7
Views
2K
Replies
4
Views
935
  • Programming and Computer Science
2
Replies
47
Views
3K
Back
Top