Lecture 4a Instruction Set Architecture PDF
Lecture 4a Instruction Set Architecture PDF
LECTURE 4
INSTRUCTION SET AND DESIGN OF
INSTRUCTION SET ARCHITECTURE (ISA)
Dr. E. A. Kalinga|CSE|CoICT| 1
Computer Architecture
• Computer architecture is the design of
computers, which include:
—Their instruction sets,
—Hardware components, and
—System organization
• The architecture of a computer consists of
two essential parts:
—The instruction set architecture (ISA), and
—The hardware-system architecture (HSA)
Computer architecture =
Instruction set architecture + Machine organisation
hardware-system architecture
Instruction Set
• Programs written in High-Level languages (by a
programmer) must be translated (by a compiler)
to an appropriate sequence of assembly
instructions (assembly language).
• Later, assembly language will be translated into
executable binary codes.
• Assembly language provides mnemonics for
machine language instructions which must be
encoded as a series of binary digits.
Instruction
Instruction in programming language:
a=b+c
Note:
Operation is “add”, source operands are “b” and “c”,
destination operand is “a”
Instruction
Add b c a
Source Source Destination
Opcode Field Operand 1 Operand 2 Operand
(Operation Code)
TF DF IF OF SF ZF AF PF CF
Instruction Fetch
Address
Memory
Select next
Program Instruction
instruction
Counter
Increment PC
CPU to locate next
instruction.
Instruction
Register
CPU Registers
• CPU uses registers as its working space (temporarily
storage)
• Registers include:
—User visible registers:
– Accumulator (A)
– General-Purpose-Registers (GPR): Base, count and
data
– Data registers (D7 – D0)
– Address Registers (A7 – A0)
—Control and status registers
– Program counter or instruction pointer
– Instruction Register
– Status word register or flag register
Addressing Instructions
3 – Addresses Instructions
• 3-addresses
instructions OPCODE Des. Addr. OP1 Addr. OP2 Addr.
used
Next Addr. Next Program counter
(PC)
2 – Addresses Instructions
• 2-addresses instructions
—2 operands are used: Operand 1, Operand 2
—Reduces one address from 3-address machine
—One address doubles as operand and result
—E.g ADD OP1,OP2
OPCODE OP1 Addr. OP2 Addr.
Address Memory CPU
1 – Address Instructions
• 1-address instructions
— Accumulator Register in CPU is implicitly used as one source operand
and as a result destination. e.g. add op1
— Arithmetic operations used are LOAD and STORE the accumulator
bits contents
— Also known as Accumulator architecture
OPCODE OP1 Addr.
Address Memory CPU
+
·
·
·
Accumulator
Nexti Addr. Next Program counter (PC)
0 – Address Instructions
• 0 (zero) address Instruction
—ALU need no memory addresses. All addresses implicit
—Uses a stack. Operands are Pushed onto the Stack from
memory
—There is push-down stack in the CPU
—Operation is performed on the two operands at the top
and second positions on the stack
—PUSH and POP opcodes are used
—Also known as Stack architectures
—e.g. c = a + b PUSH a
PUSH b
ADD
POP c
• The stack is a block of memory locations reserved to
function as temporary memory.
OP1
·
TOS
· SOS +
·
Where:
LDA – Load Accumulator, STA – Store Accumulator, MUL - Multiply
Classification of ISA
• The type of internal storage in the CPU is the most basic
differentiator
• Computers can be classified according to the structure and
function of the registers in the CPU
• Operands may be named explicitly or implicitly
1. Accumulator Architecture
— Have a limited number of data accumulator often just one, in
addition to the address register within the CPU
— In an accumulator architecture one operand is implicitly the
accumulator
— Called accumulators because they serve both as the source of
an operand and as a destination for the arithmetic instructions:
thus they serve to accumulate data
— Also known as 1-address machine, which makes the
machine to have the advantage of being cheap
— Having one or limited number of accumulator in the CPU, an
accumulator machine is quite limited when evaluating
arithmetic evaluations with many terms and factors
Classification of ISA
2. Stack Architecture
— The operands in a stack architecture are implicitly on top of
the stack
— LIFO (Last-In-First-Out) is used to describe the storage
mechanism
— Arithmetic operations use two operands from the top of the
stack, and the result is placed on the top of the stack
replacing the operand
— When the expression evaluation is complete, the result is
POPPED into a memory location to complete the process
— No-operand addresses need to be specified during an
arithmetic operation, the class is also known as a 0-
address machine
Classification of ISA
3. General-Purpose Register (GPR) Architecture
— Have only explicit operands – either registers or memory
locations
— The explicit operands may be accessed directly from memory
or may need to be first loaded into temporary storage
— They can be divided into two classes
a) Load-store or Register-register architecture:
– can access memory only with LOAD and STORE instruction
– LOAD moves data from memory to a processor register
– STORE moves data from processor to memory
– ALU and Branch operations in Load-Store machines can
accept only operands located in processor registers, and
they must store the result in the processor registers.
Hence also called Register-register Architecture.
Classification of ISA
b) Register-memory machine
– Locate operands and result in a combination of memory
and registers
– One operand or a result must be an accumulator or
general register (1½ address)
– Can access memory as part of any instruction
4. Memory-memory machine (2 or 3 address)
— They are 2 or 3 address machine depending upon whether one
of the operands location also serves as a result location
— Allows both the operand to reside in memory, i.e. keeps all the
operands in memory
— Not commonly used
• The explicit operand may be accessed directly from memory
or may need to be first loaded into temporary storage,
depending on the class of instruction and choice of specific
instruction
Classification of ISA
• Most early machines used stack or accumulator
style architecture
• Every machine designed after 1980 uses a
load-store register architecture due to the
following reasons:
—Registers are fast than memory
—Registers are easier for a compiler to use and can be
used more effectively than other forms of internal
memory
—Registers can be used to hold variables
Summary
• Stack architecture: Operands are implicitly on top
of the stack.
• Accumulator architecture: One operand is
implicitly in the accumulator (a register). Examples:
IBM 701, DEC PDP-8.
• General-purpose register (GPR) architecture:
Only explicit operands.
—Register-memory architecture (one operand in memory).
Examples: Motorola 68000, Intel 80386.
—Register-register (or load-store) architecture. Examples:
MIPS, DEC Alpha.
• Memory-memory architecture: All operands in
memory. Example: DEC VAX.
• Example: c = a + b
• It is assumed that a, b, and c all belong in
memory
ISA Characteristics
• Four main characteristics:
1. Register Organization
— # of registers & their sizes
2. Memory Organization
— Address space - # of memory locations
— Addressability - # of bits stored @ each location
– Byte addressable and provide access for byte (8 bits),
half word (16 bits), and word (32 bits)
– Conversions of ordering the bytes within a word (Little
Endian, Big Endian)
– Addressing modes – defines how operand values are
obtained
ISA Characteristics
3. Instruction Set
— List of opcodes (operations)– defines instructions
supported
— Instruction Formats (Encoding an instruction set)
– binary format for encoding instructions (R-format, I-
format, J-format)
– How the instructions are encoded into a binary
representation for execution by the CPU
— Type and size of operands: Integer, single/double precision
floating point, character
4. The role of the compiler
− From HLL to assembly language
Data Sizes
A byte is composed of 8 bits. Two nibbles makes
up a byte.Words are composed of bytes as
shown: -
Bit 1 Bit length, Either ‘0’ or ‘1’
Nibble 4 bits length, or a half byte
Byte 8 bits length
Half word 16 bits length (2 bytes)
Word 32 bits length (4 bytes)
Double Word 64 bits length (8 bytes)
Quad words 128 bits length (16 bytes)
Memory addresses
• Little-Endian byte order
—The organization stores the least significant byte of a word
at the least-significant position in the word (the little end)
i.e. lower byte address, and the most significant byte at
the most-significant position in the word i.e. higher byte
address.
—Use the address of the rightmost as the word address
Memory Organization
• The main memory can be Address Memory
viewed as a large, single- 0 8 bits
dimension array of memory
1 8 bits
locations.
2 8 bits
• Each location of the
3 8 bits
memory has an address,
4 8 bits
which is an index into the
array. 5 8 bits
6 8 bits
• The memory map on the
7 8 bits
right contains one byte (8
bits) in every location. 8 8 bits
• •
• Byte addressing means the
index points to a byte of • •
memory. • •
Addressing Modes