A program consisting of the memory unit of the computer includes a series of
instructions. The program is implemented on the computer by going through a cycle for each instruction. In the basic computer, each instruction cycle includes the following steps: It can fetch instruction from memory. It is used to decode the instruction. It can read the effective address from memory if the instruction has an indirect address. It can execute the instruction. After the following four procedures are done, the control switches back to the first step and repeats the similar process for the next instruction. Therefore, the cycle continues until a Halt condition is met. The figure shows the phases contained in the instruction cycle. Basic Instruction Cycle • Instruction Address Calculation − The address of the next instruction is computed. A permanent number is inserted to the address of the earlier instruction. • Instruction Fetch− The instruction is read from its specific memory location to the processor. • Instruction Operation Decoding − The instruction is interpreted and the type of operation to be implemented and the operand(s) to be used are decided. • Operand Address Calculation− The address of the operand is evaluated if it has a reference to an operand in memory or is applicable through the Input/Output. • Operand Fetch − The operand is read from the memory or the I/O. • Data Operation − The actual operation that the instruction contains is executed. • Store Operands − It can store the result acquired in the memory or transfer it to the I/O. Interrupt An interrupt is a signal from a device attached to a computer or from a program within the computer that requires the operating system to stop and figure out what to do next. Whenever an interrupt occurs, it causes the CPU to stop executing the current program. Then comes the control to interrupt the handler or interrupt service routine. The steps in which ISR handle interrupts are as follows − • Step 1 − When an interrupt occurs let assume processor is executing i'th instruction and program counter will point to the next instruction (i+1)th. • Step 2 − When an interrupt occurs the program value is stored on the process stack and the program counter is loaded with the address of interrupt service routine. • Step 3 − Once the interrupt service routine is completed the address on the process stack is popped and placed back in the program counter. • Step 4 − Now, it executes the resume for (i+1)th line. Multiple interrupts • Multiple interrupt is an interrupt event which can occur while the processor is handling a previous interrupt. • Ways to handle interrupts • Disable interrupt • Define priorities Instruction Cycle with Interrupts Distinction between Hardware Interrupt and Software Interrupt