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.)
-
This might be interesting for you: en.wikipedia.org/wiki/ExecutableHugo G– Hugo G2016-08-19 11:14:28 +00:00Commented 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!)S.V.– S.V.2016-08-19 11:16:14 +00:00Commented Aug 19, 2016 at 11:16
2 Answers
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.
1 Comment
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.