Isa 1
Isa 1
The portion of the machine visible to the programmer or compiler writer and this includes: 1. 2. 3. 4. 5. 6. Types of machine instructions Types and sizes of operands Addressing modes Byte Ordering (Endianness) Programmer visible CPU registers Instruction Formats (Instruction encoding)
1
Register-Register Architecture
1. 2. Memory is accessed by LOAD/STORE instructions only Arithmetic and logical instructions accept operands from CPU registers only 3. Results of ALU operations go to CPU registers only 4. Also known as LOAD-STORE architecture 5. Simple fixed length instruction encoding 6. Instructions take nearly same number of cycles for execution 7. Simple code generation model 8. Compiler writers job is relatively easy 9. High instruction count i.e. larger programmes 10. Some instructions are short and bit encoding may be wasteful 11. Helps in pipelined execution of instructions 3
Register-Memory Architecture
1. 2. 3. 4. 5. 6. 7. Operands may be in memory and CPU registers Result of ALU operation may go to memory location or CPU register One operand may be lost if accumulator is used Data may be accessed without loading first Clocks per instruction vary according to operand location Encoding a register number and a memory address in each instruction may restrict the use of registers Instruction encoding is easy
Memory-Memory Architecture
1. Allows operands and result to reside in same memory 2. Large variations in instruction sizes 3. Large variation in work per instruction 4. Memory accesses create memory bottleneck 5. Most compact code
Instruction Types
(with respect to number of operands referred) 1. 2. 3. 4. Three-address instructions Two-address instructions One-address instructions Zero-address instructions ADD A,B,C ADD A,B ADD A ADD
Example
X = (A + B) * (C + D)
The computer has two data registers R1 and R2. A, B, C and D are memory addresses.
1. Three-address instructions
ADD R1, A, B ADD R2, C, D MUL X, R1, R2 MOV R1, A ADD R1, B MOV R2, C ADD R2, D MUL R1, R2 MOV X, R1 R1 [A]+[B] R2 [C]+[D] M[X] R1*R2 R1 R1 R2 R2 R1 M[X] M[A] R1 + M[B] M[C] R2 + M[D] R1 * R2 R1
2. Two-address instructions
3. One-address instructions
One of the operand is implied and is in the accumulator register (AC). Also, the result of an operation goes to The accumulator. LOAD A AC M[A] ADD B AC AC + M[B] STORE T M[T] AC LOAD C AC M[C] ADD D AC AC+ M[D] MUL T AC AC * M[T] STORE X M[X] AC Comments The operand in AC is overwritten by the result. Total number of instructions increases. Instruction encoding takes less number of bits.
8
4. Zero-address instructions
Computational instructions do not need addresses for The operands. PUSH and POP instructions do need the address fields to specify the operands. PUSH PUSH ADD PUSH PUSH ADD MUL POP A B C D TOS TOS TOS TOS TOS TOS TOS M[X] M[A] M[B] M[A] + M[B] M[C] M[D] M[C] + M[D] (M[C]+M[D])*([A]+[B]) TOS
9
Types of Instructions
(with respect to operations) 1. 2. 3. 4. 5. 6. Data transfer Arithmetic Logical Transfer of control Input output Conversion
10
2.
Add Subtract Multiply Divide Absolute Negate Increment Decrement
Arithmetic Operations
Compute sum of two operands Compute difference of two operands Compute product of two operands Compute quotient of two operands Replace operand by its about value Change sign of operand Add 1 to operand Subtract 1 from operand
12
3.
AND, OR, NOT, Exclusive-OR Test Compare
Logical Operations
Performs specified logical operation bitwise Test specified condition; set flag(s) based on outcome Make logical or arithmetic comparison of two or more operands; set flag(s) based on outcome Class of instructions to set controls for protection purposes, interrupt handling, timer control, etc. Left (right) shift operand, introducing constants at end Left (right) shift operand, with wraparound end
13
4.
Jump (branch)
Jump conditional
Jump to Subroutine
Return
No operation
15
5.
Input (read) Output (write) Start I/O Test I/O Translate Convert
Types of Operands
1. 2. 3. 4. 5. 6. 7. 8. 9. Addresses (treated as unsigned numbers) Integers (usually in 2s complement form) Single-precision floating point numbers Double-precision floating point numbers Packed decimal numbers (BCD for decimal arithmetic) Unpacked decimal numbers (numeric character) Characters (usually in ASCII) Logical data (n-bit word is taken as n 1-bit data) Any other special data type
17
Addressing Modes
How architecture specifies the address of objects they access
Addressing Modes
1. Immediate addressing 2. Register direct addressing 3. Direct addressing 4. Indirect addressing 5. Register indirect addressing 6. Based addressing 7. Indexed addressing 8. PC-relative addressing 9. Modulo or circular addressing 10. Bit-reverse addressing
18
Instruction Format
(Instruction Encoding) It defines the layout of bits of machine instructions in terms of their: Length Opcode fields Address Fields
Operand specifier1 Operand specifier2 Operand specifier3
Opcode
0
19
Instruction Length
Instruction length affects and is affected by
1. 2. 3. 1. 2. 3. 4. Memory size Memory organization Bus structure (number of bits in system bus vs. instruction length) CPU complexity (CPU registers) Complexity of instructions Number of operands referred Addressing modes/range
20
10
Instruction Types
(with respect to fixed or variable length/format) 1. Fixed length/format instructions 2. Variable length/format instructions
21
22
11
Examples
12
13