Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How do computers 'interpret' machine language?

  1. Jul 20, 2016 #1
    Eventually at some level commands will have to be converted into something a non-sentient device can respond to. My understanding is that computers are essentially a big network of switches. So how is machine code (I think basically a file containing bits of information representing a series of on-off signals) turned into a physical response within the computer? I guess you could ask the same thing about human brains, but since we have actually built these things I'm guessing we also know how they work.
    Thanks.
     
  2. jcsd
  3. Jul 20, 2016 #2

    jedishrfu

    Staff: Mentor

    Each opcode isn't arbitrarily assigned, some bits select the operation like load or store or add ... and others select the CPU register or if memory is to be accessed and how i.e. Indexed by a register or register plus offset... There are several addressing modes usually.
     
  4. Jul 20, 2016 #3

    berkeman

    User Avatar

    Staff: Mentor

    As jedishrfu says, many of the words read from memory by the CPU (central processing unit) are Opcodes. That means they are instructions for what the CPU hardware should do in the next clock cycle. They can cause a read from a memory location into one of the Adder circuit registers, for example, which you would follow with an Opcode to read a different memory location into the other Adder register, followed by an Add command, followed by a Store command to put the result into some other memory location.

    This web page provides more details, and a Google search can yield lots more examples:

    http://homepage.cs.uri.edu/faculty/wolfe/book/Readings/Reading04.htm
     
  5. Jul 20, 2016 #4
    Thanks both. From the link:

    "The arithmetic/logic unit can perform four kinds of arithmetic operations, or mathematical calculations: addition, subtraction, multiplication, and division."
    These are just the circuits you learn in electronics class? If so, that's actually pretty cool.

    "The control unit decodes the instruction (decides what it means)..."
    This is actually what my question is really about. I guess it boils down to how does the CPU know how to interpret these opcodes. At some point you have to have: if signal X -> do Y, where X is an opcode and Y is the output operation. But what is the ->
     
  6. Jul 20, 2016 #5

    berkeman

    User Avatar

    Staff: Mentor

    Are you familiar with logic gates and flip-flops (FFs)? Those are the basic building blocks for the circuitry of the CPU and ALU. If not, you could read about them at wikipedia to start to get a basic understanding that you can then build on. :smile:
     
  7. Jul 20, 2016 #6
    Hey, its important to remember that the information level is an abstraction of underlying physics. The underlying physics do the work. The underlying physics are those of semiconductors, materials that act special ways with electric current. Simply, think 1 means current on, 0 means current off. Current can do things like turn on lights and run motors because of physics. The gates have their own current besides the information current, so you can have things like a NOT gate, where current in means no current out, and no current in means current out. At the end of the day computers are just electric, like a lamp or radio.
     
  8. Jul 20, 2016 #7

    berkeman

    User Avatar

    Staff: Mentor

    Actually, it's better to think in terms of voltages for logic levels rather than currents. Especially for CMOS devices, current (mostly) only flows during logic voltage level changes. Just think of the "1" and "0" states of FFs. There is basically no current flowing in either state. :smile:
     
  9. Jul 20, 2016 #8
    Thanks for the clarity on how modern devices work. My point is just to make a crude sketch though: A digital circuit works by logically directing electricity to do things. The inputs decide where the electricity goes. That's how a CPU "intereprets" inputs.
     
  10. Jul 20, 2016 #9

    rcgldr

    User Avatar
    Homework Helper

  11. Jul 21, 2016 #10
    Once you figure it out, you can test your knowledge by building one of these ;)

     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: How do computers 'interpret' machine language?
  1. Computer languages (Replies: 6)

  2. Computer language (Replies: 4)

Loading...