Computer question.

Ok, I’m into programming. I do it as a hobby now, but I plan to do it for a living after I get my degree. The question I have is probably extreamly difficult to answer (I’d ask the people at Intell but I doubt I’d get an answer), but my wife keeps bragging about how smart everybody here is, so if anybody can answer my question (other than Intell workers), you guys can.
Oh, and please, try stating this in layman’s terms, nice plain english, if at all possible. I hope this question makes sence.
To ask my question, I’ll have to state some things that are obvious to programmers.
Ok, now, what programmers see as computer commands, the computer sees as numbers, representing the amount of electricity in a memory cell (that may not be precisely right, but it should be close). For example, this simple DOS ASM program that turns on the mouse:
mov ax, 1
int 33H
first, move’s 1 into the ax register, then jumps to interrupt 33H by looking up its address in the interrupt vector table, then jumping there,
is stored in the computers memory as (in hexidecimal notation)
B8 01 00 CD 33
Now I know the computer reads the bits of each byte, so the computer sees:
Ok, now for the hard part. The program is loaded cs:ip is set to the begaining of the program. From the CPU standpoint, what happens next? How do the series of on’s and off’s actually accomplish anything? When the CPU is reading memory, and getting the code and data, how is it that a series of on’s and off’s cause stuff to happen? I have an idea that it has something to do with directing electricity to certain locations within the computer, such as, when you plot a pixel on the screen then maby you’re sending an electrical current to a memory loction that’s read by the monitors light gun every time it refreshes the screen. Of course I could be way off. Ok, I’ll stop now, as you can see, the question is so hard for me to think about, that it’s hard for me to ask properly. If any of you think you know what I’m trying to get at, please try to answer my question. I hope this hasn’t been to confusing. Thanks in advance.

It’s magic.

So you are basically asking how a microprocessor works? As I understand it, the basic building blocks of microprocessors are logic gates and flip-flops. Examples of logic gates are AND gates and OR gates. An AND gate outputs 1 (high, or on, usually 3 or 5 volts) if both of the two inputs are 1, and 0 (zero volts) if either is zero. An OR gate outputs 1 if either of the inputs is 1. If you combine them, you can make any circuit as long as there is only one possible output for a set of inputs. For example, you can build a circuit with 16 input signals, treat it as two 8-bit binary numbers, and output the sum of the two numbers as an 8 or 9 bit binary on 8 or 9 wires. You probably need hundreds of gates to do just that, but you don’t need anything else.

But if you only have gates, all it can do is take one set of inputs and output one set of outputs. You also need something which makes it go on to do the next job. The basic component for this is a flip-flop. The simplest flip-flop has one signal input D, one clock input C and one output Q. The output Q only changes when C makes a 0 to 1 transition. That is, it is edge triggered. When the flip-flop sees an edge, it sets Q to what D was just before the clock edge. (You can even connect the Q back to its own D input; the output alternates between 1 and 0 at each clock edge.) So the next state of the system is determined by the previous state of the system.

Now, if you combine those two types of components, you can imagine a circuit which, when it receives a clock edge, looks at all the inputs (mostly outputs from itself as well as outputs from memory chips and I/O components) and sets the next state of the system depending on a whole bunch of rules hard-wired by the logic gates. This “next state of the system” includes commands to the memory chip to output the data in certain cells, which it then reads on the next cycle.

That’s more or less an extremely simplified view of how a processor works. I’m sure others can fill in the details or correct any mistakes I’ve made.

Oops, I made a mistake about flip-flops. For the output to alternate on each clock edge, you need a NOT gate (output 1 if input is 0, output 0 if input is 1) between the Q and D.

As SCR4 noted you’re asking for a concise answer as to how a system works that is among the most complex manufactured products on earth and has layers of sophisticated micro-electronic hardware and micro code between what you type in as programming commands and how they are actually implemented down at the circuit level. This is difficult to do in a newsgroup forum without writing a book on the subject (which is really what you need).
Per your original caveat about Intel, for a general overview you should have tried them first.


How Transistors Work
How Microprocessors Work
A History of the Microprocessor
How Chips Are Made

Good luck with your goal!

I am an electrical engineer but I would have to write a book to explain this. I do not think anyone can fully answer that in a short post here. My recommendation is that you find a good book that explains it. And forget about learning it all in half an hour. This is major stuff.

This is certainly interesting stuff and I would not want to put you off persuing it. I would caution you, as a prospective programmer, not to get bogged down in this level of detail though.

Software can be appreciated at many levels of abstraction and it is an important skill as a programmer to be able to be able to seperate these levels and choose the appropriate one in which to work. An understanding of the level below the one you are working can often be a boon just so long as you do not get the levels mixed up. I learned a little assembler and, although I have never needed to use it for real, the experience is useful in my understanding when I come to use higher level languages.

In your goal to become a programmer by all means delve into the lowest, murkiest details. But also pay attention to the more abstract challenges. For most programming details of the machine are unimportant and the future is in OO languages such as C+, Java, Eiffel etc.

Thanks for all your answers. Yeah, I figured it would be extreamly complicated. I know that knowing how the computer uses code to operate isn’t that important, but seeing as how just trying to think about it is mind boggling to me, I was just curious if any of it could be somewhat simplified into terms I could understand. Anyway, I guess I will have to start reading up on it to satisfy my curiosity. Thanks.

It might be too basic for you, but I liked The Pattern on the Stone, by Daniel Hillis.

Seven words for you:

“Structured Computer Organization” by Andrew S. Tannenbaum.

If you’re going to hack computers for a living, you’ll never regret studying this one.

S. Norman

Are you just asking why a CPU uses binary code to accomplish whatever it needs to accomplish? Because if so, it’s all a matter of what it displays on the monitor. You were on the right track in the OP.

When it is at 0, that given pixel on the monitor is not in use. Reciprocally, when at 1, that given pixel is in use. Of course, a combination of those 1s and 0s make up whatever is displayed on the monitor.

Except that computers were using binary code long, long before they even had monitors (that’s right… As late as 1979, a monitor was considered a “recommended acessory”). The computer frankly doesn’t give a damn what’s actually showing on the screen (try turning your monitor off sometime; no problem), and only rarely even cares what the video card is trying to tell the screen. The reason is the logic gates and memory storage, which are both much simpler in base 2.

The reason I asked my question doesn’t have to do with monitors at all. A while ago, I just started thinking, how do the 0’s and 1’s, or on’s and off’s, accomplish anything? Do they direct an electricity flow, or what? I mean, so you have values in the computers memory, or ports. How do the different levels of electrical current make the computer do anything? And I was asking here because I was hoping I could get the answer in laymans terms, as opposed to reading a technical manual which would leave me more confused than before I started reading it. Anyway though, I guess reading a manual is what I’ll have to do, although some of the answers given, such as the use of logic gates, helps a little.

*Joel: Ok, I’m into programming. I do it as a hobby now, but I plan to do it for a living after I get my degree. *

Question: what degree are you getting? I learned how a computer interprets binary codes into actions in my sophomore year Computer Architecture class. This was required for a BS in Computer Science and Mathematics.

Try search for ‘computers’ or microprocessors, etc.

Didn’t Gates one time try to trademark 1’s & 0’s?

Just to let you know, Joel, you’re pretty much on the right path with the ‘electrical signal routing’ conjecture. Of course, at the base level, that might be too general a way of explaining it, like saying that an automobile works by routing mechanical signals (I turn the steering wheel, the wheels move, I press the accelerator pedal, stuff happens in the engine). The internal computation, and how it’s accomplished, is indeed the stuff of a course or full book. (If you have the option, do take an architecture or digital systems course – I think it will help a lot.)

On a grand scheme, there’s basically input, output, and computation. By input and output I mean the things that enable human interaction; an overly generic term is transducer for anything that converts one type of signal to another, esp. electric (e.g. a keyboard converts mechanical signals to electrical). Output devices work in the other direction, of course. With digital computers, the signals must be converted to/from digital signals, which are a set of switch states.
Again overgeneralizing, the switch states indicate what the next switch states will be; with either I/O or computation, the design indicates that switch states lead to others that can be interpreted as meaningful.

I say ‘interpreted’ since the computer doesn’t really deal with 1’s or 0’s; we say it does, but that’s because we call one state (usually voltage at some level) 1 and another 0.
At this point, I’m probably headed towards some awkward AI/philosophical problems about mind, etc. so I’ll leave it at that.

panama jack

It’s been a while since x86 assembly, but I’ll try (should really wait till I can get home and explain it in detail). With the CISC chip you’re using, it reads the first portion of the instruction, which then tells it what is expected by the instruction (the length of it, the parameters). The instruction itself is built into the CPU, so that series of bits tells it to look up a more complex bit of hard-wired gates that then do whatever the instruction needs to do (call other parts of the chip, access devices, send stuff to a device)
In the case of the mouse, it would read the signals coming from the mouse, and probably store it in a register (AX?). In the case of the monitor, if you already had the data segment pointer pointing to the appropriate part of memory that you were wanting to write to the video buffer, and some other (AX?) pointing to the video buffer, those bits would in a series of instructions flip through a logic gates on the CPU, open a connection to the memory location, read the contents, open a connection to the video buffer, and write it there. The instructions there would be converted into varying field strengths that would direct the electron beam to point to different portions of the screen, or turn it on and off (all this depending on type of monitor).

Anyway, why do you care? You want to do chip design? In many cases, that’s been abstracted too…

Joel, it has everything to do with monitors.

I’m sure you know that a monitor’s screen is made up of lots of pixels. An electrical current fills that pixel with a given color, thus the 1. When a pixel does not need to be filled, there is no need for that electrical current, hence the 0.

Was that a joke, vandal? :slight_smile:

Si, Kyberneticist. :slight_smile: