6th ca
6th ca
Instruction formats
Addressing modes
Instruction set
All other instructions are executed within the registers of the CPU
without referring to memory.
The add and multiply operations are executed with data in the registers
without accessing memory.
The way the operands are chosen during program execution is dependent on
the addressing mode of the instruction.
The computer then executes the instruction and returns to step 1 to fetch the
next instruction in sequence.
In some computers the addressing mode of the instruction is specified with a
distinct binary code, just like the operation code is specified.
Other computers use a single binary code that designates both the operation
and the mode of the instruction.
Moreover, the instruction may have more than one address field, and each
address field may be associated with its own particular addressing mode.
Although most addressing modes modify the address field of the instruction,
there are two modes that need no address field at all.
The operand field contains the actual operand to be used in conjunction with the
operation specified in the instruction.
It was mentioned previously that the address field of an instruction may specify
either a memory word or a processor register.
When the address field specifies a processor register, the instruction is said to be
in the register mode.
Register Mode:
In this mode, the operands are in registers that reside within the CPU.
When the address stored in the register refers to a table of data in memory, it
is necessary to increment or decrement the register after every access to the
table.
Sometimes the value given in the address field is the address of the operand,
but sometimes it is just an address from which the address of the operand is
calculated.
The operand resides in memory and its address is given directly by the
address field of the instruction.
Control fetches the instruction from memory and uses its address part to
access memory again to read the effective address.
A few addressing modes require that the address field of the instruction be
added to the content of a specific register in the CPU.
The effective address in these modes is obtained from the following computation:
The CPU register used in the computation may be the program counter, an
index register, or a base register.
In either case we have a different addressing mode which is used for a different
application.
Relative Address Mode:
In this mode, the content of the program counter is added to the address
part of the instruction in order to obtain the effective address.
The address part of the instruction is usually a signed number (in 2’s
complement representation) which can be either positive or negative.
When this number is added to the content of the program counter, the
result produces an effective address whose position in memory is relative
to the address of the next instruction.
To clarify with an example, assume that the program counter contains the
number 825 and the address part of the instruction contains the number 24.
The instruction at location 825 is read from memory during the fetch phase and
the program counter is then incremented by one to 826.
The effective address computation for the relative address mode is:
826 + 24 = 850.
This is 24 memory locations forward from the address of the next instruction.
Relative addressing is often used with branch-type instructions when the
branch address is in the area surrounding the instruction word itself.
It results in a shorter address field in the instruction format since the relative
address can be specified with a smaller number of bits compared to the
number of bits required to designate the entire memory address.
Indexed Addressing Mode:
In this mode, the content of an index register is added to the address part of
the instruction to obtain the effective address.
The index register is a special CPU register that contains an index value.
The address field of the instruction defines the beginning address of a data
array in memory.
In computers with many processor registers, any one of the CPU registers
can contain the index number.
This is similar to the indexed addressing mode except that the register is
now called a base register instead of an index register.
The difference between the two modes is in the way they are used rather
than in the way that they are computed.
When programs and data are moved from one segment of memory to
another, as required in multiprogramming systems, the address values of
instructions must reflect this change of position.
The instruction in addresses 250 and 251 is “load to AC,” with the
address field ADRS (or an operand NBR) equal to 500.
In the direct mode, the effective address is 500, and the operand to be
loaded into the AC is 800.
In the immediate mode, the operand 500 is loaded into the AC.
In the indirect mode, the effective address is 800, and the operand is
300.
In the relative mode, the effective address is 500 + 252 = 752, and the
operand is 600.
In the index mode, the effective address is 500 + 400 = 900, assuming
that R1 is the index register.
In the register mode, the operand is in R1, and 400 is loaded into
the AC.
AC receives the operand after the instruction is executed. The figure lists a
few pertinent addresses and shows the memory content at each of these
addresses.
The mode field of the instruction can specify any one of a number of
modes.
For each possible mode, we calculate the effective address and the
operand that must be loaded into AC.
In the direct address mode, the effective address is the address part of
the instruction 500 and the operand to be loaded into AC is 800.
The Table lists the values of the effective address and the operand loaded
into AC for the nine addressing modes.
We list the values of the effective address and the operand loaded into AC for
the nine addressing modes.
Computers provide an extensive set of instructions to give the user the flexibility
to carry out various computational tasks.
The instruction set of different computers differ from each other mostly in the
way the operands are determined from the address and mode fields.
The actual operations available in the instruction set are not very different
from one computer to another.
It so happens that the binary code assignments in the operation code field is
different in different computers, even for the same operation.
It may also happen that the symbolic name given to instructions in the
assembly language notation is different in different computers, even for the
same instruction.
Nevertheless, there is a set of basic operations that most, if not all,
computers include in their instruction repertoire.
Data transfer instructions cause transfer of data from one location to another
without changing the binary information content.
Typically, Data Transfer Instructions are given below as
The load instruction has been used mostly to designate a transfer from
memory to a processor register, usually an accumulator.
The store instruction designates a transfer from a processor register
into memory.
The move instruction has been used in computers with multiple CPU
registers to designate a transfer from one register to another. It has also
been used for data transfers between CPU registers and memory or
between two memory words.
The exchange instruction swaps information between two registers or a
register and a memory word.
The input and output instructions transfer data among processor
registers and input or output terminals.
The push and pop instructions transfer data between processor
registers and a memory stack.
2. Data manipulation instructions
Data manipulation instructions are those that perform arithmetic, logic, and shift
operations.