I've been searching a lot lately about binary and how a computer actually works so i figured assembly and the assembly board is the best place to start with my question. Generally, I want to know, how does a computer actually work? I understand the C++ that I've been actually programming in, and I slightly get the hint of addembly that I've read, but then I ask myself, how does the computer actually use this? The answer I always find is, "it turns it into a binary file that can execute on the computer". Now so far, I understand, were I get lost is, how do you actually instruct a computer to realize human concepts? I was pondering the "loop" in real life it makes sense, "keep doing something, dont stop" but in 0's and 1's where all you can make is letters? and numbers? how does the computer even understand that? I know that A. this is beyond my skill set(but if I can explain a cars complete function in a paragraph, I think we can do a CPU in 5 pages or less) B. I'm really stupid for wanting to know something as complex as this, but I have to understand, I also firmly believe it will help me in my future endeavors with programming, any help is appreciated.

Recommended Answers

All 5 Replies

First of all, you aren't stupid for wanting to know that. Curiosity is a good thing, because it helps you learn new things :)

The CPU processes machine code. The machine code is (obviously) architecture specific (there are many architectures, like x86 or x86_64). An assembler or a compiler translates your "readable" code into machine code. There are a lot of things related to CPU (like cache, main memory and buses). Machine code consists of bytes that a CPU understands. Bytes consist of (8) 0's and 1's (0 is "low" voltage and 1 is "high" voltage).

If you want to find out how your code is executed (the code you compile and link) I think you should start with operating systems. Operating systems provide a lot of abstractions (depends on design), so the machine code generated by an assembler or a compiler has a header that defines things an OS understands and uses to set up necessary things for the executable. (Google OS concepts)

In a short definition, an (x86) OS kernel is loaded by a Bootloader, which gets necessary info from 16-bit processor mode (yes, x86 processors start in real mode), loads the kernel, switches to 32-bit mode (protected mode), then jumps to the kernel. A kernel sets up the "basic basic" things for an OS. Some of those things are memory management, scheduling, interrupt handlers (OSes process exception interrupts) and a lot more (depends on kernel design).

Basically, there are 3 major kernel designs:
1. Monolithic kernel (drivers/servers reside in the kernel space; kernel provides a lot of abstraction)
2. Micro kernel (drivers/servers reside outside in the user space; kernel provides less abstraction)
3. Hybrid kernel (a compromise between the forementioned structures; mixed)

I know everything I wrote is a bit chaotic and some professionals might point out some errors (though I think everything above is true). I'm not even on a university. Internet knowledge :)

venomxxl thanks but i want to know even deeper, and rubberman i appreciate the links, but i dont understand a lot of the things they say its pretty much like "photo interference sub-reactor double torsion undertoe" or something i just cant grasp my mind around sentances with 50 vocab words in each one, those wiki pages would take a week each, i mean does anyone know how 01001100 can make a current go to 01011001, my thing is how do you TELL something that just turns on and off really quick how to understand flow and loops and holding ideas and recalling them? these are all so abstract that it just seems impossible to people who dont know how it works

The deepest level is the electronics. If you don't want to go that deep into the electronics, you might want to consider reading through those links rubberman provided. If you have problems understanding them, you can always Google the terms you don't understand (or search through Wikipedia). You could also search for some lectures about things you want to learn about.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.