instruction code
instruction code
o The Operation code (Opcode) field which specifies the operation to be performed.
o The Address field which contains the location of the operand, i.e., register or memory
location.
o The Mode field which specifies how the operand will be located.
The Register-reference instructions are represented by the Opcode 111 with a 0 in the
leftmost bit (bit 15) of the instruction.
Note: The Operation code (Opcode) of an instruction refers to a group of bits that
define arithmetic and logic operations such as add, subtract, multiply, shift, and
compliment.
Input-Output instruction
Just like the Register-reference instruction, an Input-Output instruction does not need a
reference to memory and is recognized by the operation code 111 with a 1 in the
leftmost bit of the instruction. The remaining 12 bits are used to specify the type of the
input-output operation or test performed.
Note
o The three operation code bits in positions 12 through 14 should be equal to 111.
Otherwise, the instruction is a memory-reference type, and the bit in position 15 is
taken as the addressing mode I.
o When the three operation code bits are equal to 111, control unit inspects the bit in
position 15. If the bit is 0, the instruction is a register-reference type. Otherwise, the
instruction is an input-output type having bit 1 at position 15.
Addressing Modes– The term addressing modes refers to the way in
which the operand of an instruction is specified. The addressing mode
specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually executed.
Addressing modes for 8086 instructions are divided into two
categories:
1) Addressing modes for data
2) Addressing modes for branch
The 8086 memory addressing modes provide flexible access to memory,
allowing you to easily access variables, arrays, records, pointers, and
other complex data types. The key to good assembly language
programming is the proper use of memory addressing modes.
An assembly language program instruction consists of two parts
Example: MOV AL, 35H (move the data 35H into AL register)
Register mode: In register addressing the operand is placed in one of
8 bit or 16 bit general purpose registers. The data is in the register that
is specified by the instruction.
Here one register reference is required to access the data.
The 8086 CPUs let you access memory indirectly through a register
using the register indirect addressing modes.
MOV AX, [BX](move the contents of memory location s
addressed by the register BX to the register AX)
Auto Indexed (increment mode): Effective address of the operand is
the contents of a register specified in the instruction. After accessing
the operand, the contents of this register are automatically incremented
to point to the next consecutive memory location.(R1)+.
Here one register reference,one memory reference and one ALU
operation is required to access the data.
Example:
Add R1, (R2)+ // OR
R1 = R1 +M[R2]
R2 = R2 + d
Useful for stepping through arrays in a loop. R2 – start of array d – size
of an element
Auto indexed ( decrement mode): Effective address of the operand is
the contents of a register specified in the instruction. Before accessing
the operand, the contents of this register are automatically
decremented to point to the previous consecutive memory location. –
(R1)
Here one register reference,one memory reference and one ALU
operation is required to access the data.
Example:
Add R1,-(R2) //OR
R2 = R2-d
R1 = R1 + M[R2]
Auto decrement mode is same as auto increment mode. Both can also be
used to implement a stack as push and pop . Auto increment and Auto
decrement modes are useful for implementing “Last-In-First-Out” data
structures.
Direct addressing/ Absolute addressing Mode (symbol [ ]): The
operand’s offset is given in the instruction as an 8 bit or 16 bit
displacement element. In this addressing mode the 16 bit effective
address of the data is the part of the instruction.
Here only one memory reference operation is required to access the
data.
Computer Registers
Registers are a type of computer memory used to quickly accept, store, and transfer
data and instructions that are being used immediately by the CPU. The registers used by
the CPU are often termed as Processor registers.
A processor register may hold an instruction, a storage address, or any data (such as bit
sequence or individual characters).
The computer needs processor registers for manipulating data and a register for holding
a memory address. The register holding the memory location is used to calculate the
address of the next instruction after the execution of the current instruction is completed.
The following image shows the register and memory configuration for a basic computer.
o The Memory unit has a capacity of 4096 words, and each word contains 16
bits.
o The Data Register (DR) contains 16 bits which hold the operand read from the
memory location.
o The Memory Address Register (MAR) contains 12 bits which hold the address
for the memory location.
o The Program Counter (PC) also contains 12 bits which hold the address of
the next instruction to be read from memory after the current instruction is
executed.
o The Accumulator (AC) register is a general purpose processing register.
o The instruction read from memory is placed in the Instruction register (IR).
o The Temporary Register (TR) is used for holding the temporary data during
the processing.
o The Input Registers (IR) holds the input characters given by the user.
o The Output Registers (OR) holds the output after processing the input data.
Instruction Cycle
A program residing in the memory unit of a computer consists of a sequence of
instructions. These instructions are executed by the processor by going through a cycle
for each instruction.
Register Transfer
The term Register Transfer refers to the availability of hardware logic circuits that can
perform a given micro-operation and transfer the result of the operation to the same or
another register.
Most of the standard notations used for specifying operations on various registers are
stated below.
o Typically, most of the users want the transfer to occur only in a predetermined control
condition. This can be shown by following if-then statement:
If (P=1) then (R2 ← R1); Here P is a control signal generated in the control section.
o It is more convenient to specify a control function (P) by separating the control
variables from the register transfer operation. For instance, the following statement
defines the data transfer operation under a specific control function (P).
1. P: R2 ← R1
The following image shows the block diagram that depicts the transfer of data from R1 to
R2.
Bus and Memory Transfers
A digital system composed of many registers, and paths must be provided to transfer
information from one register to another. The number of wires connecting all of the
registers will be excessive if separate lines are used between each register and all other
registers in the system.
A bus structure, on the other hand, is more efficient for transferring information between
registers in a multi-register configuration system.
A bus consists of a set of common lines, one for each bit of register, through which
binary information is transferred one at a time. Control signals determine which register
is selected by the bus during a particular register transfer.
The following block diagram shows a Bus system for four registers. It is constructed with
the help of four 4 * 1 Multiplexers each having four data inputs (0 through 3) and two
selection inputs (S1 and S2).
We have used labels to make it more convenient for you to understand the input-output
configuration of a Bus system for four registers. For instance, output 1 of register A is
connected to input 0 of MUX1.
The two selection lines S1 and S2 are connected to the selection inputs of all four
multiplexers. The selection lines choose the four bits of one register and transfer them
into the four-line common bus.
When both of the select lines are at low logic, i.e. S1S0 = 00, the 0 data inputs of all four
multiplexers are selected and applied to the outputs that forms the bus. This, in turn,
causes the bus lines to receive the content of register A since the outputs of this register
are connected to the 0 data inputs of the multiplexers.
Similarly, when S1S0 = 01, register B is selected, and the bus lines will receive the
content provided by register B.
The following function table shows the register that is selected by the bus for each of the
four possible binary values of the Selection lines.
bus system can also be constructed using three-state gates instead of multiplexers.
Advertisement
The three state gates can be considered as a digital circuit that has three gates, two of
which are signals equivalent to logic 1 and 0 as in a conventional gate. However, the
third gate exhibits a high-impedance state.
The most commonly used three state gates in case of the bus system is a buffer gate.
The following diagram demonstrates the construction of a bus system with three-state
buffers.
o The outputs generated by the four buffers are connected to form a single bus line.
o Only one buffer can be in active state at a given point of time.
o The control inputs to the buffers determine which of the four normal inputs will
communicate with the bus line.
o A 2 * 4 decoder ensures that no more than one control input is active at any given
point of time.
Memory Transfer
Most of the standard notations used for specifying operations on memory transfer are
stated below.
o The transfer of information from a memory unit to the user end is called
a Read operation.
o The transfer of new information to be stored in the memory is called
a Write operation.
o A memory word is designated by the letter M.
o We must specify the address of memory word while writing the memory transfer
operations.
o The address register is designated by AR and the data register by DR.
o Thus, a read operation can be stated as:
1. Read: DR ← M [AR]
o The Read statement causes a transfer of information into the data register (DR) from
the memory word (M) selected by the address register (AR).
o And the corresponding write operation can be stated as:
1. Write: M [AR] ← R1
o The Write statement causes a transfer of information from register R1 into the
memory word (M) selected by address register (AR).
Arithmetic Micro-operations
In general, the Arithmetic Micro-operations deals with the operations performed on
numeric data stored in the registers.
1. Addition
2. Subtraction
3. Increment
4. Decrement
5. Shift
The following table shows the symbolic representation of various Arithmetic Micro-
operations.
P: R1←R1⊕⊕R2
1010 Content of R1
1100 Content of R2
0110 Content of R1 after P = 1
To implement the logical shift left micro-operation, we use the shl symbol.
For example, R1 -> shl R1.
This command means the 8 bits present in the R1 register will be logically shifted
left, and the result will be stored in register R1.
Moreover, the logical shift left microoperation denotes the multiplication of 2. The
example we’ve taken above when converted into decimal forms the number 10. And
the result after the logical shift operation when converted to decimal forms the
number 20.
Next, we will see the logical shift right micro-operation.
Logical Shift Right
Each bit in the register is shifted to the right one by one in this shift micro-operation.
The least significant bit (LSB) is moved outside the register, and the place of the
most significant bit (MSB) is filled with 0.
For example, in the below data, there are 8 bits 00000101. When we perform a
logical shift right on these bits, all these bits will be shifted towards the right. The
LSB or the rightmost bit i.e. 1 will be moved outside, and at the leftmost place or
MSB, 0 will be inserted as shown below.
To implement the logical shift right micro-operation, we use the shr symbol.
For example, R1 -> shr R1.
This command means the 8 bits present in the R1 register will be logically shifted
right, and the result will be stored in register R1.
Logical right shift micro-operation generally denotes division by 2. The inputted bits
when converted into decimal form the number 5. And the outcome when converted
into decimal forms the number 2.
Next, we will study arithmetic shift micro-operation.
Arithmetic Shift
The arithmetic shift micro-operation moves the signed binary number either to the
left or to the right position. There are two ways to implement the arithmetic shift.
1. Arithmetic Shift Left
2. Arithmetic Shift Right
Let’s discuss both of them one by one.
Arithmetic Shift Left
The arithmetic shift left micro-operation is the same as the logical shift left micro-
operation. Each bit in the register is shifted to the left one by one in this shift micro-
operation. The most significant bit (MSB) is moved outside the register, and the
place of the least significant bit (LSB) is filled with 0.
For example, in the below data, there are 8 bits 00100011. When we perform the
arithmetic shift left on these bits, all these bits will be shifted towards the left. The
MSB or the leftmost bit i.e. 0 will be moved outside, and at the rightmost place or
LSB, 0 will be inserted as shown below.
The given binary number (00100011) represents 35 in the decimal system. And the
binary number after logical shift left (01000110) represents 70 in a decimal system.
Since 35 * 2 = 70. Therefore, we can say that the arithmetic shift left multiplies the
number by 2.
To implement the arithmetic shift left micro-operation, we use the ashl symbol.
For example, R1 -> ashl R1.
This command means the 8 bits present in the R1 register will be arithmetic shifted
left, and the result will be stored in register R1.
Arithmetic Shift Right
Each bit in the register is shifted to the right one by one in this shift micro-operation.
The least significant bit (LSB) is moved outside the register, and the place of the
most significant bit (MSB) is filled with the previous value of MSB.
For example, in the below data, there are 8 bits 10100011. When we perform an
arithmetic shift right on these bits, all these bits will be shifted towards the right. The
LSB or the rightmost bit i.e. 1 will be moved outside, and at the leftmost place or
MSB, the previous MSB value, i.e. 1, will be inserted as shown below.
Arithmetic right shift divides the number by 2.
To implement the arithmetic shift right micro-operation, we use the ashr symbol.
For example, R1 -> ashr R1.
This command means the 8 bits present in the R1 register will be arithmetic shifted
right, and the result will be stored in register R1.
Next, we will study circular shift micro-operation.
Circular Shift
The circular shift, also known as the rotate shift, moves the bits in the register's
sequence around both ends, thus ensuring no loss of information. There are two
ways to implement the circular shift.
1. Circular Shift Left
2. Circular Shift Right
Let’s discuss both of them one by one.
Circular Shift Left
Each bit in the register is shifted to the left one by one in this shift micro-operation.
After shifting, the least significant bit (LSB) place becomes empty, so it is filled with
the value at the most significant bit (MSB).
For example, in the below data, there are 8 bits 00010100. When we perform a
circular shift left on these bits, all these bits will be shifted towards the left. The MSB
or the leftmost bit i.e. 0 will be placed at the rightmost place or LSB as shown below.
To implement the circular shift left micro-operation, we use the cil symbol.
For example, R1 -> cil R1.
This command means the 8 bits present in the R1 register will be circular shifted left,
and the result will be stored in register R1.
Next, we will discuss circular shift right micro-operation.
Circular Shift Right
Each bit in the register is shifted to the right one by one in this shift micro-operation.
After shifting, the most significant bit (MSB) place becomes empty, so it is filled with
the value at the least significant bit (LSB).
For example, in the below data, there are 8 bits 00010100. When we perform a
circular shift right on these bits, all these bits will be shifted towards the right. The
LSB or the leftmost bit, i.e. 0, will be placed at the rightmost place or MSB.
To implement the circular shift right micro-operation, we use the cir symbol.
For example, R1 -> cir R1.
This command means the 8 bits present in the R1 register will be circular shifted
right, and the result will be stored in register R1.