The role of the cpu in the operationPresentation Transcript
The role of the CPU in the operation of software Mary Ramsay
Fetch and Execute Cycleinstruction and decoding of software solutions
Fetch-Execute Cycle:- describes the manner in whichthe processor works. That is, it fetches the instructionfrom primary storage, decodes the instruction, executesthe instruction and stores the result.
The CPU is made up of different parts including:ALU – performs the arithmetic and logical operationscarried out by the processor.Registers – (memories) which provides areas to storeresults, locations of instructions. An Accumulator is oneregister which stores the data currently being processed.(like the display of a calculator)Control unit – This coordinates all the actions of theprocessor.
Specific CPU components – Programcounter Is a type of register that stores the location of the next instruction to be processed. The program counter is just like a counter used in an array. (used to located an array element) The program counter is used to locate the next the instruction and then the counter is increased (incremented) to point to the next instruction. See page 149 of text book.
LinkingWhen a program requires a par0cular sub program, its address is incorporated into the program by a translaon system called a linker. Many programs are complied at a modular level (mainline) and sub modules. A linker is used to join these compiled modules together. A linker is like calling a module that needs to be processed by the CPU. For example 1. A program is complied and translated into machine code (exe) 2. The machine code is loaded into main memory to be executed. 3. The mainline is executed ﬁrst – with the use of a linker only the modules required are loaded into RAM. (This reduces the amount of instruc0ons loaded into RAM at one 0me) 4. The linker also used for library rou0nes. If the program calls a library rou0ne it is only called and loaded into main memory when required. Again this saves memory resources.
DLL’s (Dynamic Linking Libraries Is a collec0on of programs in machine code which can be accessed by other programs to perform a speciﬁc task. E.g prin0ng – when a user chooses to print the CPU will look in the DLL ﬁle to get the saved machine code (instruc0ons) to print rather than searching the translated code. The DLL ﬁle is loaded into RAM instead. As a result processing and RAM resources are minimsed.
Translation methods in software solutions
Advantages of a compiler} Compiled programs will run faster than those that have been interpreted as they are already in a form that the processor understands. } Compiled programs hide the code from view so that it is more diﬃcult to determine the algorithms used. } A compiled program is oTen a lot smaller that the high-‐level code that generated it. } A compiled program cannot be easily modiﬁed by an inexperienced user.
Disadvantages of a compiler} Run-‐0me errors are not apparent un0l the program has been completely compiled. } When a compiled program is modiﬁed, the whole of the program has to be re-‐compiled, regardless of the nature of the modiﬁca0on. Even if a minor modiﬁca0on is made, the whole program has to be re-‐compiled. This can make the tes0ng process tedious.
Advantages of an interpreter} • During testing, both run-time and translation errors become apparent as the code is} being executed. These errors may then be corrected as they are found. This allows the} programmer to more quickly debug a program, as the code does not need to be} completely translated after the changes have been made.} • The process of interpretation also allows the programmer to quickly add and remove} debugging aids such as flags and debugging output statements.
} Disadvantages of an interpreter} • Programs that are interpreted will run far more slowly than those that have been} compiled, as each line of code has to be translated before it is executed.} • The code of an interpreted program is easily accessible to any user or other programmer.} This means that the illegal use of modules is easier.} • Programs that are interpreted will generally take up more storage than a similar program} that has been compiled.
Advantage of an incremental compiler} Programs will run faster than those of an interpreter; however, the incremental compiler retains the advantage for a programmer that both run-‐0me and syntax errors can be iden0ﬁed as they are reached. Disadvantages of an incremental compiler } Programs are not executed as quickly as for a compiled program. } Code is s0ll accessible to users and others.