HPC Lecture4
HPC Lecture4
Word Alignment
`Integer variable X is not word aligned’
The data item is not located at a word boundary
Word boundaries: addresses 0, 4, 8, 12, …
2
Instruction Set Architecture (ISA)
View of the computer that is visible to the
programmer (or compiler)
There are 2 styles of instruction set design
1. CISC
Complex Instruction Set Computer
A single instruction performs a complex operation
involving several actions
2. RISC
Reduced Instruction Set Computer
Each instruction performs only a simple operation
3
Instruction Set Architecture
Description of machine from view of the
programmer/compiler
Example: Intel® x86 Instruction Set Architecture
Includes specification of
1. The different kinds of instructions available
(instruction set)
2. How operands are specified (addressing modes)
3. What each instruction looks like (instruction
format)
4
Kinds of Instructions
1. Arithmetic/logical instructions
add, subtract, multiply, divide, compare (int/fp)
or, and, not, xor
shift (left/right, arithmetic/logical), rotate
5
Kinds of Instructions
1. Arithmetic/logical instructions
2. Data transfer instructions
load (copy data to a register from memory)
store (copy data to a memory location from a
register)
move
6
Kinds of Instructions
1. Arithmetic/logical instructions
2. Data transfer instructions
3. Control transfer instructions
jump, conditional branch, function call, return
7
Kinds of Instructions
1. Arithmetic/logical instructions
2. Data transfer instructions
3. Control transfer instructions
4. Other instructions
e.g., halt
8
Operand Addressing Modes
• Operands to an instruction
• Source: input value to instruction
• Destination: where result is to go
• Addressing Mode
• How the location of an operand to an instruction is
specified
• An operand can be either
• in a memory location
• in a register
9
Addressing Modes: Operand in Register
1. Register Direct Addressing Mode
Operand is in the specified general purpose register
Example R1 61
17
Suppose that the General Purpose Registers R2 24
numbered as R0, R1, R2, etc R3 37
ADD R1, R2, R3 / R1 = R2 + R3
destination operand source operands
10
Addressing Modes: Operand in Register
1. Register Direct Addressing Mode
2. Immediate Addressing Mode
Operand is included in the instruction
ADD R1, R2, 7 /R1 = R2 + 7
11
Addressing Modes: Operand in Memory
3. Register Indirect Addressing Mode R1 42
32
Memory address of operand is in the
R2 100
specified general purpose register
ADD R1, R1, (R2) Address 96 100 104 108
Value 0 10 35 -17
MAIN MEMORY
12
Addressing Modes: Operand in Memory
3. Register Indirect Addressing Mode
4. Base-Displacement Addressing Mode
Memory address of operand is calculated as
R1 67
32
the sum of value in specified register and
R2 100
specified displacement
Address 96 100 104 108
ADD R1, R1, 4(R2) Value 0 10 35 -17
MAIN MEMORY
Information that must be present in instruction:
Identity of base register (e.g., R2)
Value of displacement to be added (e.g. 4)
13
Addressing Modes: Operand in Memory
3. Register Indirect Addressing Mode
4. Base-Displacement Addressing Mode
5. Absolute Addressing Mode
Memory address of operand is specified directly in
the instruction
ADD R1, R2, #100
14