How are a indtrutruction of a program executed bye computer
Answers
Inside the CPU is a register called the program counter which always contains the address of the next instruction to be executed. The processor does the following:
It asks the memory to retrieve the value at the address in the program counter.Then it increments the program counter so it is ready to point at the next instruction.Then it executes the instruction.Then it goes back to step 1.This is called the fetch-execute cycle, and as long as the power is on, the computer is doing it.
So the next question is: How does the processor do all this? The CPU has two major parts: The control unit and the arithmetic and logic unit (ALU). The ALU is a bunch of circuits that can perform arithmetic operations (such as adding) and logical operations (such as bitwise AND). The control unit is also a bunch of circuits which can sends signals to all the other parts of the computer to tell it what to do. So basically control unit does something like this:
Tells the program counter to send the address in it to the memory.Tells the memory to send back the data at the specified address.Waits for the data to come back, then stores the retrieved instruction into the instruction register.Tells the program counter to execute.Looks at the op code in the instruction register and sends a series of signals to the rest of the computer to accomplish this instruction. These include:Read from or write to a register.Read from or write to memory.Read from or write to and I/O device.Tell the ALU to perform an operation, taking input from certain places and sending the output to certain places.And that is basically it. For more details, see any course or textbook on the subject called Computer Architecture.