ECE 445 - Fall 2020 - Lecture 4 - MIPS Machine Language and Program Execution
ECE 445 - Fall 2020 - Lecture 4 - MIPS Machine Language and Program Execution
Topics Covered
• MIPS Machine Language Instructions
• R-type, I-type, and J-type Formats
• Conversion from assembly language to machine language
• Conversion from machine language to assembly language
• Program Execution
• High-level and Low-level languages
• Compiler, Assembler, Linker, and Loader
• Instruction Cycle
Fall 2020 ECE 445 - Computer Organization 3
Reading Assignment
• Hennessey/Patterson: A.10
• Hennessey/Patterson: 2.1 – 2.7
• Additional reading posted on Blackboard.
Fall 2020 ECE 445 - Computer Organization 4
Machine Language
• Low-level programming language.
• “close to” the hardware.
• Architecture dependent.
• Processor specific.
• Cannot be executed on a different processor.
31 26 25 21 20 16 15 0
opcode Rs Rt immediate I-type
31 26 25 0
opcode address J-type
R-type: Opcode bits [31 – 26] + funct bits [5 – 0] are used to specify the instruction
I-type and J-type: Opcode bits [31 – 26] are used to specify the instruction
Fall 2020 ECE 445 - Computer Organization 7
31 26 25 21 20 16 15 11 10 6 5 0
0 17 9 16 0 32
opcode Rs Rt Rd shamt funct
31 26 25 21 20 16 15 11 10 6 5 0
0x02298020 (hexadecimal)
Fall 2020 ECE 445 - Computer Organization 8
8 20 10 27
opcode Rs Rt immediate
31 26 25 21 20 16 15 0
001000 10100 01010 0000000000011011
0x228A001B (hexadecimal)
Fall 2020 ECE 445 - Computer Organization 9
4 17 18 3
opcode Rs Rt immediate
31 26 25 21 20 16 15 0
j L2
mnemonic
Fall 2020 ECE 445 - Computer Organization 12
31 26 25 0
Exit: … 80024
Fall 2020 ECE 445 - Computer Organization 14
PROGRAM EXECUTION
Programming languages (high-level, assembly, machine)
Compiler, assembler, linker, and loader
Instruction cycle
Fall 2020 ECE 445 - Computer Organization 15
Program Execution
• The processor executes machine language (ML) instructions.
• Stored program computer
• ML instructions are stored in program memory, each at a specific address.
• Each instruction must be fetched from memory before it can be executed
by the processor (CPU).
Fall 2020 ECE 445 - Computer Organization 18
Program Execution
• The processor executes machine language (ML) instructions.
• Special purpose registers
• Program Counter (PC): stores the address of the instruction to be fetched.
• Instruction Register (IR): stores the instruction to be executed by the CPU.
Program Counter
Instruction Register
Fall 2020 ECE 445 - Computer Organization 19
Program Execution
• Each machine language instruction is processed according to
the steps in the instruction cycle.
• Aka. the fetch-execute cycle and the CPU cycle.
Instruction
Fetch
Instruction
Decode
Execute
Instruction Cycle
Fall 2020 ECE 445 - Computer Organization 20
Instruction Cycle
• Each machine language instruction is processed according to
the steps in the instruction cycle.
IF
Instruction Fetch
• PC contains address of ML instruction.
• Read (fetch) instruction from program
memory at address pointed to by PC.
ID
• Adjust PC to point to next instruction.
• Increment PC (by 4 for MIPS)
• Use Branch target address
Instruction Cycle
Fall 2020 ECE 445 - Computer Organization 21
Instruction Cycle
• Each machine language instruction is processed according to
the steps in the instruction cycle.
IF
Instruction Decode
• Instruction is identified by the opcode
(and the funct bits for MIPS R-type
instructions).
ID • Control unit decodes instruction.
• Appropriate control signals are generated.
• Control the functional units in the datapath
Instruction Cycle
• Each machine language instruction is processed according to
the steps in the instruction cycle.
IF
Execute
• Functional units in the datapath
implement the required actions for the
executed instruction.
ID • Functional units controlled by the control
signals.
• Different instructions require a different set
of actions and, thus, a different set of
EX functional units.
Instruction Cycle
Fall 2020 ECE 445 - Computer Organization 23
Questions?