Instruction Set Types
Instruction Set Types
Structure
1.0 Inlroduclion
1.1 Objectives
1.2 Instruction Set Characteristics
1.2.1 Oj~crandData Types
1.2.2 Number of Addresses in an Instniction
1.2.3 Operation Types
1.3 Addressing Schemes
1.3.1 Irnrncdiate Addressing
1.3.2 Dirccl Addrcssing
1.3.3 Indirect Addressing
1.3.4 Rcgistcr Addressing
1.3.5 Register Indirect Addressing
1.3.6 Displaccrnent Addrcssing
1.3.7 Stack Addressing Scheme
1.4 Instruction Format Design
1.4.1 Instruction Length
1.4.2 Allocation of Bits
1.4.3 Variable Length of Instructions
I .5 . Example of Instruction Set
1.6 Summary
1.7 Model Answers
1.0 INTRODUCTION
In the previous block, we have discussed about structure of the computer and the data
representation. One term which we have commonly used is the instruction. In this respect,
fcw questions which still need to be answered is : What is an instruction? What are its
components? How is the instruction executed by the CPU? This unit is an attempt to answer
~hc:first two questions. While, the third question is a complex one and is explained in the
later units. In this unit we havc discussed in details about the instructions, their types, the
operands. We will also discuss about the various addressing schemes which are popular
among various PC's and how the effective address is calculated for these schemes. In
addition we are also trying to highlight the basic design issues related to the instruction in the
unil. We havc prcsented here the instruction set of IBM Systemn70 as an example.
However, you car1 study the delails on the other instruction sets for example VAX machine
from the further readings. We have not included discussions on the instruction set of popular
lNTEL microprocessor. One of Lhis microprocessor instruction set is discussed in the
Block 3 of this course. Other related microprocessors instruction set can also be studied
from the further readings.
OBJECTIVES
At the end of this unit a student should be able to:
discuss about various elements of an instruction
distinguish various types of instructions
differentiate various types of operands
define a classification of computers on the basis of number of addresses in
instruction sets
discuss about various operations which are performed by the instru&ons
identify various addressing schemes
calculate effective address for various schemes
d~scussabout the instruction formats design characteristics
1.2 INSTRUCTION SET CHARACTERISTICS
Till now we have discussed about instruction in an abstract way. Now let us discuss in
details various characteristics of instructions. But let us first discuss what is the significance
of instruction set? One hing which should be kept in mind is that the instruction set is an
boundary which is looked upon in a same fa~hionby a computer designer and the
programmer. From thc computcr designer's point of vicw, the instruction set provides the
functional requirements of thc CPU. In fact, for implementing the CPU design, one of the
main task is to implcmcnt the instruction set for that CPU. However, from the-uscr point of
view machine instructions or Assembly instructions are nccdcd for low level programming.
In addition, a user should also be aware of registers, the data types supported by the machine
and the functioning of the ALU. We will be discussing about the registers in unit 2 and about
the ALU in unit 3 of this block.
Explanation on the machine instruction sct gives extensive details about the CPU of a
machine. In fact, the operations which a CPU can pcrform can be detcrmincd by the
machine instructions. Now, Ict us answer somc introductory qucstions about the instruction
set.
0 3 4 9 10 15
Reference to Reference
Opcode operand to operand
I 4 bits
What are the factors which play important role for selectionldesigningof instruction set
for a machine?
Instruction set design is the most complex yet int,resting and very much analysed aspect of
computer design. The instruction set plays important role in design of the CPU as it &fines
many functions of it. Since instruction sets are the means by which a programmer can
control the CPU,therefore, users view must be considered while designing the instruction
set. Some of the important design issues relating to instruction design are:
How many and what operations to be provided?
3
.-
s
What are the operand data types to be provided?
What should be the Instruction format? This includes issues like: instruction length.
number of address, length of various elements of instructions etc.
What is the number of registers which can be refef~lcedby an instruction and how
are they used?
All the machines provide instructions for performing arithmetic operations on fixed point
and floating point numbers. Many machines provide arithmetic instructions which perform
operations on packed decimal digits.
Characters: Another very common data type is the character or string of characters. The
most widely used character representation is ASCII (American National Standard Code of
Information Interchange). It has 7 bits for coding data pattern which implies 128 different
characters. Some of these characters are control characters which may be used in data
communication. The eighth bit of ASCII may be used as a parity bit. One special mention
about ASCII which facilitateconversion of a 7 bit ASCII and a 4 bit packed decimal number,
is that the last four digits of ASCII number are binary equivalent of digits 0-9.
That is
Decimal Binary ASCII
The other important code is Extended Binary Coded Decimal Interchange Code (EBCDIC).
This is a 8 bit code and is compatible with packed decimal in a similar way as that of ASCII.
The digits 0 through 9 in this can be represented as 1111 0000 through 1111 1001.
Logical Data: In general a data word or any other addressable unit such as byte, half word
etc. are treated as a single unit of data. But can we consider a n-bit data unit consisting of n
items of 1 bit each? If we treat each bit of a n-bit data as an item then it can be considered to
be logical data. Each of these n items can have a value 0 or 1.
What are the advantages of such a bit oriented view of data? The advantages of such a vim
will be:
We can store an array of boolean or binary data items most efficiently.
We will be in a position to manipulate the bits of any data item.
But where do we need to manipulate bits of a data item? The example of such a case is
shifting of significand bits in a floating point operation or for converting ASCII to packed
decimals where we need only the 4 right most bits of ASCII's byte.
Please note that for extracting decimal from ASCII, first the data is treated as logical data
and then can be used in arithmetic operations as numeric data. Thus, the operation
performed on a unit of data determines the type of the unit of data at that instance. This
statement may not be true for a high level language, but holds good for machine level
language.
Check Your Progress 1
State true or false.
Q1. An instruction set is meant only for the programmer and is not needed at the time of
implementation of a machine?
True F a n
42. Explicit operand references are must for an instruction?
True (1F& n
Q3. You can use only one instruction format for an instruction set of a machine.
Q4. Data movement instructions are used for bringing in data from the memory to CPU
registers.
True 1 ~alrr
Q5. Numbers represented in computers are limited in magnitude.
True ) n
" r Q6. A data value in a machinc lmguage can be treated as of one type only.
True j( False n
1 1.2.2 Number of Addresses in an Instruction
The fewer number of adhesses in an Instruction lo reduced length of instructions,
however, it also limits lh?ranqe of functton *hatcdn ?sperformed by the instructions. In a
sense this implie. t k t a machine instr~~uonset hawng less number of addresses have longer
programs, which means longer execution m e . Howeger, more addresses may lead to more
complex decoding and prwesslng circuits.
Most of the instruc :ions donot require more than three operand addresses. In instructions
having fewer addrsses than three, normally some of the operand locations are implicitly
pefined. Many computers have a range of instructions of different length and number of
addresses. The followinp table gives an cxample ~f zero, one, two and three address
instruction along with their interpretaiions.
Number of Addresses Inst1 uction Interpretation
3 ADD A,B,C Operation A = B+C is executed
Two plausible interpretations
(i) AC = A + B
(ii) A = A + B. In this case the
original content of operand
location A is lost
ADD A AC = AC+A
A is added to accumulator
ADD Top of Stack contains the addition
of top two values of the stack.
AC is a accumulator register.
A,B,C are operand locations.
Figure 3 : Example dzero, one, two and three address Instruction
The register architecture, that is a general classification which is based on register set of the
computer, is sometimes classified according to the number of addresses in instructions.
These classificationsare:
Kvaluation-StackArchitecture: These machines are Zero address machines and their
9
CPU Ogsnlsation operands are taken from top of the stack implicitly. The ALU of such machine directly
references a stack which can be implemented in main mcmory or regis~rsor bob. These
machine contains instructions like PUSH and POP to load a value on stack and store a value
in the memory respectively. Please note that PUSH, POP are not zero address instructions but
contain one address.
The main advantages of such an architectureare:
very short instructions
since stacks are normally made within CPU in such an architecture machine, the
operands are close to the ALU, thus fast execution of instructions.
excellent support for subroutines.
While, the main disadvantages of this architecture are:
not very general in nature, in comparison to other architectures.
difficult to program for applications like text and string processing.
One example of such a machine is Burroughs B6700. However, these machines are not very
common today because of the general nature of machines desired. The stack machines uses
Polish notahons for evaluation of arithmetic expression. Polish notation was i n d u c e d by a
Polish logician Jan Lukasiewicz. The main theme of this notation is that an arithmetic
expression AxB can be expressed as:
either x AB (Prefix notation)
or ABx (Suffix or reverse polish notation)
In stacks we use suffix or reverse polish notation for evaluating expressioii. The rule here is
to push all the variable values on the top of stack and do the operation with the top elements
of stack as an operand is encountered. The priority of operand is kept in mind for generation
of reverse polish notation. For example, an expression AxB+CxD/E will be represented in
reverse polish notation as:
Flpm 4 :Sample program lor evaluating AxB+CxDIE using zero address instructions
Please note that PUSH and POP are not zero-address instructions.
The execution of the above program using stack is represented diagrammatically in figure 5.
Accumulator Machines: These machines contain a special register called accumulator
which holds the results of arithmetic, logical or shift operations. The accumulator is an
implicit address. The instructions in such machines are normally one-address instructions.
The basic advantage of the one address machines is that the instructions are shorter than 2
and 3 addressed machines. However, de performance of these machines are somewhat slow
because these machine require frequent memory accesses. These machines are made by
various vendors.
For example, a program for evaluating the expression F=AxB+CxD/E written in this
Accumulator based machine is given in figure 6.
PUS14 C
/Transfer A to Accumulalor/
/Multiply Accumulator with B, keep the result of /
/multiplication in B/
/Store the intermediate result temporarily in a location T/
/Transfer C to Accumulator /
/Accumulator = Accumulator X Dl
/Accumulator = ~c'cumulator/E/
/Accumulator = Ac%umulator+ T/
/Store the Accumulator value to location F/
Figure 6 : Sample program for evaluating AxBtCxDIE using one address instructions
General Purpose Register Set Machines: Many computers have bcen designed having set
of registers termed as general purpose registers. Thesc general-purpose regisler machines
normally have multiple address instructions. In these machines any of the register of the
register set can be used as accumulator or an address register or an index register or a stack
pointer, or even (in some cases)as a program counter. In such machines, each instruclion
specifies itself,about the use of register. Some examples of such computers are IBM syslem
370 & Digital VAX families.
The instructions in such machines can specify as many Register operands as desired.
Therefore, several oprations can be performed solely on regislers. This may increase the
program execution speed as register references are faster than memory references. For the
purpose of flexibility and ability to use multiple registers, these computers may use two and
three address instructions. Some of these computers have instructions for Register to mcrnory
transfer, and memory to memory transfer. Since number of registers are few, thcrcfoe, the%
instructions are normally shorter.
The program for F = AxB + CxDE for 2 address and 3 address machines will look llke
MOVE T,A /MoveTA/ MULT F, A, B / F=AxB /
T, B / Multiply T=WB / MULT T, C, D / T=CxD /
MOVE F,C /MoveF C / DIV T,T,E /T=T/E/
F, D / Multiply F=FxD / ADD F,F,T / F=F+T/
F, E / Divide F=F/E / 11
ADD F, T 1 Add F=F+T/
Figure7 :Sample program fw evaluating F=AxB+CxD/E using two and three address instructions
Data Transfer Operations: This is the most fundamental type of operation. A data transfer
instruction need ro furnish the following information:
The location of source and destination operands (This could be memory or regismr
or stack-top). This will be more clear after you go through the next subsection.
The length of data transfer
The mode of addressing for each operand. These addressing modes are discussed in
greater details in the next section.
Some of the common data transfer operations are:
Operation Description
MOVE or TRANSFER Transfers a word or a block of data from source to
destination.
STORE Transfers a word from the processor to a specified location
in the main memory.
LOAD or FETCH Brings a word from a location of main memory to the
processor.
EXCHANGE Exchanges the contents of the source with the destination.
CLEAR or RESET Transfers a word containing all 0's to the destination.
SET 'Itansfen a word containing aU 1's to the destination.
PUSH Transfers a word from a source to top of stack.
POP Transfer a word from the top of stack to a destination.
Figure 8 : Common data transfer operations
For all these instructions the choice of source or destination can be a location in the main
memory or a register or the top of stack. This location can be indicated either in opcode or in
the specification of an operand.
Arithmetic Operations: Almost all the machines provlde the four basic arithmetic
I operations on signed fixed point integers. Some machines provide operations on floating
point and packed decimal numbers. Some other arithmetic operations such as absolute of a
number, negation of a number, incrementing or decrementing a number are also included as
instructions in several machines. The execution of an arithmetic instruction requires bringing
in the operands in the operational registers such that the data can be processed by the ALU.
I The arithmetic operations which can be provided in a machine in general be:
! ADD, SUBTRACT, MULTIPLY, DIVIDE
i
ABSOLUTE, NEGATE, INCREMENT, DECREMENT
i
Logical and Shift Operations: The logical operations are based on boolean operations
performed on binary data. Some of the logical operations are: AND, OR, NOT,
Exclusive-OR.
In addition to these bitwise logical operations, machines provide a variety of shifting
operations. A shift operation is performed either in the left or to the right. In a shift
operation, all the bits move towards the left or right as desired. (Please refer to figure 9).
I
(left shift)
Bit out Bit in
(for left shift) (for l d t shift)
-
In logical lejilright shift the "bit in" is a 0 bit.
Arithmetic shift is same as logical shift except for the sign bit which is not shifted.
A circular shift uses the "bit out" bit as the "bit in" bit.
The main usage of these shifts are:
The logical shift is used in extracting fields from a word. How?
The arithmetic shift if performed on numbers represented in signed 2's complement
notation cause multiplication by 2 or division by 2 depending on left or right
arithmetic shift, provided there is no overflow or underflow.
The circular shift preserves all the bits.
Conversion Operations: The conversion operations are needed to convert the fonnat of the
data. For example changing format from decimal to binary or ASCII to EBCDIC or vice
versa. In general the two conversion operation are:
TRANSLATE This instruction translates a given piece of data depending on a
table of correspondence
CONVERT It convert. the contents of a word from one format to other.
Let us give an example of each of these. A common example for TRANSLATE instruction is
conversion of ASCII to EBCDIC. This can be achieved by creating a table which is 256 byte
long. We can call it as an array of EBCDIC equivalent values. Each index of this array
represent the ASCII value, while the content of that location is the equivalent EBCDIC. For
example, if 00110011 in ASCII is equivalent to 11001100 then
ARRAY location 00110011 contains 11OO1100
that is TRANS [00110011] = 11001100
However, the convert instruction converts the format based on certain rule for example,
decimal to binary.
13
CPU Organisation InputiOutput Operations: There 1s a lo1 of variety as far as input/output operations are
concerned as they depend on the type of input/output such as programmed 110, DMA, etc.
We have given some 110 operations in the Unit 4 of Block 1. However, some of the common
input/output instructions are:
READ (or INPUT) This command is used for transferring data from inpur/output
module or part to a destination which may be the main memory
or processor register.
WRITE (or OUTPUT) This command transfers data from a specified source to input1
output module.
TEST UO It transfers the inpur/output systems status information to a
specified destination.
System Control Operations: The system control operations generally come under the
category of privileged instructions, that is, these instructions are executed only when the
processor is in certain privileged state or the processor is executing a program which is
stored in a special privileged area of memory. In general, these instructions are used by the
operating system. A typical syslem control instruction is OSCALL. This instruction causes
the interruption of execution of current program and passes the control to the operating
system.
I'ransfer of control Operations: In general, in a program execution the next insrniction in
sequence is executed next. However, in certain cases such as looping, decision making and
subroutine call, the next instruction to be executed may not be the next instruction in
sequence. The instructions that disturb the normal flow of instruction execution are called
transfer of control instructions. The most common transfer of control instructions which are
found in instruction sets are:
- Branch
- Skip
- Subroutine Call
Branch Insrrucrion: A branch instruction causes a jump,to the new instruction to be
executed. A branch instruction is also known as jump instruction. This instruction has one
operand, that is, the address of the instruction to which branch is desired. The branch
instruction, in general, is used as a conditional branch instruction that is the branch is made
only if a specified condition is satisfied otherwise the next instruction in the normal sequence
is executed.
But how is the condition tested? Most of the machines provide a 1 bit or a multiple-bit
conditional code, which in certain cases can be treated as a user visible register (we will
discuss more about user visible registers in unit 2 of this block). For example, a typical
machine performing on an arithmetic operation can set a 2 bit condition code to either zero,
positive, negative or overflow condition. On such a machine, we can have the conditional
jump instructions as:
Conditional Meaning Instruction Meaning
Code (C.C)
00 Resultant is positive BRP X Branch to memory location
X if the result is positive
01 Resultant is negative BRN X Branch to memory location
X if the resultant is negative
10 Resultant is Zero BRZ X Branch to X if resultant is Zero.
11 Overflow has occurred BRO X Branch to X if overflow
has occurred.
All these branches may be implemented by assigning Program counter (PC) the address of
the location to which branch is desired.
Figure 10 :Example of conditional branch lnstrudlons
As the changes in condition code may Lake place on execution of each instruction,
Therefore, the branch instruction will depend on the most recent instruction which have
modified the condition codc. All thc abovc four branches takes place when a condition, is
fulrillcd, othenvisc h e next instruction in scqucnce is cxecuted. Another type of condltional
Instruction Sets
branch instruction which has the condition in itself can be devised for a three address
instruction. For example:
BUN R1,R2,C (Branch to a memory location address 'C' if contents of R1 is not
equal to contents of R2.)
Here the condition is tested and branch is determined in a single instruction. Please note that
branch can take place to a higher address or to a lower address. How branching can be used
for looping is discussed in block 3 of this course.
Skip Insfrucfion:This instruction skips the next instruction to be executed in sequence. In
other words this instruction increments the address of "next instruction to be executed" (in
many computers it is the program counter) by one instruction length. Skip instruction can
also be used with conditions, for example, IS2 instruction skips the next instruction only if
the condition codc indicates that the resultant of the most recent operation is zero. This
instruction along with branch instruction is used for implementing looping structures.
Subroufine Call: A subroutine is a self contained user program which contains the code
often used repeatedly in a large program. This program is incorporated in a bigger program.
For more details on subroutine, you can refer to Course 2, Block-1, Unit- 1.
I
A subroutine is called explicitly by a program statement. This is explained in the following
figure:
execution
102
103
execution
Two most important instructions related to subroutine call are CALL and RETURN
statements. CALL causes jump to the first instruction of subroutine, however, this jump
must remember from where it has started as RETURN brings the control back to the
instruction following the CALL instruction. The logic of subroutine call is similar to that of
Interrupt processing. The subroutine call is implemented in many cases by storing the
contents of Program Counter (PC) which in fact is the pointer to the return address.
But where do we store the return address? In general, the return address can be stored in a
register or memory location specifically used for this purpose. In such a system the
following stcps will be fol!owcd on encountering a subroutine call.
Store thc contcnt of PC in a predetermined memory location or register. Let us, call
this rcgister or mcmory location as R
Transfer the starting address of the subroutine which has been called in the PC
Execute the subroutine
On encountering RETURN statement of this subroutine load the contents of R into
the PC.
A second approach cm be to store the return address at the start of the subroutine. For
example, a call instruction CALL X will initiate the following steps:
Store the contents of PC into memory location X.
Place address X+l in the PC, as subroutine statements starts from this memory
location only, as the Xth location is reserved for storing the return address
Execute the subroutine
On encountering RETURN statement, load the contents stored in memory location
XtothePC.
However, the+ two approaches are not valid when more than one person want to execute the
same subroutine simultaneously, and also when a subroutine calls itself. The reason is that in
both the cases the location whcre the return address is stored will be rewritten by the new
calling address, in turn, canceling the previously stored address.
Thus, a very general approach utilising stacks is used for subroutinecall. The return address
on a subroutine call is pushed on the top of the stack. On encountering a RETURN
statement the POP operation is used to retrieve the most recent return address. This methou
also works for recursive subroutine calls.
Another important aspect of subroutine call is the parameter passing. With a subroutine call,
in general. parameters are passed. There are three approaches for parameter passing
Parameter passing through registers
Parameter passing through memory location just after the call instruction location.
The return address in such a scheme should be the memory location after thesr:
memory based parameters.
Use of stacks for parameter passing in addition to return address.
The drawback of the first approach is that proper utilisation of registers is to be ensured by
the calling program. The second method fails in cases where variable number of parameters
are to be passed. The third approach is quite general in nature. Stacks are used for not only
storing the return address but are also used for storing the parameters which are to be passed
to the subroutine which is called. The stacks are discussed in greater details in Course-4.
'This addressing mode is used to initialise the value of a variable. The advantage of this
mode is that no additional memory accesses are required for executing the instruction.
However, as the size of instruction and operand field are limited, the type of data specified
under this addressing scheme also get restricted.
1 CPU Organisation 1.3.2 Direct Addressing
Under thls addressing scheme, the content A of the operand field specify EA, the effective
address of the operand: i.e.
EA = A and
D = @A)
The second statement implies that the data is stored in the memory location specified by
effective address. In this addressing scheme only one memory reference is required. This
simple addressing scheme provides a limited address space. If the address field has n bits
then the address space available is 2" memory locatigns.
1.3.5 ~ e ~ i s t Indirect
er Addressing
Under this addressing scheme the operand field specifies the registers which contains the
address of the operand.
EA = (R) and
D = (EA)
The address capability of register indirect addressing scheme is determined by the size of the,
register.
I
I 1.3.6 Displacement Addressing
This is a very powerful addressing scheme. It combines both the direct addressing as well as
the register indirect addressing schemes. Here the content A of the operand field is related to
i
EA by
I
The register address R may be specified explicitly or implicitly in the instruction. Depending
I
upon the use and the implementation this address scheme may be known as:
Indexed Addressing Scheme: This addressing scheme is generally used to address me
consecutive locations of memory (which may store the elements of an m y ) . The
t interpretation of the expression €A = A+@) is as follows:
The contents of the operand field A is taken to be the address of the initial or the reference
location (or the first element of array). The contents of register R gives the @lacement
with respect to the reference location. For example, to address of an element Bi of an array
B1, B2,....B,, with each element of the array stored in two consecutive locations, and the
starting address of the array being 101, the operand field A shall contain the number 101 and
i the register R will contain the value of the expression (i-1) x 2. Thus, for the first element of
the array the register will contain 0. For addressing 5th element of the array, the A=101
where as register will contain (5-1) x 2 = 8. Therefore, the address of 5th element of array
B5=101+8=[Link] B5, however, is stored in location 109 and [Link] address any other
element of the array, changing the content of the register (let us call it index register) will
suffice. As the index register are used for iterative applications, therefore, an index register
is incremented or decremented after each reference to it. In several systems this operation is
performed automatically during the course of an instruction cycle. This feature is known as
autoindexing. Autoindexing can be autoincrementing or autodecrementing. The choice of
register to be used as an index register differs from machine to machine. Some machine
employ general purpose registers for this purpose while other machines may specify special
purpose registers referred to as index registers.
Another related addressing scheme which couples the indirect addressing with indexing are
also utilised by several systems. Here, there are two possibilities:
Indexing is performed after indirection (postindexing):
In this scheme the memory address specified by opcode address the location that contains a
direct address which is to be indexed. That is:
DA = (A)
€A = DA+ (R)
D = @A)
( DA is Direct address )
In normal circumstances both pre-indexing and post-indexing are not used in an instruction
set simultaneously.
Base Addressing Scheme: This addressing scheme is generally employed to relocate the
programs in the memory specially in a multiprogramming environment Relocation is
discussed in details in course 2, block 2. Here the register R, referred to as Base Register
contains the initial address in the memory (referred to as the base address) of the program
segment being relocated. The operand field A contains the displacement of an instruction 01
data with respect to the base address. In this case:
€A = A + (B) ; D = (EA)
(B) refers to the contents of a base register B.
The contents of the base register may be changed in the privileged mode only, i.e. in the user
mode the contents of the base register cannot be changed.
CPU Ogmlsatla The base addressing scheme while on one hand provides the enhanced addressable space on
the other hand it provides protection of users from one another.
In a base addressing scheme the address of an index addressed element is given by:
EA = A + (B) + (I), where B and I are base register and index register respectively.
Like index register a base register may be a general purpose register or a special register
reserved for base addressing.
Relative Addressing Scheme: In this addressing scheme, the register R is the program
counter (PC) containing the address of the current insuuction being executed. The operand
field A contain the displacement (positive or negative) of an instruction or data with respect
to the current instruction. This addressing scheme have advantages if the memory references
are nearer to dle current insuuction being executed.
Inswclion Inslruaion
1 Instruction I
R Operand
@) Direct addressing
Address of operand
Main memory
Main memory
Instruction
Instruction
Opt-d operand
- &. .
d
.
#
-_
Operand c Register Set
Register Set
Instruction
Top cf stack
Register Set
I Immcd~atc
Register indircct
-;,
-;,
For moving constants, initialisation of variables
I
I
I
I
I
Check Your Progress 3
1. F~ndout the memory rcferences required to get h e data for h e following addressing
modcs:
D~rcctaddrcss~ng
lndircct addressing
Rcgis~crindircct addressing
I~nmcdiateaddressing
True 1 1 False I 1
(c) Index addressing is used for addressing arrays.
T r u e r 1 False I[
3. What are h e differences between preindexing and postindexing?
4. What are the differences between base and relative addressing schemes?
As far as the designing of instruction format goes, it is a complex art. The computers have a
variety of instructions designed for them in last so many years. We will discuss in this
section about the design issues for instruction sets of the machines. We will discuss only
point wise details of thcse issues.
CPU Organisation 1.4.1 Instruction Length
Significance: It is the most basic issue of the format design. It determines the richncss and
flexibility of a machine.
Basic Tradeoff: Smaller instruction (less space) Vs desire for more powerful instruction
repertoire.
Normally programmer desire:
more Opcode and operands: as it results in smaller programs.
more Addressing modes: for greater flexibility in implementing functions like table
manipulations, multiple branching.
However, a 32 bit instruction although will occupy aouble the space and can be fetched at
double the rate of a 16 bit instruction, but can not be doubly useful.
Factors which must be considered for deciding about instruction length
Memory Size If larger memory range is to be addressed, then more bits may
be required in address field.
Memory organisation : If the addressed memory is virtual memory then memory
range which is to be addressed by the instruction is larger than
physical memory size.
Memory Transfer length : Instruction length should normally be equal to data bus 4
(in bus system is equal length or multiple of it.
to the data bus length)
Memory transfer : The data transfer rate from the memory ideally should be
equivalent to the Processor speed. It can become a bottleneck
if processor executes instructions faster than the rate of fetching
the instructions. One solution for such problem is to use cachc
memory or another solution can be to keep instruction shor~.
Normally an instruction length is kept as a multiple of length of a character (that is 8 bits),
and equal to the length of fixed point number. The term word is often used in this context.
Usually the word size is equal to the length of fixed point number or equal to
memory-transfer size. In addition. a word should store integral number of characters. Thus,
word size of 16 bit, 32 bit, 64 bit are be coming very common and hence the similar length of
instructions are normally being used.
i h e c k Your Progress 4
!Statetrue or false.
1. A long instruction can be executed faster than short instructions.
TNe 1 1 False
2. Virtual addresses require more bits for the address part of instruction in comparison to
non-virtual addresses.
TN~ ( False
3. The speed gap between processor and memory suggests that instruction size should be
as big as possible.
True 1 False
: CPU organisation 4. In general, the instruction length is kept equal to the size of floating point storage
format.
True n False n
5. Large number of operand addresses in instruction leads to smaller programs.
1(
True False
6 Register addresses for specialised register set machines is smaller than that of the
machines having general purpose register set.
True False
7. A machine using direct addressing mode having a memory addressing capability of 8 K
bytes, require 13 bits for byte addressing.
True False
8. In a variable length instruction format, an instruction fetch must fetch the words equal
to the size of smallest instruction.
True False
Fixed point arithmetic One register is used for storing one of the operand
Instructions and theresult, while the second operand can be in
another register or in memory. It provides operations
in either as unsigned 16 or 32 bit integer operands or
16 or 32 bit 2's complemented integer numbers.
Logical Instruction Provided bitwise AND, OR and XOR operations.
General Register Provides 8 shift instructions pairing the following
Shifting Instructions options:
(1) Lcft or right shil't
(2) Usc of single or double rcgistcr
(3) Signcd or logical shift
For example, two of the eight shirt instructions will be
a left, single register, logical shift instruction and a left,
double register, signed shift instruction. A second
operand is used in the instruction to specify the
amount of shift. The shift instruction effects either a
single register or this can effect an even-odd register
pair. The arithmetic shift instruction leaves the sign
bit intact.
General Register - load Provided transfer operations as:
and store Instructions - Register to register transfer
i - Register to memory transfer
- Memory to register transrer
The addressing schemes provided by this system although are simple and easy yet a
programmer must understand how to use the segments in IBM systemL370. This discussion
is beyond the scope of this unit. You can refer to further readings for more derails.
Instruction Format
We will present a simplified tabular representation for the instruction format of IBM
systeml370.
Features:
Variable length instructions : bytes. 4 bytes, 6 bytes instructions
Variable opcode length 1 byte and 2 byte
Eight different instruction formats are used.
Mostly two operand instructions, however, one ana three operands are also used in
some instructions.
F i t two bits of instruction specifies:
length of the instruction and
format of the instruction
First two bits of opcode Instruction length (bytes) instruction opcode format
RR
RX
RREIRSISISI
SSISSE
The instruction,formats are:
Register-Register (R R) : A compact representation
Instruction length : 2bytes
0
- : 1 byte
Register addresses : 2 nos of 4 bit each.
Register : Used f a privileged instructions used by the
Register Extended operating system.
InslrwtlonSets
Instruction length : 4 bytes
%ode : 2 byes
Register addresses : 2 o f l biteach
1 byte is unused.
-
Register-Indexed Instruction Length : 4bytes
(R Jo Opcode : 1 byte
First operand
Register operand : Oneof 4 bit
Second operand
Virtual memory operand : One 4 bit Index Register
4 bit base register
12 bit displacement
Register-Storage (R S) : Instruction lenglh : 4 byte
Number of operands : 3 (the only three
operand instruction
format)
opcode : 1 byte
First operand and Third
operand : Register operands
require 4 bit each for
register reference
Second operand : Virtual memory
operand using a base
register (4 bit) and
displacement (12 bits)
Storage lmmediate Instruction lenglh : 4bytes
(S 1) %ode : 1 byte
First operand : Virtual memory
operand using a base
register(4 bits) and
displacement (12 bits)
Second operand : Immediate operand
of one byte
Storage (S) Used for representing privileged instructions for I10
or system control.
Instruction lenglh : 4bytes
mode : 2bytes
Number of operands : one
Operand address is virtual address using a base
register (4 bits) and displacement (12 bits)
Storagc-Storage (S S) : Instruction lenglh : 6bytes
o~code : 1 byte
Number of operand = 2
both operands are virtual memory operands specified
by base register (4 bits) and displacement (12 bits)
Use of remaining 1 byte :
One length format : The remaining byte specifies
the number of bytes to be operated upon. Used for
moving a block of characters from one location to
another.
Two length format : two length fields of 4 bit each
specifying the size of each of the two operands.
Used for operations on BCD.
Register specifications : The byte designates two
general purpose registers which contains the conuol
*
information or lenglh specifications. Used for
privileged insuuctions.
Storage-Storage Extended : Used for privileged instructions
(S S E) Insmction length : 6 bytes
-Ode : 2 bytes
Two operands both in the form of base register
cPU o r p ~ h t l o n (4 bits) and displacem,ent (12 bits).
Thus,IBM SystemJ370formats tries to m a k efficient use of insuuction lengths. Figure 14
gives the summd of instruction formats of ihis system.
1-
R R Format R -+ Regiater addnaa
I -+ Index Regiater Addreas
B -+ Baae Register Address
A -+ Displacement
7 8 111
Subscript indicate aperand number
R R E Format
Opcode Not used R~ R2
0 15 16 23 24 27 28 31
R X Format
Opcode R1 I2 B2 A2
0 7 8 1112 1516 1920 31
R S Format
Opcode R1 Rj B2 A2
0 7 8 11 12 15 16 19 20 31
S I Format
S Format
Opcode B1 A1
0 15 16 19 20 31
S S Format
Special
Opcode use B1 A1 B2 A2
0 7 8 15 16 19 20 31 32 35 36 47
Special Use : One field of 8 bit specifying length of Block (One length format)
OR
T ~ Ofields of 4 bit each specifying length (Two length format)
OR
Two fields of 4 bit each of register address (Register specification)
S S E Format
Opcode B1 A1 B2 A2
0 15 16 19 20 31 32 35 36 47
1.6 SUMMARY
In this unit, we have introduced you to various concepts relating to an instruction. We have
discussed about the basic characteristics, the number of addresses, type of operands and
operations in instructions and various addressing modes. We have also highlighted the basic
issues while designing instruction formals and presented details on the instruction set of IBM
Instruction ScCl
[Link] note we have not provided you h e detailed insuuctions which his machine
provide. But only h e conceptu&model behind his instruction set. You can refer to furlher
reading for more details on instruction set for various machines.
I
+ parameter passing
+ branching and coming back from a small program
1 5. Refer to sub-section on subroutinecalls.
I
Check Your Progress 3
1. No model answer
I 2. (a)False. (b) False. (c) True
3. Refer sub-section 1.3.6
4. Refer sub-section 1.3.6