Академический Документы
Профессиональный Документы
Культура Документы
Lecturer Summary
1. Instruction Set Architecture
2. Register Transfer Notation
3. Assembly language
4. Instruction Types
5. CPU Organization/Classification of ISAs
- Accumulator based CPUs/ Computers
- Register based CPUs/ Computers
- Stack based CPUs/Computers
6. Instruction Formats
- Zero address instruction format
- One address instruction format
- Two address instruction format
- Three address instruction format
7. Instruction Execution and Straight-Line Sequencing
1 Introduction
In computer all works are done by its hardware. To command a computer’s hardware, you
must speak its language. The words of a computer’s language are called instructions, and its
vocabulary is called an instruction set.
Every CPU has a low-level instruction set, or machine language, which closely reflects that
processor’s design.
In this course, we use a generic style to describe machine instructions and operand
addressing methods that are typical of those found in commercial processors. These generic
programs are specified at the assembly language level, which are formally described by RTN.
RTN is a notation that uses symbols, rather than words, to provides a formal means of
describing machine structures and functions.
It can be used to describe what a machine does (an abstract RTN) without describing
how the machine does it.
It can also be used to describe a particular hardware implementation (a concrete
RTN). RTN aids greatly in understanding of new machine design concepts.
Information is transferred from one location in the computer to another. Possible locations that
may be involved in such transfers are memory locations, processor registers, or registers in the
aksHELPLINE Lecturer Notes of Computer Organisation (CO), First Ed. Page 1 / 11
I/O subsystem. A location is identified by a symbolic name standing for its hardware
binary address.
For example,
Names for the addresses of memory locations may be LOC, PLACE,
A,B,C,D,..,VAR2. Processor register names may be R0,R1,R2,R3,R4 R5 etc.
I/O register names may be DATAIN, OUTSTATUS and so on.
The contents of a location are denoted by placing square brackets around the name
of the location.
For example,
Thus, the expression R1 ← [LOC] means that the contents of memory location
LOC are transferred into processor register R1.
The expression R3 ← [R1] + [R2] means the operation that adds the contents of
registers R1 and R2, and then places their sum into register R3.
No two computers of different models have same instruction set. Almost every computer has
some unique instructions which attract the programmers. Taking into account the various
operations, the instructions can be classified into following eight types.
1. Data transfer instructions : These move the data from one register from one
register/memory location to another.
Register transfer: MOVE
Memory transfer: LOAD, STORE
2. Arithmetic instructions: These perform arithmetic
operations. ADD, SUB, MUL, DIV
3. Logical instructions: These perform Boolean logical operations.
NOT, OR, AND, XOR, SHIFT,ROT etc
4. Control transfer instructions/ Program sequencing and control instructions : These modify
the program execution sequence.
5. I/O instructions: These transfer information between external peripherals and system
(CPU/Memory).
I/O transfer: IN, OUT
6. String manipulation instructions: These manipulates strings of byte, word, double word etc.
7. Translate instructions: These convert the data from one format to another.
8. Processor control instructions: These control processor operations.
The stack is push down list with last in first out(LIFO) access mechanism. It stores the operands. It is
present either inside the CPU or a portion of the memory can be used as a Stack.
A Register (or memory location) is used to point to the address of the top vacant
location of the stack. This register is known as the Stack pointer. When nothing is stores
in the stack, the stack is empty and the stack pointer points to the bottom of the stack.
When an item is stored in the stack, it is called PUSH Operation and The item which is pushed into the
stack last (recently) comes out first in the next POP Operation.
In the stack base CPU, all operations by the CPU are done on the contents of a stack.
Similarly, the result of an operation is stored in stack.
Advantages of stack based CPU
Easy programming/high compiler efficiency.
Highly suited for block-structured languages.
Instruction do not have address field; short instructions.
Dis-advantages of stack based CPU
Additional hardware circuitry needed for stack
implementation. Increased program size.
A real or emulated computer that evaluates each sub-expression of a program statement via a pushdown
data stack and uses a reverse Polish notation instruction set.
Any computer that uses a call stack in memory to manage the local variables of nested calls. (Nearly all
computers and programming languages do this now.)
In these instruction formats, only one operand is specified and other operand is
implicitly taken as accumulator. Here all the operations are carried out between the
accumulator register and a memory operand.
Instruction RTN Assumption/(Meaning)
LOAD A AC ← [A] Copies the contents of memory location A
into the accumulator.
STORE A A ← [AC] Copies the contents of accumulator into
memory location A
ADD A AC ← [AC] + [A] Add the contents of memory location A to
the contents of the accumulator register and
place the sum back into the accumulator.
SUBTRACT A AC ← [AC] - [A] Subtract the contents of memory location A
or SUB A from the contents of the accumulator register
and place the result back into the
accumulator.
MULTIPLY A AC ← [AC] * [A] Multiply the contents of memory location A
Or MULT A from the contents of the accumulator register
and place the result back into the
accumulator.
In these kind of instruction formats two operands are specified. Here one of the operands is
source, while the other is both source and destination for the operation.
Here we assume an instruction in the form OPCODE SOURCE DESTINATION
Instruction RTN Assumption/(Meaning)
LOAD A, Ri Ri ← [A] Copies the contents of memory
or location A into the register Ri.
MOVE A, Ri
STORE Ri, A A ← [Ri] Copies the contents of Register
or Ri into memory location A
MOVE Ri, A
ADD A, Ri Ri ← [Ri] + [A] Add the contents of memory
location A to the contents of the
register Ri and place the sum into
the register Ri.
ADD Ri, Rj Rj ← [Rj] + [Ri] Add the contents of register Ri to
the contents of the register Ri and
place the sum back into the
register Rj.
Example-2
Write an assembly language program to derive the expression X = (B+C)*D-E in a 2-
address instruction based computer.
Answer
Assembly language RTN
MOVE B, R0 ; R0 ← [B]
ADD C, R0 ; R0 ← [R0] + [C]
MULT D, R0 ; R0 ← [R0] * [D]
SUB E, R0 ; R0 ← [R0] - [E]
MOVE R0, X ; X ← [R0]
In these instruction formats, the three operands are specified in the instruction. RISC
processor usually supports 3 - operand instruction format. A convention that the third
operand is the destination and the rest two are source, a convention followed in SPARC
assembly language. In the MIPS assembly language, the convention is the other way
around: first operand is destination, and the next two are sources.
If the three address instruction format allows only two memory operand as source and
one register as destination, the the above ADD instruction can be written as follows:
ADD A, B, R1 ; R1← [A] + [B] in SPARC style
ADD R1, A, B ; R1← [A] + [B] in MIPS style
Example-2
Write an assembly language program to derive the expression X = (B+C)*D-E in a 3-
address instruction based computer.
Answer
Assembly language RTN
ADD B, C, R0 ; R0 ← [B] + [C]
MULT D, R0, R1 ; R1 ← [D] + [R0]
SUB E, R1, X ; X ← [R1] - [E]
2. Given a binary pattern in some memory location, is it possible to tell whether this
pattern represents a machine instruction or a number?
aksHELPLINE Lecturer Notes of Computer Organisation (CO), First Ed. Page 11 / 11