The document discusses instruction sequencing and execution in a CPU. It explains that instructions are executed in a two-step process - fetching from memory then executing the operation. The program counter holds the address of the next instruction to fetch. It is incremented after each fetch so it points to the next instruction. Branch instructions can alter the program counter to change the linear execution sequence.
The document discusses instruction sequencing and execution in a CPU. It explains that instructions are executed in a two-step process - fetching from memory then executing the operation. The program counter holds the address of the next instruction to fetch. It is incremented after each fetch so it points to the next instruction. Branch instructions can alter the program counter to change the linear execution sequence.
The document discusses instruction sequencing and execution in a CPU. It explains that instructions are executed in a two-step process - fetching from memory then executing the operation. The program counter holds the address of the next instruction to fetch. It is incremented after each fetch so it points to the next instruction. Branch instructions can alter the program counter to change the linear execution sequence.
SEQUENCING • Instruction sequencing – The order in which the instructions in a program are carried out is known as instruction sequencing. – Normally the sequence proceeds in a linear fashion through the program, and the address of the instructions is obtained from the program counter in the control unit. – This sequence is interrupted when a branch instruction is executed; at such a time the address field of the branch instruction is inserted into the program counter and the process continues. Instruction Sequencing and Execution
• Execution of instruction is a two-step
procedure. In the first step, the instruction is fetched from memory. In the second step, the instruction is executed. • First Step-> Instruction Fetch First Step-> Instruction Fetch • The processor has a register named program counter which has the address of the instruction that has to be executed next. • To start the execution of a program, the address of first instruction has to be placed in the program counter. • After the address of first instruction is placed in the program counter, the processor uses this address to fetch the first instruction. • As soon as the first instruction is fetched the content in program counter is incremented by the word length (the group of n bits that can store a single, basic instruction) i.e. now, it has the address of next successive instruction to be executed. • After fetching the instruction from memory location it is placed in the instruction register of the processor. Second Step -> Instruction execution • In the second step, the processor examines the instruction present in the instruction register and find out which operation has to be performed. • It first fetches the operands involved in the instruction from the memory or processor register. Then the processor performs the arithmetic and logical operation and stores the result in the destination location mention in the instruction. • During this time the content of program counter is incremented so that it could point next instruction for execution. This execution of instructions in increasing order of addresses is straight line sequencing. Interpretation • Interpreter (Computing): – In computer science, an interpreter is a computer program that directly executes instructions written in a programming or scripting language, without requiring them previously to have been compiled into a machine language program. – An interpreter generally uses one of the following strategies for program execution • Parse the source code and perform its behavior directly; • Translate source code into some efficient intermediate representation and immediately execute this; • Early versions of Lisp (Locator / Identifier Separation Protocol) programming language and minicomputer and microcomputer BASIC dialects would be examples of the first type. • Perl, Python, MATLAB, and Ruby are examples of the second, while UCSD Pascal is an example of the third type. • Source programs are compiled ahead of time and stored as machine independent code, which is then linked at run-time and executed by an interpreter and/or compiler (for JIT systems). • Some systems, such as Smalltalk and contemporary versions of BASIC and Java may also combine two and three. • Interpreters of various types have also been constructed for many languages traditionally associated with compilation, such as Algol, Fortran, Cobol, C and C++. • While interpretation and compilation are the two main means by which programming languages are implemented, they are not mutually exclusive, as most interpreting systems also perform some translation work, just like compilers. • The terms "interpreted language" or "compiled language" signify that the canonical implementation of that language is an interpreter or a compiler, respectively. • A high level language is ideally an abstraction independent of particular implementations. • Types of Interpreters: – Bytecode interpreters – Threaded code interpreters – Abstract syntax tree interpreters – Just-in-time compilation – Self-interpreter