2

I would like to get a feel of how computers originally worked. I know initially with computers such as ENIAC, they physically had to plug in wires in the correct order to make their programs execute. They later used punch cards and finally then came up with assembly language(s). It just build upward from there with FORTRAN, COBOL, etc. Is there any way I am compile 0s and 1s on my computer. If I open textedit, and type in a specific sequence of zeroes and ones, then is how can I make that a binary file and not a text with a sequence of ASCII characters? I am open to any method. (Disclaimer: I know doing things in binary takes forever, I just want to learn how to very basic things.)

2
  • This might be interesting for you: en.wikipedia.org/wiki/Executable Commented Aug 19, 2016 at 11:14
  • Yes! There are many fun ways to do this. But coding in binary probably is going to kill your face and make you just give up. I personally recommend writing a bit of assembly code. Here's a nice tutorial on ASM. Here's A question related to learning assembly (lots more resources!) Commented Aug 19, 2016 at 11:16

2 Answers 2

3

The easiest way to do this is to start with an assembler of your choice, in an IDE if you like. Use some sort of debugger (such as an IDE) so you can see the effect of your code without also having to write to console or file.

Rather than writing only binary as text digits, write a complete assembler source using data elements instead of instructions.

So, instead of

.code
main proc
    mov eax,5               
    add eax,6               
main endp
end main

you could write:

main proc
    db 10111000b, 00000101b, 00000000b, 00000000b, 00000000b
    db 10000011b, 11000000b, 00000110b
main endp
end main

db means define byte and the b suffix means binary.

And, with this, you'd be all set up to cheat, but I won't tell you how until you ask so I don't spoil the fun for you.

Here is a good tutorial for getting started on Windows with MASM and Visual Studio 2015.

Sign up to request clarification or add additional context in comments.

1 Comment

This was a good answer as well, but at the time it broke my mind.
1

The way to create a binary data stream depends heavily on its purpose.

Binary data itself is not much of magic. You can take any hex-editor and start typing the desired binary input.

But this is not how computers are programmed nowadays. If you really want to go to the lowest level, you can have a look on assembly programming, which basically allows you to tell your machine the exact instructions it should execute in a more handy way.

But even here you won't have much fun. If you want to be able to actually execute your programs and see some results on your display or perhaps even things like keyboard input, the code would grow really large and hard to write and understand for humans.

This is why we use compilers. Compilers generate such code from a high level language and eliminate the need to write the smallest instruction blocks over and over again.

If you really just want to understand how computers work in principle, download some emulator for a simple CPU (perhaps with a nice GUI) and play around with it. Edumips is one of those emulators for educational purpose.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.