Machine Language
Machine Language
CS500
Hypothetical Algorithmic Machine Architecture
Microprocessor: instruction set
• The microprocessor has a finite set of instructions (instruction set) that can be
performed
■
Machine Instructions as Bit Patterns
Both data and programs are stored in main memory in the same way as a stream of bits
The Instruction Set of the Hypothetical Algorithmic Machine
The Instruction Set of the Hypothetical Algorithmic Machine...
The Instruction Set of the Hypothetical Algorithmic Machine...
The Instruction Set of the Hypothetical Algorithmic
Machine...
Instruction: 156C
1 5 6 C
op-code
operands
LOAD R5 M[6C]
My Program
CU: Machine Cycle A2 1526
2 1- Fetching A3 2061
PC register A2
A4 3504
A5 C000
CU: Machine Cycle
3 2- Decoding
5 0 5 6
R0 1111 1100
My Program
PC register A3 A1 5056
A2 1526
A3 2061
A4 3504
A5 C000
Program Execution...
• To execute a program stored in main memory, the control unit of the CPU uses the
special-purpose registers to do the job.
• The first step is that the start address of the program, such as 156C in the main memory
should be placed in the “program counter” register by the operating system.
• Once the address of the first instruction to be executed is put in the “program
counter” register, the control unit starts a “repeating algorithm” called
“machine cycle”.
Program Execution: Machine Cycle
The machine cycle consists of 3 steps:
1. Fetch: which is fetching the instruction from the memory cell whose address is in the
program counter, and putting it in the instruction register. At the end of fetch step, the
program counter register is incremented to the next program instruction.
2. Decode: which is decoding the instruction contained in the instruction register and
analyzing its op-code field , and operand field.
3. Execute: after decoding the instruction, the control unit activates the required circuity to
perform the needed operation.
The fetch-decode-execute cycle continues until the “HALT” instruction is decoded in the instruction
register, then before completing its execution the machine is informed that the program is completed and
the machine cycle stops.
Program Execution: Machine Cycle...
Since the instruction in the hypothetical CPU is 16 bits, and the size of
each memory cell is 8 bits, then each instruction of the
program occupies two consecutive memory cells.