I want to type a couple of 1's and 0's into notepad, save as something.exe, and get a program. Obviously, it will not be very complex. Even just saying hi would work. How do I output text? How do I pause it so it doesn't close immediately? Is there a resource anybody has where it says all this?
-
4You can't just program machine code by typing `1`'s and `0`'s. You should look into assembly programming: http://en.wikipedia.org/wiki/Assembly_language – Bjørne Malmanger Mar 16 '12 at 20:17
-
3http://dilbert.com/strips/comic/1992-09-08/ – Alex Howansky Mar 16 '12 at 20:18
-
You'll certainly get a "Nice Question" badge for that. (+1 if you linked this question to Twitter or Facebook :P) – Mar 16 '12 at 20:19
-
@H2CO3 I think I am going to be linking this to facebook – jzworkman Mar 16 '12 at 20:21
-
im not joking, im just wondering – yourface Mar 16 '12 at 20:27
-
010010 successfully makes a pause, while others dont – yourface Mar 16 '12 at 20:27
-
i already looked into assembly, but its not what i want – yourface Mar 16 '12 at 20:30
-
You are not typing binary but ASCII the proper binary for 010010 is 001100000011000100110000001100000011000100110000 since 0 is character with 48 try to ord('0') in any programming langauge. And if 010010 pause program it's just luck. – jcubic Mar 17 '12 at 00:12
-
@jcubic "You are not typing binary but ASCII" really helps. also, could I reverse engineer this? – yourface Mar 21 '12 at 20:41
-
@yourface you can use disassembler on that binary, nasm have nice disassembler `ndisasm`, http://www.nasm.us/ or ODA online disassembler http://onlinedisassembler.com/ it seams that it's 3 xor instructions on different registers. – jcubic Mar 22 '12 at 16:49
2 Answers
I think you would have a better experience if you used a text editor, typed either binary (ones and zeros) or hex into a text file then write a small program that reads that ascii file and saves it as the binary bits or bytes you intended. Basically making a machine code assembler.
You should specify the processor and operating system you are interested in before taking this further. You not only have to know the opcodes/machine code for the instruction set but need to know the binary file formats for the operating system (coff, elf, exe, etc) and would need to hand code all of that information (much better suited to have your machine code assembler create that header for you if needed).
As an example take http://github.com/dwelch67/lsasim an educational instruction set with simulator and tools that I created. The "binary file format" is an ascii file with the machine code in readable hex. The simulator reads that and executes it, and if desired (which is how I tested it at first), you can hand code the machine code instead of assembly language. I dont have an operating system, etc, the parser that reads the machine code file turns it into a buffer of binary ones and zeros, which is the simulated memory for the processor.
In the old days of dos and windows the debug command line program made this kind of thing easy, hand code either assembly or machine code bytes, and when you save you can easily save to a .com executable file. I am certain I am not the only one that learned x86 assembly language using debug as I couldnt afford to buy software tools like masm, and didnt have a modem to get whatever the popular free assembler was asm86 or some such thing (until years later when I could afford one of those). if debug is still part of the windows command line you can probably still do this today with that tool.

- 69,149
- 8
- 89
- 168
You would need to first identify a specific processor it would run on, and also an environment (raw CPU, some operating system, something else). From the environment you would need to determine the correct binary format. From the CPU you would need to determine the actual machine language. There are several other things you would need to determine as well.
Your question may as well be "where does life come from?" -- yes, it can be answered, but not with any useful result through a simple Q&A forum. If you want to pursue this further, you might consider taking a course (or just reading a book) in Computer Organization, concentrating on the assembly language details. From there, it's not a far stretch to learn to convert your assembly into machine code (though there will still be quite a bit to learn).

- 39,056
- 9
- 76
- 93
-
so does that mean i cannot type a bunch of 0's and 1's into notepad, save, and get a program? all i want it to do is say Hi. – yourface Mar 16 '12 at 20:26
-
-
-
1@yourface: Notepad is already higher-level than `0`s and `1`s. You need a hex editor. – SLaks Mar 16 '12 at 21:18
-
Then why does 010010 make the equivalent of a pause command in cmd in the exe filw while other random combos dont? – yourface Mar 16 '12 at 22:58