Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I write a program in binary directly ? How can I get the computer to execute it?

Tags:

binary

I know that may seem weird and looking for troubles but I think experiencing what the ancient programmers experienced before is something interesting. So how can I execute a program written only in binary? (Suppose that I know what I am doing and not using assembly of course.)

I just want to write a series of bits like 111010111010101010101 and execute that. So how can I do that?

like image 387
SteepCurver Avatar asked Nov 16 '10 17:11

SteepCurver


People also ask

Can you program a computer in binary?

Computer programs are sets of instructions. Each instruction is translated into machine code - simple binary codes that activate the CPU . Programmers write computer code and this is converted by a translator into binary instructions that the processor can execute .

How does a program become the binary code that a computer can execute?

The compiler and the interpreter are translational programs that take source code (programs made from high-level programming languages) and translate them to assembly language, which the assembler will then decode to binary. An interpreter will take one line of code and immediately execute it.

Can you code with just binary?

Of course. It's more commonly called machine code. It's basically assembly language without the mnemonic devices. Someone who knows assembly very well could program in machine code with additional effort, referring to opcode listings (e.g. x86) as needed.

Can you program directly in machine code?

While it is possible to write programs directly in machine code, managing individual bits and calculating numerical addresses and constants manually is tedious and error-prone.


1 Answers

Use a hex editor. You'll need to find out the relevant executable format for your operating system, of course - assuming you want to use an operating system... I suppose you could always write your own bootloader and just run the code directly that way, if you want to get all hardcore.

I don't think you'll really be experiencing what programmers experienced back then though - for one thing, you won't be using punch cards, paper tape etc. For another, your context is completely different - you know what computers are like now, so it'll feel painfully primitive to you... whereas back then, it would have been bleeding edge and exciting just on those grounds.

like image 141
Jon Skeet Avatar answered Sep 21 '22 05:09

Jon Skeet