# How a computer really works

• jackson6612

#### jackson6612

Please remember I'm not a science or computer student - quite a layman in these areas. Please be as much explanatory as possible. Thanks.

I'm struggling to understand how a computer works at basic level. They say it's all about 0's and 1's for computers. But a computer is an electronic device, that means those 0's and 1's stand for something else. As some of my friends here have told me that it's the voltage. If the voltage is, let's say, below 2.5V, then it's 0, and if it's above 2.5V then it's 1, excluding 2.5V which doesn't stand for anything.

I was thinking when I press "A" on the keyboard, how it works. I have read somewhere that "0001" stands for "A". Okay, when I press "A" there is small switch underneath which is pressed, but then what does happen? How do I get A on the screen? What route does it take to reach on the screen?

I have many other questions of this type but I will first wait for an answer to the above.

Thanks for your time and time.

It's actually quite complex. Between the time you push the "A" key and the "A" appears on the screen, the computer is doing thousands of calculations at several different levels of complexity. If you really want to understand in detail what it is doing, you will have to methodically study how computers and electronic circuits work, and it will probably take months to years to answer your question. This might be a good place to start:

http://en.wikipedia.org/wiki/Computer

Hi Phyzguy

I would like to say something here. I understand what you're saying. Persons who have real understanding of their field have the ability to reduce/break down complex ideas into simpler ones. Sometimes, the very being discussed is not that much difficult but the approach and interpretation makes it real difficult. Einstein's theory of not difficult for their maths, they are difficult because they approach the motion and the space around us in entirely different way. That's why it looks contrary to common sense. But really good at those theories would know why ideas of relativity sound so weird when first mentioned. Well, a good teacher always knows what is troubling his students even when they couldn't frame their questions in a good way.
We only like to interpret ideas as we see it. The question I have asked is obviously difficult but I'm sure could still be addressed.

Best wishes
Jack

What exactly are you asking? If you want a high-level understanding of what a computer does, it sounds like you already have it. The computer stores the data as 1's and 0's, and when you hit the "A" key it does a series of logical calculations and writes an "A" to the screen. However, it sounded like you wanted to trace out in detail the entire sequence of steps between hitting the "A" key and the "A" appearing on the screen. If this is the answer you want, it will take quite some time, as I said. Of course, there is a whole sequence of possible answers in between that might satisfy you.

Assume a simple program that just displays the keys you enter onto the screen, in DOS mode, where the video is in a "text" mode.

The keyboard has it's own little computer that scans all the keys one at a time, completing a cycle every few milliseconds. When it sees that the "A" key has been pressed on a new scan, and that it wasn't pressed on a previous scan, it adds the "A" keys code into it's memory queue.

The simple program is in a cycle polling the keyboard to see if there are any keycodes in it's queue, and if so, transfers the keycode into the computer's memory. The keyboard's computer removes that keycode from it's memory when the keycode is transferred.

The program then converts the keycode into a display code for the monitor, and then adds the display code to the video cards screen memory.

The video card also has its own computer and in text mode, scans it's memory for display codes, which it translates into a pattern of dots to be left dark and to be lighted. The scanning actually takes place one "raster" line at a time. There may be up to 16 "raster" lines for a single row of displayed codes. In this case, the video card's computer does a scan for each "raster" line, reading the same display code memory 16 time in a row, and uses the relative raster line to index into a memory table that contains the dot pattern for the display code to show it on the screen.

Will attempt a real basic explanation. This however is not how it works at all (anymore) in a modern computer but things sort of started off in a similar way with keypads and displays. Only the principles here matter for you to form some sort of understanding hopefully.

The (example) keyboard is a grid of wires, say 5 rows and 20 columns (could be etched tracks on a printed circuit board). The wires in the grid don’t touch each other. At each intersection sits a key that you press (just a switch) which will short both wires to ground. Each wire is attached to 5V (through a resistor). The computer has a Central Processing Unit (CPU) that reads the columns and rows all the time. So the CPU reads all the rows and all the columns, sees that they are all at 5V (logic one), so for each row/column combination it can make a matrix (or array) of 5 x 20 in its memory and fill it all with ones (representing 5V).

When you press a key, both the column and row are shorted to ground (0 V), so the CPU now sees a zero in one of the rows and another zero in one of the columns. Say Z sits at position row 4 and column 2. After the CPU scanned the keyboard it now can place a zero in position (4, 2) in the array. Each position in the array refers to a letter or number (symbol). It now knows that you have pressed key Z. It has a lookup in its memory of symbol patterns that is selected by the row/column combination in the keyboard array. This causes the CPU to pass the binary (ASCII) code for the letter Z to another part of the CPU program that sends the Z to the Display.

A screen works in a similar fashion in that the screen is only rows and columns of pixels that can be off or on (black and white screen). The letter Z is an area of pixels that are switched on in a specific pattern to render the Z symbol. So the CPU instead of reading, now writes (or sends) the row, column information to the screen.

Wherever the column AND row are at 5V (or 1), the pixel is on, otherwise off. So you can see if you had a 640x480 screen there will be 640 columns and 480 rows. A symbol (like our Z) say occupies 10 columns and 15 rows of pixels on the screen. So when you press the Z the CPU then sends the 10x15 pattern off to the screen. The row and column offset will determine where on the screen the Z will appear. If it must be at row 100 and column 200, the CPU activates the area 100 to 115 of the rows and 200 to 210 with the Z pattern, and bingo you have a Z on display.

For colour there are red, green and blue (RGB) pixels overlaid with each other, with three Z patterns sent to render RGB Z.

The above is so far from what actually happens it is not funny, but the principles are important only. I hope that it intrigues you enough to do further study or reading.

The (example) keyboard is a grid of wires, say 5 rows and 20 columns (could be etched tracks on a printed circuit board). The wires in the grid don’t touch each other. At each intersection sits a key that you press (just a switch) which will short both wires to ground.
A bit off topic, but this wouldn't allow multiple keys to be pressed at the same time. Still since this is a question about how stuff works at a low level ...

Generally pressing a key just makes a connection between two wires in the matrix. There's an issue that if 3 keys are pressed, a "phantom" 4th key could appear to be pressed (on 2 rows and 2 columns). Adding diodes to each key eliminates this problem. On matrix type keyboards without the diodes, one way to deal with this is if 3 or more keys are pressed, is to wait until 2 keys or less are pressed, then note the release order of those final 2 keys and use that order as the key press order. This allows key stroke rollover, for example, it's common for a typist to overlap keystroke on certain patterns, like "ion". Also <alt> <ctl> <shift> are usually setup outside the main matrix with their own control line so they can pressed at the same time along with the primary keys in the matrix.

Some cheap keyboards will not allow more than 2 or 3 alpha numeric keys to be pressed at the same time, mostly an issue for games that use keyboard as primary input.

An alternative is to simply have a separate pair of wires for every key, in which case the number of keys pressed at the same time doesn't matter.

Last edited:
Please remember I'm not a science or computer student - quite a layman in these areas. Please be as much explanatory as possible. Thanks.

I'm struggling to understand how a computer works at basic level. They say it's all about 0's and 1's for computers. But a computer is an electronic device, that means those 0's and 1's stand for something else. As some of my friends here have told me that it's the voltage. If the voltage is, let's say, below 2.5V, then it's 0, and if it's above 2.5V then it's 1, excluding 2.5V which doesn't stand for anything.
Amazingly enough, I think I understand what jackson6612 is asking and, if I'm right, everyone's answers have been way too high level and abstract. I think jackson6612 is asking about the implementation details of how a computer works so that he can, in principle, build his own computer (not that he intends to but this is the level of understanding I think he seeks). I used to wonder this and even did so long after I had learned to program a computer which goes to show how far removed computer programming is from computer engineering...

In order to fundamentally understand how modern computers are implemented, you need to understand a long list of things. First, you need to learn boolean logic. Then, you need to learn some basic electronics. Then, you need to learn how to construct logical circuits that perform said boolean logic with said electronics. See how it all ties together? Really, all computers do is this boolean logic...

We can start with the first topic: boolean logic. Really, all you need to understand is that the most basic unit of information digital computers use is the bit and they perform three different operations on bits: and, or and not. There are a couple other operations but they can all be built from these three basic ones...

Once you understand boolean logic, then you can move on to learn how to implement them using some simple electronics. Since you just want to understand the basic principles, you can make this really simple by assuming zero resistance conductors and perfect diodes and transistors. The electronic implementation of these logical operations are called gates...

Only after learning all this will you be in a real position to understand how to build a digital computer. With these simple gates and a clock, you can build memory and a processor to operate on said memory...

...and you will have yourself a computer...

I was thinking when I press "A" on the keyboard, how it works. I have read somewhere that "0001" stands for "A". Okay, when I press "A" there is small switch underneath which is pressed, but then what does happen? How do I get A on the screen? What route does it take to reach on the screen?

I have many other questions of this type but I will first wait for an answer to the above.

Thanks for your time and time.
You will likely have a lot to learn before something this complicated can be explained to you in the manner that I think you're looking for...

Go on, let me throw my two penneth worth into this. Firstly, I would stress, I am only surprised by just how good a job some of the guys above have done of packing a great deal of insight into relatively short posts. But the first point I would make is that you do not need to understand the first thing about electronics to understand the basic principle of how a computer works. I recall, in physics lessons in my days at school, we used to have these boards; they were a couple of feet square I suppose, with a grid of upright spring loaded contacts in a square grid arrangement. You then had a store full of connectors and batteries (cells of course!) and lamps and such like with which you could build different circuits. You could test out the effects of different resistances connected in series and parallel and such like. You could, with these components, build AND gates and OR gates and NAND gates and NOR gates. You could demonstrate how such components could be used to do simple addition and subtraction and then, by ingenious techniques, multiplication and division. So electronics are just the mechanism by which desk top computing devices have become a practical reality. The techniques of using electrical circuitry to do number crunching are not dependant on electronics. And understanding how doing nothing more than number crunching, which is all computers do, enables computers to do the myriad different tasks of which they are capable is something else entirely.

Thank you very much, Phyzguy, Rcgldr, CyMark, Jocko, Ken. I have to say, Jocko, you have hit the nail quite on the head. Ken, you were also good.

I have still many questions to ask, so as soon as I get the proper wording for them I would post them here. Once again, thanks a lot.

Negatron: Thanks for the book recommendation.