Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question for Programmers and the Like
#6
First of all, CPUs do not understand languages like C or C++. They only understand the binary instruction set for that particular processor. Languages like C and C++ get turned into binary by a program called a compiler. A CPU has the ability to load and store values to and from memory as well as to and from locations inside the CPU called registers. Registers are faster than memory. A CPU has a special register called the instruction pointer. The instruction pointer is a number that refers to a location in memory. At the beginning of each clock cycle, the CPU does the following:

1. Load the instruction located at the memory location indicated by the instruction pointer.
2. Increment the instruction pointer so it refes to the next instruction.
3. Figure out what the instruction means and execute it. An instruction might be "Load the 4 bytes starting at memory location 1395739 and put them in register 6" or
"multiply the values in register 2 and register 6 and put the result in register 1" or even "change the value of the instruction pointer to 29832"


One way for the CPU to communicate with devices like a hard drive is to put certain values indicating commands or data in a special memory location and then send a signal to the device. The device can communicate with the CPU in a similar way, putting data in a special memory location and then triggering an interrupt, which makes the CPU stop its normal execution and start executing an interrupt handler. When the interrupt handler is done, the CPU goes back to what it was doing.


As others have said, an infinite loop does not destroy a processor other than the slow effect of normal wear and tear.
Reply


Messages In This Thread
Question for Programmers and the Like - by Khoi - 2010-10-29, 01:51 PM
Question for Programmers and the Like - by larmie - 2010-10-29, 02:06 PM
Question for Programmers and the Like - by Spaz - 2010-10-29, 03:34 PM
Question for Programmers and the Like - by Hazzy - 2010-10-29, 03:49 PM
Question for Programmers and the Like - by Fiel - 2010-10-29, 04:02 PM
Question for Programmers and the Like - by Spaz - 2010-10-29, 04:45 PM
Question for Programmers and the Like - by Nikkey - 2010-10-29, 05:23 PM
Question for Programmers and the Like - by Hazzy - 2010-10-29, 07:44 PM
Question for Programmers and the Like - by Eos - 2010-10-29, 09:56 PM
Question for Programmers and the Like - by Spaz - 2010-10-29, 10:28 PM
Question for Programmers and the Like - by Eos - 2010-10-29, 10:48 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)