Chapter 2
Instructions: Language of the Computer
Machine Language and Assembly Language
Instruction Set
Three Other Popular Instruction Sets
�Stored-program Computer Concept�
�Operations Of The Computer Hardware�
add a, b, c
The above means add b and c and put the result in a
Three Underlying Principles Of Hardware Design:
The MIPS Instruction Set
Chapter 2 — Instructions: Language of the Computer — 8
�MIPS Assembly Language�
The MIPS Assembly Language Notation
MIPS Notation
Arithmetic Operations
add a, b, c # a gets b + c
Chapter 2 — Instructions: Language of the Computer — 12
Example of Compiling Two C Assignment Statements into MIPS.
Basic Instruction Execution
���Example 1 of compiling a complex C assignment into MIPS.���
Examples
MIPS Continued
Register Operands
MIPS operands
Register Operand Example
f = (g + h) - (i + j);
add $t0, $s1, $s2�add $t1, $s3, $s4�sub $s0, $t0, $t1
Chapter 2 — Instructions: Language of the Computer — 20
MIPS assembly language for Arithmetic
Registers vs. Memory
Chapter 2 — Instructions: Language of the Computer — 22
MIPS assembly language Data Transfer
�Instruction Types�
�Instruction Types Continued�
Instruction Types Continued�
Instruction Types Continued�
MIPS Assembly Language Logical
Assembly Language
�Operands of the Computer Hardware�
Compiling a C Assignment Using Registers.
�Memory operands�
Memory Operands
Memory Operand Example 1
g = h + A[8];
lw $t0, 32($s3) # load word�add $s1, $s2, $t0
offset
base register
��Load Word Instruction��
Memory Operand Example 2
A[12] = h + A[8];
lw $t0, 32($s3) # load word�add $t0, $s2, $t0�sw $t0, 48($s3) # store word
Load word instruction.
Load word instruction.
Load word instruction.
Store word
���Example of compiling using load and store.���
�Constant or immediate operands�
addi $s2, $s1, -1
Readings