The role of machine code in the execution of a program
Machine code and CPU operation
Instruction format
- An instruction is the command given to the central processing unit by a computer program
- Instructions are made up of an operation code and a memory address
- An operation code is a machine lanugage command for a single operation
- The control unit inteprets this code to determine the appropriate action
- The CPU contains permenant microdcode instructions which cannot be modified
Use of registers and accumulators
- A register is a temporary storage location within central processing unit
- Any data leaving the main CPU goes through the register buffer
- An accumulator is a register which stores the result of the latest computation carried out by the CPU or the last data that is about to be computed
- After being in the accumulator, the data must be moved to a different memory location
The fetch-execute cycle
- The fetch-exexute cycle is sperated into four steps:
- Fetch instruction from primary memory and place in instruction register
- set program counter to the next instructions adress
- Decode the instruction (done by control unit)
- Load operands from memory into a register
- Execute the instruction and store result in accumulator (generally the ALU will execute the task)
- Reset the cycle to recommence the cycle
Use of a program counter and instruction register
- The program counter is a register that is part of the computers CPU
- The program counter stores the address of the next instruction to be executed
- Instructions are generally stored sequentially unless the instruction is to change the program counter
- The instruction register is where the instruction either being decoded or executed is stored
Execution of called routines
Linking, including use of DLLs
- Linking alllws for a machine code program to be combined with another machine code porgram
- Because larger programs are modular in nature, the linker is used to join these modules
- Since programs must be in the RAM to be executed, linkers save resources because only the needed modules are loaded
- DLL’s or Dynamic link libraries is a library of machince code programs which can be accessed by others to perform specific tasks
- DLL files allows programs common acess to resources and provide efficent use of the memory